Claude Code: Expert
At the expert level the goal is no longer one good session: it is many loops running at once, some without you watching. The mechanics are the same as ever: gather context, act, verify, repeat. What changes is that you take yourself out of the loop in places, which makes verification non-negotiable rather than optional. Everything here is the loop run wide.
Run without a session: headless
Section titled “Run without a session: headless”claude -p "prompt" runs non-interactively (no chat UI, no saved session) for CI, pre-commit hooks, and scripts. It returns a result and exits.
claude -p "Run the test suite and summarize any failures." --output-format jsonOutput formats are text (default), json, and stream-json (add --verbose to stream). Because no human is in a headless run to catch “looks done” being wrong, the verification gate from the Advanced guide stops being a nicety and becomes the contract.
A concrete gate you can install today: a pre-commit hook that has Claude review the staged diff before the commit lands.
#!/bin/shverdict=$(git diff --cached | claude -p "Review this diff for bugs, leaked secrets, and leftover debug code. Reply with PASS, or FAIL followed by one line per finding.")echo "$verdict"case "$verdict" in FAIL*) exit 1 ;; esacNote where the exit code comes from: your script parses the verdict. claude -p exits non-zero on errors, not on findings. The same invocation drops into a CI step unchanged; add --allowedTools "Bash(git diff *)" when the prompt needs Claude to run commands instead of reading piped input.
Parallel sessions without collisions
Section titled “Parallel sessions without collisions”To run several Claudes at once, give each one its own ground so their edits don’t clash:
- Git worktrees. Isolated checkouts of the same repo: each session edits its own working tree.
- Agent teams. Coordinated sessions that share a task list and a team lead.
Fan out across many files
Section titled “Fan out across many files”To apply one change across a codebase:
- Have Claude list the files that need to change.
- Loop
claude -pover them, scoping permissions per run with--allowedTools. - Pipe results into your own pipeline:
claude -p "..." | your_command.
Autonomy with a safety net
Section titled “Autonomy with a safety net”Auto mode runs uninterrupted with background safety checks that block risky actions (scope escalation, unknown infrastructure, actions driven by hostile content):
claude --permission-mode auto -p "Fix all lint errors."In -p mode there is no human to fall back on, so the run aborts if the classifier keeps blocking. Auto mode is gated: it joins the permission cycle only when your account and model qualify and you opt in. As of mid-2026 the gating criteria are still shifting, so treat its availability as something to confirm in the current docs, not assume.
Adversarial review before “done”
Section titled “Adversarial review before “done””Before calling work done, hand the diff to a fresh model that sees only the diff and your criteria, and ask it to find what is wrong. The bundled /code-review skill reviews the current diff. Tell it to report gaps that affect correctness, not style: a reviewer told to find anything finds nits; one told to find correctness gaps finds bugs.
Dynamic workflows you can re-run
Section titled “Dynamic workflows you can re-run”The top of the verification ladder is a script Claude writes that orchestrates many subagents (codebase audits, large migrations, cross-checked research), including verification subagents whose job is to refute the findings. Because it is a script, the audit you run today is the audit you can run again next month, the same way every time.
The window is still the budget
Section titled “The window is still the budget”Going wide does not repeal the master constraint: it multiplies it. Each session, each subagent, each headless run has its own context window, and the same discipline applies to all of them: hand over precise context, isolate heavy reading in subagents, keep durable rules in CLAUDE.md so they survive compaction, and never ship work you cannot verify. Orchestration only pays off when each loop underneath it is clean. AI is an accelerator with no opinion about direction; context is the steering, and at scale you are steering many at once.
You’re done when…
Section titled “You’re done when…”- ✅ You’ve run a real task headless with
claude -pand a verification check - ✅ You’ve run two or more sessions in parallel via worktrees or an agent team
- ✅ You’ve piloted a fan-out prompt on a few files before scaling it
- ✅ An adversarial review or verification subagent grades work before you call it done
Next step
Section titled “Next step”You’ve reached the top of the Claude Code track. The same engine (the agentic loop, the context window, verification) sits under every tool in these docs.