Skip to content
Agentic Levels
  • New to AI?
  • Assessment
  • Levels
  • Lessons
  • Tracks
  • Resources
  • Reference
  • What's New
  • What's Next
  • More
    Tool SetupCompareAboutThanksFAQPricingPreferences
  • New to AI?
  • Assessment
  • Levels
  • Lessons
  • Tracks
  • Resources
  • Reference
  • Tool Setup
  • Compare
  • What's New
  • About
  • Thanks
  • FAQ
  • What's Next
  • Pricing

© 2026 Fuentes Studio·Privacy·Terms

yourCouncil
Ready to help
✦

What do you want to understand?

Ask anything about what you're learning.

L8Lesson 6

Your First Background Agent

After this, you'll be able to kick off one low-risk task as a background agent, verify the output when it finishes, and use a git worktree so the agent works in isolation.

Before you start

You'll want a working sense of Define the Blast Radius before this lesson, since background agents run unsupervised and need a Tier 1 classification before you let them loose.

The idea

You have the inner loop, structured logs, a checkpoint, and a blast-radius classification. Now you combine all of it: you define the task, start the agent, walk away, and come back to a completed diff. That is the L8 payoff.

For Claude Desktop users: use the 'run in background' option in a new conversation, or simply start a long-running task and switch windows. Claude will continue working and notify you when done. For Claude Code users: the headless flag (claude --headless or -H) runs a session without the interactive UI. Pass the task as a prompt. The agent works. When it finishes, the result is in your git tree.

Git worktrees are the isolation layer. Instead of the agent working in your main checkout, a worktree creates a second checkout of the same repo in a separate directory. The agent works there. You work in the main tree. No conflicts. When it finishes, you review the diff and merge if it passes.

Here is the before and after: a JSDoc-coverage task runs in a worktree at ../project-jsdoc-agent created with git worktree add. The headless command runs claude with a prompt that names the directory, the spec criteria, and the test command. The agent edits 14 files, runs npm test, and reports 'JSDoc added to 14 functions in src/utils/. All 63 tests pass. No signatures changed. Spec: 4/4 criteria passed. Ready to review.' You review the diff once.

The right first task: a Tier 1 task with a passing test suite and a 3-5 criterion spec. Good candidates: generate JSDoc for all exported functions, add missing type annotations, apply a style fix across a directory. Bad candidates: anything Tier 2+, anything with ambiguous success criteria. The first run will feel anticlimactic. The agent runs, you check back, you review the diff. That anticlimactic feeling is the goal.

Try it (25 min)

Watch out for

  • Running the first background agent on a task with no tests. Without a runnable check, the agent cannot verify its own output and cannot close the loop.
  • Skipping the worktree. Running the agent directly in your main checkout means its changes are mixed with your in-progress work and cannot be cleanly reviewed.
  • Picking a task that requires judgment to evaluate. 'Improve the code quality' is not a background task. 'Add JSDoc to every exported function with no existing JSDoc' is.
  • Not setting a time budget. Background agents can spin in loops. Give the task a token or time cap for your first run.
  • Merging the diff without running tests. The agent verified its own output, but you still run the test suite after merging. Trust the spec, verify the merge.

Paste this into Claude:

I want to run my first background agent task. Help me set it up: (1) Identify a Tier 1 task from my project that has a passing test suite and clear success criteria: [describe your project and a candidate task, e.g. 'generate JSDoc comments for all exported functions in src/utils/' or 'add missing type annotations to all functions in src/api/']. (2) Write the spec: 3-4 binary criteria the agent should verify before it is done. (3) For Claude Code: write the exact shell command to run this as a headless session, including how to capture output to a log file. For Claude Desktop: describe how to set up the task and let it run in the background. (4) Show me how to create a git worktree for this task so the agent works in isolation. Then walk me through reviewing the diff when the agent finishes.

What good looks like:

  • You identified a Tier 1 task with a passing test suite and a written spec
  • You created a git worktree and the agent ran inside it, not in your main checkout
  • The agent completed without interactive prompts from you
  • You reviewed the diff after the run and could evaluate it against each spec criterion
  • The test suite still passes after the agent's changes

What a good response looks like:

Setup for first background agent run (Claude Code path):

```bash
# Create the worktree
git worktree add ../project-jsdoc-agent main

# Run headless session inside the worktree
cd ../project-jsdoc-agent
claude --headless \
  --output-format stream-json \
  'Add JSDoc comments to every exported function in src/utils/ that does not already have one. For each function: document params, return type, and a one-sentence description. Run npm test when done. Report pass/fail.' \
  2>&1 | tee agent-run.log
```

Spec verified by agent before reporting done:
1. STRUCTURAL: Only files in src/utils/ modified. (grep check: git diff --name-only | grep -v src/utils/)
2. BEHAVIORAL: All existing tests pass. (npm test exits 0)
3. COVERAGE: Every exported function with no existing JSDoc now has one. (grep -rn 'export.*function' src/utils/ | count vs JSDoc count)
4. NEGATIVE: No function signatures changed. (git diff src/utils/ | grep '^-export' should be empty)

Agent completion report:
'JSDoc added to 14 functions in src/utils/. All 63 tests pass. No signatures changed. Spec: 4/4 criteria passed. Ready to review.'

Your review: check the diff, run npm test once more after merge. Done.

When this breaks

  • Breaks when the task has no runnable check because the background agent cannot close its own loop and reports 'done' from a state that may not be done.
  • Breaks when the agent runs in the main checkout because its changes mix with your in-progress work and the diff that should be reviewable becomes a manual untangle.
  • Breaks when success criteria need judgment because nothing the agent can run mechanically tells it whether to stop, and the run drifts past the bound you expected.

Claude can do it for you

Say to Claude: 'Help me set up a background agent run. Task: [your task]. Write the spec, create the worktree command, write the headless command to run it, and tell me exactly what to check in the diff when it finishes.' Claude Desktop users: ask the same question, and Claude will give you the Desktop-native path for background execution.

You can now

Run a single Tier 1 task end-to-end in a git worktree without intermediate prompts, then review the resulting diff against each spec criterion before merging.

Key takeaways

Define the task, write the spec, start the agent, do other work. Review the diff when it is done. That is the L8 workflow. The first run is always the hardest, because it requires trusting the loop you built.

  • Background agents combine the inner loop, spec-as-test, observability, and tier classification into one workflow
  • Worktrees isolate the agent from your main checkout so the diff is cleanly reviewable
  • First task: Tier 1, passing test suite, 3-5 binary criteria. Anything else is too ambitious for run one.
  • Trust the spec, verify the merge. Run the test suite after merging even when the agent reports green.

Go deeper

  • The Ralph Loop (ghuntley.com, autonomous looping until done)
  • Claude Code Sub-Agents (headless mode reference)
  • Get Shit Done (minimal agent orchestration framework)