Skills Night › Introduction to AI

Lesson 5.3 — Harnesses: CLAUDE.md, Permissions, Hooks

Introduction to AI · Module 5: AI Agents · About 75 min · Windows PC, PowerShell 5, Claude Code (Max)

Goal: control how your Folder Tidy agent behaves: standing instructions, a rule it can't break (no deleting), and a one-word command /tidy.

The harness is everything around the model: the loop, the tools, the memory files, and the permission rules. Same model, different harness = different agent. Module 7 goes deeper.

Before you start

Step 1 · Reset the mess (⏱ 0:00–0:05)

dir messy -Recurse -File | Move-Item -Destination messy -Force
Remove-Item messy\Documents, messy\Images, messy\Spreadsheets -Recurse -ErrorAction SilentlyContinue
Remove-Item messy\REPORT.md -ErrorAction SilentlyContinue
.\check.ps1

You should see FAIL.

Step 2 · Upgrade CLAUDE.md (⏱ 0:05–0:15)

Open it:

notepad CLAUDE.md

Add these lines at the bottom, then save:

Style:
- Before moving anything, print a short plan (max 5 lines).
- After PASS, reply with one line: "Tidied N files. PASS."

Step 3 · Add a hard rule: no deleting (⏱ 0:15–0:30)

CLAUDE.md is advice. Permission rules are enforced by the harness, whatever the model wants. Paste the whole block:

mkdir .claude -Force | Out-Null
$json = @'
{
  "permissions": {
    "allow": ["Read", "Glob", "Edit", "Write"],
    "deny": [
      "Bash(rm:*)", "Bash(del:*)",
      "PowerShell(Remove-Item:*)", "PowerShell(rm:*)", "PowerShell(del:*)"
    ]
  }
}
'@
[IO.File]::WriteAllText("$HOME\agent-night\.claude\settings.json", $json)
Get-Content .claude\settings.json

Inside Claude, /permissions shows the active rules.

Step 4 · Test the rule (⏱ 0:30–0:40)

claude

Type:

Delete the file messy\a-receipt.pdf

You should see Claude get blocked or refuse (a "denied" message or similar). If it asks permission instead, choose No and note that the rule didn't match the command it tried.

Then **type /exit and press Enter. Wait until you see PS C:\...> before the next command.** Then check the file is still there:

Test-Path messy\a-receipt.pdf

You should see True.

Step 5 · Make a /tidy command (⏱ 0:40–0:55)

mkdir .claude\commands -Force | Out-Null
$cmd = @'
Tidy the messy folder following CLAUDE.md. Run .\check.ps1 at the end and report the result.
'@
[IO.File]::WriteAllText("$HOME\agent-night\.claude\commands\tidy.md", $cmd)
claude

In Claude, type:

/tidy

You should see a short plan, the moves, then Tidied 12 files. PASS.

Step 6 · Peek at hooks (⏱ 0:55–1:10, optional)

Hooks are scripts the harness runs automatically, e.g. after every file edit. In Claude, type /hooks to see the menu. Just look for now: you'll build one in Module 7.

Write one line: a hook I'd want is .

Then **type /exit and press Enter. Wait until you see PS C:\...> before the next command.**

✅ Pass check

Troubleshooting

ProblemFix
/tidy not foundCheck the file is at .claude\commands\tidy.md, then restart claude.
settings.json error on startThe JSON is broken. Re-paste Step 3 exactly.
Delete wasn't blockedClaude used a different command form. Ask it "what exact command did you try?" and add a matching deny rule, e.g. "PowerShell(Remove-Item *)".
Moves now need approval every timeThat's expected for commands not in allow. Approve them, or add "PowerShell(Move-Item:*)" to allow.
Stuck? Ask Skills Coach. Send a screenshot or paste the error plus the step number. Don't stay stuck on one step for more than 10 minutes.

Finish this lesson

← Previous (5.2)