Skip to main content

Out of the Loop: Letting the Agent Work on Its Own

Why This Matters

Watching every step does not scale. The value of an agent grows when it can finish a larger piece of work while you do something else. That requires trust, and trust comes from clear limits and automatic checks, not from hope.

Decide where you watch and where you do not

Split a task into zones before you start:

ZoneExamplesYour involvement
AutonomousEdits in src/ and tests/, running tests and lintReview the final diff
Ask firstNew dependencies, config changes, deleting filesApprove each action
NeverPushing to main, production data, secrets, rm -rfBlocked

Turn the zones into permissions

Claude Code asks for approval before risky actions. You can pre-approve safe ones and deny dangerous ones in .claude/settings.json:

{
  "permissions": {
    "allow": [
      "Bash(npm test:*)",
      "Bash(npm run check:*)",
      "Bash(npx playwright test:*)",
      "Edit(src/**)",
      "Edit(tests/**)"
    ],
    "deny": [
      "Bash(git push:*)",
      "Bash(rm -rf:*)",
      "Read(.env*)"
    ]
  }
}

Shift+Tab to auto-accept edits lets the agent change files without asking each time, while commands outside the allow list still need your approval. Avoid flags that skip all permission checks on your own machine; use them only in an isolated container if at all.

Give it a definition of done

An agent working alone needs to know when to stop. Put it in the prompt or in CLAUDE.md:

Implement the flaky history panel from the approved plan.
You are done when: npm run check is green, the new e2e test passes,
and you have listed any decision you made that I did not ask for.
Do not push. Stop and ask if you need a new dependency.

Build trust step by step

  1. Start with tasks that are easy to verify (tests, small refactors).
  2. Let it run longer when the last few results needed no rework.
  3. Add automatic checks (hooks, lesson 15, Rules versus Hooks) for things you keep checking by hand.
  4. Work on a branch or in a separate worktree (lesson 14, Subagents and Parallel Agents in Git Worktrees), so a bad run costs one git branch -D.

Hands-on

  1. Write the three zones for your project.
  2. Translate them into permissions in .claude/settings.json and commit them.
  3. Give the agent a 20 to 30 minute task with a written definition of done, on a fresh branch.
  4. Do something else. Afterwards, review the diff and note what you had to correct: that list is input for your next CLAUDE.md or hook.

Walkthrough in TestRun Board

  1. Open .claude/settings.json. The allow list contains the commands the agent may run without asking: npm test, npm run check, lint, typecheck, e2e, mutation, generate:api, and read-only git. The deny list blocks git push, rm -rf and reading .env files.
  2. The hooks add a second layer: even if someone widens the permissions, .claude/hooks/block-dangerous.mjs still blocks pushing, hard resets, --no-verify and npm install <package>.
  3. Give the agent a 20-minute task with a definition of done, on a new branch:
    Implement docs/specs/status-filter.md. Done when npm run check is green, the e2e test for
    the filter exists, and you have listed every decision I did not ask for. Do not push.
    Ask before adding a dependency.
    
  4. Switch to auto-accept edits (Shift+Tab) and leave it alone.
  5. Afterwards note every permission prompt that appeared and every correction you had to make. A prompt for a safe command means the allow list is too narrow; a correction you make twice belongs in AGENTS.md or a hook.

Key Takeaways

  • Decide up front what is autonomous, what needs approval and what is forbidden.
  • Encode that in permissions, not in memory.
  • A written definition of done tells the agent when to stop.
  • Expand autonomy gradually, based on how much rework the last runs needed.