# Claude Code best practices I use, from one session to a fleet

> Claude Code best practices from measured sessions: concise instructions, explicit checks, scoped subagents, context hygiene, and independent verification.

- Canonical: https://jedarden.com/guides/claude-code-best-practices/
- Published: 2026-10-26
- Updated: 2026-11-30
- Last verified: November 30, 2026 (2026-11-30)
- Tags: claude-code, ai-coding-agents, best-practices, agent-fleets

---

**A Claude Code session says the change is finished. There is a commit. The
test it ran passed. Then I open the page and the control does nothing.** A
commit proves that something changed; it takes a check of the requested
behavior to establish that the work is done.

That distinction is the center of my Claude Code best practices. I use them
while steering one session and while running about twenty headless workers:
give the agent the information it cannot discover, define the result, limit
the scope, and verify what actually shipped.

> The useful prompt is a small contract: what should change, what must stay
> true, and how we will know it worked.

Start with these six habits:

- **Write the outcome and a check.** Include an example the result must handle.
- **Keep standing instructions short.** Record the commands and constraints
  Claude cannot infer from the code.
- **Enforce hard boundaries with tools.** Instructions alone are fallible.
- **Keep one task's context together.** Save a handoff before changing topics.
- **Delegate a bounded packet.** Name the question, authority, and return format.
- **Review the result independently.** Inspect the diff and exercise the behavior.

The exhibits below come from my September 23–October 31, 2026 transcript
study: 13,763 files across 325 project directories. This is one operator's
workload, including Claude Code used with GLM as well as Anthropic models.
It is observational evidence, not a controlled model benchmark. The advice
and vendor documentation were rechecked November 30, 2026; my installed
Claude Code is **2.1.332**. Historical measurements have not been relabeled
as measurements of that version.

## 1. Give Claude a result it can check

"Fix the settings page" leaves most of the decision to the agent. I get a
better result by specifying the failure, the expected behavior, and the
verification:

> Saving an empty display name currently succeeds. Reject it, keep the
> previous value, and show an error beside the field. Check the empty case,
> a valid save, and keyboard submission. Keep the existing settings layout.

For an established codebase, I ask Claude to read the relevant implementation
and existing tests before proposing a change. For a larger change, I want a
brief plan with the unresolved decisions made explicit. For a small defect,
that can be a paragraph. A new project needs more discovery. I no longer
treat a documentation scaffold or two formal review rounds as a prerequisite
for every edit.

My fleet task descriptions usually fit under about 3,000 characters with
fewer than eight acceptance checks. Those are editing heuristics, not
measured reliability thresholds. Keep implementation, necessary tests,
documentation, and delivery under the same outcome owner. Split work when
it has an independent result or a dependency another worker must satisfy.

Anthropic's current [best-practices guide](https://code.claude.com/docs/en/best-practices)
likewise emphasizes supplying missing project knowledge and giving Claude a
check to run. I add the concrete example because it makes a passing check
harder to confuse with a useful result.

## 2. Keep CLAUDE.md short, and check what loaded

I put durable project knowledge in the instructions file: the exact build
and test commands, deployment constraints, conventions that differ from the
surrounding code, and what to do when blocked. The current task belongs in
the task description; long research belongs in a separate document the task
can reference. Every standing paragraph competes with the work for attention.

Use `CLAUDE.md` for Claude-specific instructions. Current Claude Code also
supports `AGENTS.md` directly, with conditions: support requires v2.1.277
or later, and the default reads it only when no project `CLAUDE.md` or
`CLAUDE.local.md` is found in the working directory or above. The Project
instructions setting can load both. An `@AGENTS.md` import in `CLAUDE.md`
remains an option. Check the [memory documentation](https://code.claude.com/docs/en/memory)
for the version and loading rules; run `/context all` to see the loaded
memory files rather than assuming the filename was enough.

Repeated context showed up clearly in my study. The Anthropic interactive
cohort's cache-read share was 98.0%; the GLM headless cohort's was 90.8%.

<div data-ccbest-exhibit="cache">

| Cohort | Sessions | Cache-read share |
| --- | ---: | ---: |
| Anthropic / interactive | 792 | 98.0% |
| GLM / headless fleet | 8,340 | 90.8% |

</div>

Here, cache share means cache reads divided by uncached input plus cache
creation plus cache reads; output is excluded. It is **not a percentage of
money saved**. The providers account for cache creation differently, and
model and task mix differ between cohorts. Cached context still occupies
the context window. These numbers give me a reason to trim standing
instructions, not proof that trimming them causes better results.

## 3. Separate instructions, settings, and enforcement

Writing "never" makes a constraint clearer. It does not make compliance
deterministic. I use prose to explain the intent and a permission boundary,
hook, or external gate when an exception would be unacceptable.

| Need | Where I put it |
| --- | --- |
| Project knowledge and conventions | `CLAUDE.md`, or supported shared instructions |
| Team Claude Code configuration | `.claude/settings.json`, committed |
| My project-specific overrides | `.claude/settings.local.json`, untracked |
| My defaults across projects | `~/.claude/settings.json` |
| Organization-enforced policy | Managed settings |

The [settings documentation](https://code.claude.com/docs/en/settings) gives
the precedence: managed settings, command-line `--settings`, project local,
shared project, then user settings. Permission lists combine across sources;
do not assume a local list erases a shared rule. Environment variables have
per-setting behavior rather than a single position in that stack. I use
`/status` to inspect sources and `claude doctor` when configuration behaves
unexpectedly. In headless runs, check stderr too: invalid settings can be
skipped while the run continues.

My study recorded **174,653 tool calls; 78.6% were Bash**. That tells me to
pay attention to shell permissions and the commands a task can launch.

<div data-ccbest-exhibit="tools">

| Cohort | Tool | Share of tool calls |
| --- | --- | ---: |
| Interactive main | Bash | 82.1% |
| Interactive main | Read | 6.4% |
| Interactive main | Edit | 5.8% |
| Interactive main | Write | 1.8% |
| Interactive main | Grep / Glob | 0.0% |
| Interactive main | Agent | 0.8% |
| Interactive main | WebSearch / WebFetch | 1.0% |
| Interactive main | Other | 2.2% |
| Headless main | Bash | 76.5% |
| Headless main | Read | 15.9% |
| Headless main | Edit | 3.6% |
| Headless main | Write | 1.0% |
| Headless main | Grep / Glob | 0.0% |
| Headless main | Agent | 0.2% |
| Headless main | WebSearch / WebFetch | 0.1% |
| Headless main | Other | 2.8% |

</div>

That is a call count, not elapsed time or risk weighting. A read-only command
and a destructive command both count as one call. I inspect `/permissions`
and grant the commands a workflow actually needs. Anthropic documents
[permission rules and sandboxing](https://code.claude.com/docs/en/permissions)
as separate controls; a file-read rule should not be mistaken for protection
against every possible shell command.

A command-based `Stop` hook can run a required check and block ordinary
completion when it fails. It still needs testing for the intended failure
case and a bounded escape from repeated failures. The [hooks reference](https://code.claude.com/docs/en/hooks)
documents event-specific behavior, including that `Stop` does not run for
a user interrupt. I keep the release gate outside the editing session as well.

## 4. Save decisions before context becomes a problem

I keep a compact handoff with the outcome, decisions already made, changed
files, checks actually run, and the next action. That lets a fresh session
resume without reconstructing the whole conversation or asking settled
questions again.

Only 46 of 792 interactive sessions had a continuation marker in this study.
Most sessions were short; compaction was the exception.

<div data-ccbest-exhibit="compaction">

| Cohort | Sessions with compaction | Share |
| --- | ---: | ---: |
| Interactive | 46 of 792 | 5.8% |
| Headless | 30 of 8,354 | 0.4% |

</div>

Among sessions that compacted, the median first compaction arrived after
nine human turns for interactive work and one for headless work. Median
cumulative tokens before first compaction were 16.8 million and 8.8 million,
respectively; median live context at compaction was 303,261 and 167,506.
These are different quantities: repeated cached reads can push cumulative
usage into millions without millions fitting in one context window.

Those historical medians mix models and workloads; **they are not Claude
Code compaction thresholds**. I use `/clear` between unrelated tasks after
saving the handoff. In a long task, `/compact` can name what to preserve:
the decision, the outstanding failure, and the verification commands.
Anthropic's [context and cost advice](https://code.claude.com/docs/en/best-practices#keep-cost-and-context-down)
also warns that compaction itself processes the conversation. I do not
compact after a fixed number of turns or treat it as free housekeeping.

## 5. Give subagents a bounded packet

A subagent is useful when it can answer a question or own a distinct result
without competing for the same edits. My packet names the objective, input
material, write scope, authority, check, and return format. A read-only
investigation returns its finding and the evidence location; implementation
returns the result, verification, and remaining work.

<div data-ccbest-exhibit="subagents">

| Cohort | Subagent share of all tokens | Subagent share of output tokens |
| --- | ---: | ---: |
| All | 34.4% | 4.0% |
| Interactive | 48.1% | 14.4% |
| Headless | 0.7% | 0.4% |

</div>

My corpus had 506 subagent transcript files. Their share of all tokens,
including cache reads, was much larger than their share of output. That
does not establish waste: reading, checking, and discarded approaches can
be useful work. It does mean delegation has a budget, especially when
several workers load similar context. Token share does not equal bill share.

Anthropic's [subagent documentation](https://code.claude.com/docs/en/sub-agents)
describes separate context windows, scoped tools, and model selection. I
use that separation for noisy searches or independent checks, and keep
tightly dependent edits together. Asking a child to reproduce the parent's
entire reasoning usually gives me two large contexts and one outcome.

## 6. Verify the behavior, then the delivery

I ask the agent to check its work while implementing. Then I inspect what
the check proves. Did it exercise the failure in the prompt? Did it run
against the code being delivered? Could an empty result pass? For a UI, I
want the interaction performed in a browser. For a migration, I want evidence
against representative data and a recovery path.

My completion record includes the revision, actual commands and exit status,
the behavior observed, and any skipped checks. A new commit is useful
delivery evidence, but it cannot replace those checks. A new commit containing
only a log or a test that mirrors a mistake is still a new commit.

For a fleet, the same rule becomes a gate owned by the orchestrator. My
October 31 fleet study used the adapter that actually executed each attempt,
because worker names misattributed 27.7% of attempts. It recorded 18,341
attempts overall. Those counts are not an Anthropic-model success rate:
only 91 attempts used the Anthropic-backed Claude Code adapter. Most of my
Anthropic usage was interactive. See the
[measured harness comparison](/guides/codex-vs-claude-code/) for the workload
boundaries before comparing yields.

## When one session becomes several workers

The six habits above apply without a queue or an orchestrator. The moment
I add a second worker, I also need exclusive task ownership, dependencies
for overlapping changes, and a retry budget.

- **Claim atomically.** Selecting a task and marking it claimed must be one
  exclusive operation. A list-then-update sequence can assign it twice.
- **Serialize overlapping work.** Different task IDs do not protect a shared
  function or file. Name the write scope and relate conflicting tasks.
- **Count attempts and delivered outcomes separately.** Repeated retries
  are expenditure, not progress. Decide when to stop and escalate in advance.
- **Check resources before blaming the model.** Memory pressure, a missing
  command, a network failure, and an empty ready query need different fixes.

I route routine, bounded work to a cheaper model when the outcome checks
support it, and escalate difficult work or a failed attempt. That is an
operating choice, not evidence that one model is universally sufficient.
The [workflow manual](/guides/workflow/) develops the planning and queue
practices; [agent orchestration](/guides/agent-orchestration/) covers the
control loop and failure boundaries.

## Score your next session

Tick a practice only when you can point to its evidence in the task you are
doing now. This checklist is a reminder, not a validated maturity score.
Pick one unchecked practice to add before your next session.

<div data-ccbest-exhibit="checklist">

| Practice | Evidence to look for |
| --- | --- |
| Define the outcome | An expected result and a check that can fail |
| Keep instructions concise | Current commands and non-obvious constraints |
| Enforce hard boundaries | A tested permission, hook, or external gate |
| Save a handoff | Decisions, checks, remaining work, next action |
| Bound delegation | A question or result, scope, budget, and return format |
| Verify independently | Diff review, behavior exercised, revision recorded |

Score one point per evidenced practice, from 0 to 6. No JavaScript is needed
to use this table as a checklist.

</div>

## What I would adopt first

For one session, start with the outcome and its failing example, keep the
instructions short, and inspect the delivered behavior. Add context handoffs
when a task spans sessions and bounded delegation when there is an independent
packet worth handing off. Build atomic claims when there is a second worker
to contend with the first.

The tracker and orchestrator I use are mine. Their behavior explains some
of these practices; it is not a requirement to adopt them. The transferable
part is a clear outcome, evidence of completion, and a bounded way to recover
when the agent is wrong.

For more detail: [the workflow manual](/guides/workflow/),
[independent verification](/notes/dont-let-the-agent-grade-its-own-homework/),
and [what breaks at twenty agents](/notes/what-breaks-at-twenty-agents/).