Guide · Claude Code · Agentic engineering
Get Out the Loop
A field guide to agentic engineering with Claude Code: how to turn every lesson you learn in review into something a machine enforces, so you can stop supervising and start trusting.
Why you step into the loop
Every time you stop an agent, read its diff line by line, or take the keyboard back, you do it for one reason: trust. You do not trust that the result is right.
You can't talk yourself into trust, and a better prompt won't give it to you. You earn it the same way you earn it with a new engineer: you watch what goes wrong, you say what you expect, and then you put a check in place so the same mistake can't ship twice.
That is the whole method. Learnings become deterministic. Each time you step in, you leave behind a rule that runs without you. Do that enough times and there is nothing left to step in for except the two jobs that stay human: writing the spec and making the final call.
A lesson has three stages
This is teaching the model by example, and then refusing to rely on the teaching.
Prompts are suggestions. Hooks are laws.
- Observe. You catch the agent following a bad pattern in review.
- Capture intent. You write the lesson down in a prompt or in CLAUDE.md. At this stage it is a suggestion.
- Enforce. A lint rule, hook, test or CI check runs every time, no matter what. Now it is a law.
Most teams stop at stage two. The lesson sits in a markdown file, the agent follows it most of the time, and "most of the time" is exactly why you are still in the loop. Stage three is the one that lets you leave.
The same lesson at each stage
| Observed in review | Captured (suggestion) | Enforced (law) |
|---|---|---|
Agent leaves // TODO: handle errors and moves on |
CLAUDE.md: "No TODO comments. Finish it or open an issue." | ESLint no-warning-comments set to error, run in a hook and in CI |
Agent edits .env or the lockfile by hand |
CLAUDE.md: "Never edit .env or lockfiles directly." | PreToolUse hook that blocks Edit and Write on those paths |
| Agent says "done" while tests fail | CLAUDE.md: "Run the tests before finishing." | Stop hook that runs the suite and refuses the stop until it passes |
| Agent writes a second copy of a helper that already exists | CLAUDE.md: "Search for existing helpers first." | Duplicate detector (for example jscpd) in the Stop hook and CI |
Clean up your codebase and gather data
This is context engineering, and it comes before any prompt work. An agent reads your repository far more than it reads your instructions. Whatever is in the code is the example it copies.
Remove what you don't want copied
- Bad examples and workarounds. A hack you tolerated once becomes the house style after the agent sees it three times.
- Duplicated code, types and strings. If two versions of a type exist, the agent will pick one at random and may add a third.
- Layering violations. One UI component that imports the database client tells the agent that this is allowed.
- Magic numbers. Unnamed constants get copied as unnamed constants.
- Old comments. A stale comment is a false statement the agent treats as true.
- Bad engineering practice in general. The classics from The Pragmatic Programmer apply with more force now, because a broken window is no longer just demoralizing. It is training data.
Gather data on what the agent actually does
- Code review the early commits. The first few agent commits on a project show you which patterns it has locked onto. Fixing them on day two is cheap and fixing them at commit two hundred is not.
- Architecture review. Have a strong model describe the architecture it sees in the code, then compare that to the architecture you intended. The differences are your cleanup list.
- Root cause analysis for every known issue. Run it with several models on high effort and have one agent consolidate. The full recipe is under Useful workflows and hacks, near the end.
- Fuzz your code. Fuzzing throws unexpected and malformed input at your code and finds the crashes. It finds the holes your tests miss, because your tests only cover the cases you thought of.
Make each learning deterministic
Everything you found above should end up in one of three places.
Linter rules. Anything you can describe as a pattern in the source: leftover TODOs, commented-out code, banned imports across layers, magic numbers. This excerpt is from an eslint.config.js:
rules: {
"no-warning-comments": ["error", { terms: ["todo", "fixme", "hack"] }],
"no-magic-numbers": ["error", { ignore: [0, 1] }],
"no-restricted-imports": ["error", {
patterns: [{ group: ["**/db/*"], message: "UI code may not import the database layer." }]
}]
}
Hooks. Anything you want checked after every agent run, such as DRY violations, formatting, or the test suite. The lint rules above only become laws when a hook or CI runs them every time. The harness section below shows how.
Scheduled tasks. Anything that should improve the system while you are not looking:
- Summarize repeated prompts. A weekly job reads your session transcripts, finds instructions you typed more than once ("use pnpm", "don't mock the database"), and proposes them as CLAUDE.md lines, lint rules or hooks.
- Weekly PRs on your marketplace plugin. The same job opens a pull request against the plugin that holds your shared skills, hooks and subagents. You review one PR a week and every machine and teammate gets the lesson. This is the self-learning loop.
Prompt engineering
Make intent explicit
Say what you want, why you want it, where the work stops, and how you will know it is done. Current models follow instructions closely, which means a vague prompt gets a literal, minimal answer.
| Vague | Explicit |
|---|---|
| "Fix the login bug." | "Users with a plus sign in their email can't log in (issue #212). Find the root cause before changing anything. Fix it in the validation layer, not the UI. Add a failing test first. Done means the new test and the existing suite pass. Don't touch the session code." |
System prompts versus user prompts
- CLAUDE.md and AGENTS.md are not system prompts. Claude Code reads them at session start and delivers them as a user message right after the system prompt. They are context that sits alongside what you type. The model weighs them, and it can also drift from them in a long session.
- Enforce rules in hooks, not in CLAUDE.md. If breaking a rule is unacceptable, it does not belong in a file the model merely reads.
- A real system prompt lives in a subagent definition. The body of a subagent's markdown file becomes its system prompt. That is where you define who an agent is.
Prompt variables, conditions and loops
A reusable prompt is a small program. In Claude Code the unit is a skill: a folder with a SKILL.md whose frontmatter configures it and whose body is the prompt. You get variables ($ARGUMENTS, $0, $1), live context from shell commands, and conditions and loops written in plain language. This one lives at .claude/skills/fix-lint/SKILL.md:
---
name: fix-lint
description: Fix lint errors in a path until the linter is clean
argument-hint: <path>
allowed-tools: Read, Edit, Bash(npx eslint *)
---
Current lint output:
!`npx eslint $ARGUMENTS --format compact || true`
If there are no errors, say so and stop.
Otherwise, loop:
1. Fix the first file's errors.
2. Re-run `npx eslint $ARGUMENTS`.
3. Repeat until the output is clean or you have made 5 passes.
If errors remain after 5 passes, list them and stop. Do not disable rules.
Workflows and frontmatter
Frontmatter is the YAML block at the top of a skill or subagent file. It is where the deterministic settings go: which tools are allowed, which model and effort to use, whether to run in an isolated context, which hooks apply. The prose below it is the suggestion and the frontmatter is closer to law.
When the plan itself needs to be deterministic, Claude Code has dynamic workflows: Claude writes a JavaScript script that fans work out to subagents, the runtime executes it, and intermediate results stay in script variables instead of filling a context window. You can read the script, rerun it and save it as a command.
Higher order and lower order prompts
A lower order prompt does one concrete job. A higher order prompt takes another prompt as its input and decides how, when or how often to run it.
A lower order prompt:
Fuzz the parser in src/parser/ for 10 minutes with cargo-fuzz.
For each crash, save the input to fuzz/crashes/ and write a
failing test that reproduces it. Don't fix anything.
A higher order prompt:
Run this task: {{task_prompt}}
Run it in a fresh worktree on a new branch.
When it finishes, start a separate reviewer agent to check the
result against the task. If the reviewer fails it, retry once
with the reviewer's notes. Open a draft PR with the result and
the review.
Pass the fuzz prompt in as {{task_prompt}} and you get a fuzzing job. Pass in "update dependencies" or "fix lint errors" and the same wrapper runs those instead. You write the wrapper once and every task inherits the worktree, the reviewer, the retry and the PR.
{{task_prompt}} is template notation. In a Claude Code skill the same slot is written $ARGUMENTS, so the wrapper above becomes a skill you call as /run-reviewed fix lint errors in src/api.
Focused agents (defined subagents)
- System prompts define who they are. A subagent gets only its own system prompt plus basic environment details. It does not get the full Claude Code system prompt, and it does not see your conversation.
- Lead agents versus subagents. The lead holds the plan and talks to you. Subagents each do one job in a fresh context and return a result. The narrower the job, the better the result.
A skeptical reviewer, saved as .claude/agents/skeptic.md:
---
name: skeptic
description: Independent reviewer. Use after any implementation task to check the result against the original task.
tools: Read, Grep, Glob, Bash
model: opus
effort: high
---
You review work you did not write. Assume it is wrong until the
evidence says otherwise.
You are given the original task and a branch. Do not trust the
author's summary. Read the diff and run the checks yourself.
Score each line PASS or FAIL, with the evidence you saw:
1. Does the change do what the task asked, and nothing else?
2. Do the tests pass when YOU run them?
3. Is there a test that would fail without this change?
4. Any duplicated code, TODOs, or disabled checks?
If you could not verify a line, it is a FAIL.
End with one word on its own line: APPROVE or REJECT.
Models, effort and agents
Which Claude model does what
This is the split I use. Treat it as a starting point and adjust from your own results.
| Model | Use it for |
|---|---|
| Fable 5.2 | One-shot coder, designer and video editor. On larger tasks: planning, architecture, review, design and strategy. Also the long-running orchestrator, at medium or low effort. |
| Opus 5.5 | Primary coding agent in long-running tasks. |
| Sonnet 5.5 | Fast small code changes, chores, direct bug fixes. |
| Haiku 5.5 | Quick, well-defined tasks and basic explanation. |
Optional: an orchestrator that cannot write code
An orchestrator that can edit files will eventually "just fix it quickly" instead of delegating. You can take the option away so it plans, delegates and handles devops, and nothing else.
- Give the agent a
toolslist that leaves out Edit and Write, or - add
disallowedTools: Edit, Writeto inherit everything else, or - put deny rules for
EditandWriteunderpermissions.denyin settings.
Saved as .claude/agents/orchestrator.md:
---
name: orchestrator
description: Plans the work, delegates implementation, handles git and deploys. Never edits code.
tools: Read, Grep, Glob, Bash, Agent
model: fable
effort: medium
---
You are the lead. Break the task into pieces, hand each piece to
a builder subagent, and send every result to the skeptic before
you accept it. You do not write or edit source files yourself.
You may run git, gh and the deploy scripts.
Bash is a write tool. Removing Edit and Write does not stop echo ... > file or sed -i. If the orchestrator keeps Bash for devops, narrow it: allow only the commands it needs with permission rules, or add a PreToolUse hook on Bash that rejects anything outside your list. For a reviewer that needs no shell at all, tools: Read, Grep, Glob is the truly read-only set. In .claude/settings.json:
{
"permissions": {
"allow": ["Bash(git *)", "Bash(gh *)", "Bash(./scripts/deploy.sh *)"],
"deny": ["Edit", "Write"]
}
}
Effort
Effort is a separate dial from the model. It controls how much work Claude does overall: how long it thinks, how many files it reads, how much it verifies before answering. The levels are low, medium, high, xhigh and max, and you can set one per session or per subagent in frontmatter.
- Start from the model's default. Anthropic's own guidance is to treat effort as a general setting for your kind of work, not something to tune per task.
- If the agent had the right context, tried, and was still wrong, move up a model.
- If the agent skipped a file, didn't run the tests or gave up on a refactor, raise the effort.
- Orchestrators mostly route and wait, so medium or low effort is enough. Reviewers and root cause analysis earn high effort.
How many agents?
As few as the task needs. Each agent costs tokens and adds a handoff where information gets lost. Add an agent when there is a real reason:
- the work splits into independent pieces that can run in parallel,
- a job would flood the main context with output you only need a summary of, or
- you need an independent opinion, which means a reviewer that did not write the code.
What model does what: planner, builder, skeptical evaluator
The split that holds up is three roles. A planner turns a short request into a spec. A builder implements it. A separate, skeptical evaluator tests the running result against the spec. Anthropic's own long-running harness uses the same three roles, and the reason is practical: a standalone evaluator is far easier to make skeptical than a builder is to make self-critical.
How much context is copied?
| Named subagent | Fork | |
|---|---|---|
| Starts with | A fresh context: its system prompt, the task message the lead writes, CLAUDE.md, a git status snapshot | The entire conversation so far |
| System prompt, tools, model | From its definition file | Same as the main session |
| Sees your history? | No | Yes |
| Returns | Only its final result | Only its final result |
| Use when | The job is well defined and an unbiased view helps (review, research, a focused build) | The side task needs so much background that re-explaining it would cost more than copying it |
A named subagent only knows what the lead puts in the task message. Write that message as if you were briefing a contractor who has never seen the project, because that is the situation.
The harness: hooks as laws
The harness is everything around the model: Claude Code itself, its settings, permissions, hooks, skills and subagents. Hooks are the part that turns a lesson into a law. A hook is a command Claude Code runs at a fixed point in its lifecycle. The model does not choose whether it runs.
What can block and what can't
A hook blocks by exiting with code 2. What "block" means depends on the event.
| Event | Blocks? | What exit code 2 does |
|---|---|---|
PreToolUse |
Yes | Stops the tool call before it runs |
UserPromptSubmit |
Yes | Stops the prompt before it reaches Claude |
Stop |
Yes | Keeps the agent working instead of finishing |
SubagentStop |
Yes | Keeps the subagent working |
TaskCompleted |
Yes | Refuses to let the task be marked done |
TaskCreated |
Yes | Rolls the new task back |
TeammateIdle |
Yes | Keeps an agent-team teammate working |
PreCompact |
Yes | Stops compaction |
PostToolUse |
No | The tool already ran. The hook's message goes back to Claude as feedback. |
SessionStart |
No | Can only add context. Errors are shown to you, not acted on. |
Notification, SessionEnd |
No | Nothing is blocked |
Exit code 1 is not a block. It is the usual Unix failure code, and in a hook it means "non-blocking error": the action goes ahead. A hook that is supposed to enforce something must exit 2. Test every enforcing hook by making it fail once on purpose.
The stage example: no finishing until the tests pass
A Stop hook that runs your test suite is verification and enforcement in one small piece of config. In .claude/settings.json:
{
"hooks": {
"Stop": [
{
"hooks": [
{ "type": "command", "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/tests-must-pass.sh" }
]
}
]
}
}
And the script, .claude/hooks/tests-must-pass.sh:
#!/bin/bash
# Stop fires every time Claude finishes a response, so skip when nothing changed.
[ -z "$(git status --porcelain)" ] && exit 0
if ! OUTPUT=$(npm test 2>&1); then
echo "Tests are failing. Fix them before you finish:" >&2
echo "$OUTPUT" | tail -n 40 >&2
exit 2 # refuse the stop; stderr goes back to Claude
fi
exit 0
Two things to know before you rely on it:
- Loop protection. Claude Code overrides a Stop hook after it blocks eight times in a row with no tool call in between. The hook input also carries a
stop_hook_activeflag that is true when the agent is already continuing because of a Stop hook. Exiting early on that flag is the documented way to avoid loops, but it also lets the agent stop on its second try, so leave it out of a strict gate like this one. - Stop does not fire when you interrupt. It is a gate on the agent finishing, not on you pressing Escape.
Feedback hooks: lint after every edit
PostToolUse can't undo an edit, but it can tell Claude about the problem within the same turn, which is usually what you want for lint. Register this script on PostToolUse with the matcher Edit, Write:
#!/bin/bash
FILE=$(jq -r '.tool_input.file_path // empty')
case "$FILE" in *.ts|*.tsx|*.js) ;; *) exit 0 ;; esac
if ! OUT=$(npx eslint "$FILE" 2>&1); then
echo "$OUT" >&2
exit 2 # can't block, but Claude sees the lint errors and fixes them
fi
Hooks that use judgment
Most hooks are shell commands. Claude Code also has prompt hooks, which ask a model a single yes or no question, and agent hooks, which start a subagent that can read files and run commands before deciding. Use those for checks you can't express as a script, such as "does this change duplicate an existing helper?" Agent hooks are still marked experimental, so prefer a command hook where one will do.
Where hooks live
User settings apply to all your projects. Project settings in .claude/settings.json are committed and shared. A plugin can ship hooks to every machine that installs it. Skill and subagent frontmatter can scope a hook to just that skill or agent.
Long-running agents
A context window is finite and a long task is not. Two mechanisms carry the work across that gap.
- Compaction. As the window fills, auto-compaction summarizes the conversation so it can continue. Compaction keeps the conversation going, but details get lost in the summary.
- Handoff. Notes on disk are what let a fresh agent pick up the work. Your handoff and progress files are how you keep state across compaction, across sessions and across agents.
Treat the progress file as the source of truth and the conversation as disposable. If the session died right now, a new agent should be able to read one file and continue. A PROGRESS.md can be this small:
# Goal
Migrate the billing service from REST to gRPC without changing behavior.
# Done
- [x] Proto definitions for Invoice and Payment (commit 4e1a9c2)
- [x] Server stubs generated, wired into main.go
# In progress
- [ ] Port InvoiceService.List (handler done, pagination test failing)
# Next
- [ ] Port PaymentService
- [ ] Remove REST routes behind the feature flag
# Decisions
- Keep REST and gRPC side by side until parity tests pass. Do not delete REST early.
# Gotchas
- Integration tests need `make db-up` first.
# How to verify
make test && make parity
Then make the harness reload it. A SessionStart hook with the compact matcher runs after every compaction, and whatever it prints is added to Claude's context.
{
"hooks": {
"SessionStart": [
{
"matcher": "compact",
"hooks": [
{ "type": "command", "command": "cat \"$CLAUDE_PROJECT_DIR\"/PROGRESS.md" }
]
}
]
}
}
Add one line to the task prompt as well: "Update PROGRESS.md after each completed step, before you start the next one."
Verification: what earns you the right to leave
You can leave the loop when something other than you is checking the work, and you have evidence that the check is reliable. Build it in layers.
Use adversarial evaluators
Agents skew confident when they evaluate their own work. Anthropic's harness research found that agents praise their own output even when it is plainly mediocre, and that a reviewer left untuned will notice real problems and then talk itself into approving anyway. So the verifier is a different agent, with a different prompt, told to distrust the author. The skeptic subagent above is that agent.
Deterministic checks
Tests as the spec, types, lint, static analysis. They are fast, cheap and give the same answer every time. Anything that can be checked this way should be.
Model-based checks
A reviewer or evaluator agent scoring against a written rubric. "Is this good?" gets you a compliment, and "does it meet these four criteria, with evidence for each?" gets you a review. Calibrate the rubric by reading the evaluator's transcripts and tightening the prompt wherever its judgment differs from yours.
Human as the final check
This and spec writing are where being in the loop matters. You decide what gets built and you decide whether it ships. Everything between those two points is a candidate for automation.
Evals for agents
Anthropic's Demystifying evals for AI agents (January 2026) makes two points that matter here.
"It worked once" isn't trust. There are two ways to count success over k tries. pass@k is at least one success in k tries. pass^k is success on all k tries. An agent that succeeds 75% of the time passes three in a row only about 42% of the time. Leaving the loop needs pass^k, because you won't be there to pick the good run.
| Success per try | 3 in a row | 5 in a row |
|---|---|---|
| 75% | 42% | 24% |
| 90% | 73% | 59% |
| 95% | 86% | 77% |
| 99% | 97% | 95% |
Your bug backlog is your eval set. Start with 20 to 50 tasks drawn from real failures: bugs from your tracker, the manual checks you run before a release. Each one becomes a task with a clear pass or fail. Run each task several times and track the pass^k number over time.
The grader itself can be the bug. In one case from the same post, a model scored 42% on a benchmark and 95% after the evaluation was repaired. The fixes covered over-strict grading that rejected valid answers, ambiguous task specs, tasks that couldn't be reproduced, and a less constrained scaffold. Read the transcripts before you believe a score, high or low.
A few more rules from that post worth keeping:
- Prefer deterministic graders, and use model graders where you must.
- Grade the outcome, not the exact steps the agent took to get there.
- Give each trial a clean, isolated environment so runs don't contaminate each other.
- Keep two suites. Capability evals start with a low pass rate and show you what to improve. Regression evals should sit near 100% and tell you when something broke.
Workflow patterns
The first five come from Anthropic's Building effective agents. The last three are what the community and the tooling have added since. The advice from that post still stands: start with the simplest thing that works and add structure only when it measurably helps.
| Pattern | What it is | Example |
|---|---|---|
| Prompt chaining | A fixed sequence of steps where each one works on the last one's output, with checks in between | Plan, then implement, then write tests, with a lint gate between steps |
| Routing | Classify the input and send it to a specialized prompt or model | Issue triage into chore, plan, feature or debug. Simple work to Sonnet, hard work to Opus. |
| Parallelization | Run calls at the same time and combine the results, by splitting the work or by voting | Three models review the same diff independently |
| Orchestrator-workers | A lead breaks the task down at run time, delegates and combines | A refactor across an unknown number of files |
| Evaluator-optimizer | One agent produces, another evaluates, repeat until it passes | Builder and skeptic, looping until APPROVE |
| Loops (Ralph and others) | The same prompt fed to a fresh agent again and again. State lives in files and git, not in the conversation. | while :; do claude -p "$(cat PROMPT.md)"; done in a sandbox, with PROGRESS.md as memory |
| Swarms and message boards | Many peer agents coordinating through a shared task list or board instead of a single lead's context | Claude Code agent teams, where teammates claim tasks from a shared list |
| Scheduled task agents | An agent that runs on a timer or an event with no one watching | Nightly dependency updates, weekly learning PR |
Tools
- Databases, files, RAG, Graph RAG. These are the agent's memory. Plain files are the simplest and often enough. A database gives you structured, queryable state. RAG retrieves relevant passages from a large corpus. Graph RAG adds the relationships between things, which helps when the answer depends on how parts connect.
- Skills. Folders of instructions and code that Claude loads when relevant. Only the name and description sit in context until the skill is used.
- Marketplace plugins. A plugin bundles skills, hooks, subagents and MCP servers into one unit. A marketplace is a catalog, usually a git repository, that distributes them. This is how a lesson learned on one machine reaches every machine.
- GitHub Actions. Run agents in CI on pull request and issue events, with the same checks your human contributors face.
- Cloudflare tunnels and webhooks. A tunnel gives a local machine a public URL, so a webhook from GitHub or anywhere else can start an agent on your own hardware.
- Discord bots. A chat front end for your agents: start a job from your phone, get the result and the PR link back in a channel.
- MCP and CLIs. MCP servers give the agent typed tools for external systems. A CLI the agent already knows, such as
gh, often does the same job through Bash with less context spent on tool definitions. Use whichever is simpler for the task.
Scheduling options in Claude Code
| Option | Runs on | Good for |
|---|---|---|
| Cloud scheduled tasks (formerly routines) | Anthropic's cloud, on a schedule, an API call or a GitHub event | Unattended work that must run with your laptop closed |
| Desktop scheduled tasks | Your machine | Jobs that need local files and tools |
/loop |
The current session | Quick polling while you work |
Automated bug fixing
This is where the pieces come together: harness engineering around your own codebase.
The three systems you build
- Memory systems. CLAUDE.md, progress files, and a place where lessons accumulate between sessions.
- Eval systems. The bug backlog as a regression suite, run on every change to the harness itself.
- Self-learning scheduled loops. The weekly job that turns repeated corrections into proposed rules.
Deterministic triage
Every incoming issue is filed as one of four types, and code picks the route. The model does not decide which process applies to it.
| Type | What it means | Route |
|---|---|---|
| Chore | Mechanical, no design decision | Small model, one pass, straight to PR |
| Plan | Needs a decision before any code | Planner writes a spec, a human approves it, no code yet |
| Feature | New behavior with an approved spec | Planner, builder, skeptic |
| Debug | Something is broken | Reproduce with a failing test, find the root cause, fix, skeptic |
A triage.sh where the label picks the prompt:
#!/bin/bash
ISSUE=$1
LABEL=$(gh issue view "$ISSUE" --json labels -q '.labels[].name' | grep -E '^(chore|plan|feature|debug)$' | head -n 1)
case "$LABEL" in
chore|plan|feature|debug) PROMPT=".claude/prompts/$LABEL.md" ;;
*) gh issue comment "$ISSUE" --body "Needs a type label: chore, plan, feature or debug."; exit 0 ;;
esac
claude -p "$(cat "$PROMPT")
Issue number: $ISSUE"
The entire learning loop, end to end
- An issue arrives and triage files it as a chore, plan, feature or debug.
- The matching prompt runs in a fresh worktree on a new branch.
- The builder works. Hooks lint every edit and block protected files.
- The Stop hook refuses to let it finish until the tests pass.
- The skeptic reviews the branch against the original issue. A rejection goes back to the builder with notes.
- A draft PR opens with the change and the review attached.
- You make the final check. This is the one step that is yours.
- Anything you had to correct becomes a lesson: observed, captured, enforced.
- The bug itself joins the eval set, so the harness is tested against it from now on.
- The weekly scheduled job collects what was learned and opens a PR on the shared plugin.
Each time around, there is one less reason to step in.
Useful workflows and hacks
Multi-model root cause analysis
Different models miss different things, so run the analysis with more than one and then consolidate.
- List every known issue.
- Run one architecture and code review agent on each of three models: Claude Opus, Claude Fable, and OpenAI's GPT-6 Astra (through Codex). Use high effort, scaled to the size of the codebase.
- Each one works independently and reports root causes, not symptoms.
- One final Fable agent consolidates the three reports, removes duplicates, and ranks the findings by effort, cost, number of tasks and difficulty.
For each issue in ISSUES.md, find the root cause. Do not fix anything.
Trace the failure to the earliest point where the code does the wrong thing.
For each issue report: the root cause, the evidence (file and line), any other
issues that share this cause, and the architectural weakness that allowed it.
Findings that two or three models agree on go to the top of the list. A finding only one model reports is worth a second look before you act on it.
Checklist
- Bad examples, duplicates, stale comments and workarounds are out of the codebase.
- Early agent commits have been reviewed for the patterns they follow.
- Every repeated correction has moved from a prompt into a lint rule, hook, test or CI check.
- CLAUDE.md holds context and preferences. Nothing in it is load-bearing.
- Enforcing hooks exit with code 2, and each one has been seen to fail on purpose.
- A Stop hook runs the tests.
- Long tasks keep a progress file that a fresh agent could resume from.
- A separate, skeptical agent reviews against a written rubric.
- The bug backlog is an eval set of 20 to 50 tasks, and you track pass^k, not single runs.
- A scheduled job proposes new rules every week.
- You still write the spec and make the final call.
Sources and further reading
- Demystifying evals for AI agents, Anthropic, January 2026
- Harness design for long-running application development, Anthropic, March 2026
- Building effective agents, Anthropic, December 2024
- Claude Code hooks reference and hooks guide
- Claude Code subagents
- Claude Code skills
- Claude Code dynamic workflows
- Claude Code plugins and marketplaces
- Claude Code scheduled tasks
- Give Claude context: CLAUDE.md and better prompts, Claude Help Center
- Choosing a Claude model and effort level in Claude Code, Anthropic, July 2026
Get in touch
Run this with your team.
Get Out the Loop is also a workshop: we work through it in your own repository, on the corrections your team keeps repeating.