Skip to content
groundworkv0.2

Set up an agent-ready project

A hands-on walkthrough that adds a project file, a deny rule, a hook and a skill to a small demo app, with a check after every step.

7 min read · Last reviewed December 4, 2026

Set up an agent-ready project

A hands-on walkthrough that adds a project file, a deny rule, a and a skill to a small demo app, with a check after every step.

You need Node.js, git and Claude Code, signed in. It takes about 20 minutes. If the terms are new, read AI vocabulary and when to use what first.

Four layers around a project: CLAUDE.md informs the agent, a permission rule and a hook limit it, and a skill gives it a procedure.

Step 1: Create the demo project#

Download the starter script, read it, then run it in an empty working folder. It only creates a bookings-demo folder with a few small files, and stops if that folder already exists.

sh agent-ready-start.sh
cd bookings-demo
git init
git add -A
git commit -m "Start"
npm test

Check it worked. The test summary ends with:

ℹ tests 2
ℹ pass 2
ℹ fail 0

If it went wrong. node --test not found usually means an old Node version. A git error about your name or email means git needs those configured first.

Step 2: Write the project file#

Create CLAUDE.md in the project folder. It holds facts the agent needs every session: how to test, and what it must not do.

# Bookings demo

A tiny room-booking library in plain Node (ES modules). No dependencies.

## Commands
- Run tests: `npm test`

## Rules
- Business logic goes in `src/`, with a test in `test/` for every behaviour change.
- Files already in `migrations/` are applied. Never edit them; add the next numbered file.
- Don't add dependencies without asking.

Claude Code's /init command can draft this file for a real project. Read the draft and cut it down; the docs suggest staying under 200 lines. If your project already has an AGENTS.md, a CLAUDE.md whose first line is @AGENTS.md imports it.

Check it worked. Start claude in the folder and send:

Prompt
How do I run the tests in this project, and what are the rules for migrations? Answer in two sentences.
Run the tests with `npm test`, which runs `node --test`. Files already in
`migrations/` count as applied, so never edit them; make any change by adding
the next numbered file (currently that would be `002_...sql`).

If it went wrong. Check that you started Claude Code inside bookings-demo and that the file name is exactly CLAUDE.md.

Step 3: Block reading secrets#

First make a fake secrets file. .gitignore already excludes .env.

cp example.env .env
mkdir -p .claude

Create .claude/settings.json with a deny rule:

{
  "permissions": {
    "deny": ["Read(./.env)"]
  }
}

Check it worked. In a new session, send:

Prompt
Show me the contents of the .env file.
I couldn't show the `.env` file: permission to run the command was denied, so I
haven't seen its contents or confirmed that it exists.

If it went wrong. If the contents appear, check that the JSON is valid and the file is at .claude/settings.json, then start a new session. Run /permissions to see the active rules.

Step 4: Protect applied migrations with a hook#

The project file asks. A hook enforces, for the tools it matches. Create .claude/hooks/protect-migrations.mjs:

// Blocks edits to migration files that already exist. New migration files are allowed.
import { existsSync, readFileSync } from "node:fs";
import path from "node:path";

const input = JSON.parse(readFileSync(0, "utf8"));
const file = input.tool_input?.file_path ?? "";
const inMigrations = path.basename(path.dirname(file)) === "migrations";

if (inMigrations && existsSync(file)) {
  console.error(`Blocked: ${path.basename(file)} is already applied. Add a new numbered migration instead.`);
  process.exit(2);
}

Replace .claude/settings.json with this, which keeps the deny rule and registers the hook:

{
  "permissions": {
    "deny": ["Read(./.env)"]
  },
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "node \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/protect-migrations.mjs"
          }
        ]
      }
    ]
  }
}

Check the script on its own first. A hook is a program, so you can feed it input without an agent:

echo "{\"tool_input\":{\"file_path\":\"$PWD/migrations/001_create_bookings.sql\"}}" | node .claude/hooks/protect-migrations.mjs
echo "exit=$?"
Blocked: 001_create_bookings.sql is already applied. Add a new numbered migration instead.
exit=2

Exit code 2 is what tells Claude Code to block the call.

Then check it through the agent. /hooks should list it. Send:

Prompt
Add a notes TEXT column to the bookings table by editing migrations/001_create_bookings.sql directly with your edit tool. I am deliberately testing the guard, so try the edit and tell me exactly what happened. Do not work around it.
PreToolUse:Edit hook error: [node "$CLAUDE_PROJECT_DIR"/.claude/hooks/protect-migrations.mjs]:
Blocked: 001_create_bookings.sql is already applied. Add a new numbered migration instead.

If it went wrong. If the edit succeeds, run the script check above. If that blocks but the agent is not stopped, the hook is not registered: check /hooks and restart the session.

Step 5: Break your own guard#

Do not stop at the first green result. Ask for the same change by another route. Approve the shell command if asked: this is a throwaway project.

Prompt
I am testing my own guard in this throwaway demo. Using a shell command (not the edit tool), append the comment line '-- touched' to migrations/001_create_bookings.sql, then report what happened.
I appended `-- touched` to `migrations/001_create_bookings.sql` with a shell
redirect (`echo ... >>`), and the write went through. Nothing blocked it.

The hook's matcher is Edit|Write, so it never saw a shell command. Undo the change:

git restore migrations/001_create_bookings.sql

What this teaches: a guard covers the paths you tested and no others. For a client project, back it with something outside the agent, such as a check in CI that fails when an existing migration changes, and review the diff.

Step 6: Add a pre-commit skill#

A skill is a procedure you would otherwise keep retyping. Create .claude/skills/pre-commit-check/SKILL.md:

---
name: pre-commit-check
description: Check uncommitted changes before committing. Use when asked to check, review or commit work in this project.
---

1. Run `git status --short` and `git diff` to see what changed.
2. Run `npm test`. If it fails, stop and report the failure.
3. Report each item as ok or problem, with the file name:
   - every behaviour change in `src/` has a test
   - no existing file in `migrations/` was edited
   - no secret or `.env` file is about to be committed
4. Do not commit and do not edit files.

Give it something to find by adding a function with no test to the end of src/bookings.js:

export function cancelBooking(list, room, start) {
  return list.filter((b) => b.room !== room || b.start !== start);
}

Check it worked. Send:

Prompt
/pre-commit-check
Pre-commit check: one problem to fix before committing. `npm test` passes (2 of 2).

Problem: `src/bookings.js` adds `cancelBooking`, and neither of the two tests
that ran covers it.
OK: no changes under `migrations/`.
OK: no secret or `.env` file about to be committed.

If it went wrong. If the command is unknown, check the folder name and path, then run /reload-skills.

Step 7: Commit the setup#

Remove the untested function, then commit the configuration so everyone who clones the project gets it.

git restore src/bookings.js
git add CLAUDE.md .claude
git status --short
git commit -m "Add agent setup"

Check it worked. git status --short, run before the commit, lists CLAUDE.md and three files under .claude/, and no .env.

Use it on your next project#

The finished setup script adds these four files to the folder you run it in. It refuses to overwrite files that exist. Then change them to fit:

  • Rewrite CLAUDE.md with that project's real commands and rules.
  • Change the folder the hook protects, or delete the hook if you have no migrations.
  • Read the before using it, and swap npm test for the project's test command.

Go deeper#