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

claude-codeai-coding-agentsbest-practicesagent-fleets

Last verified:

On this page
  1. 1. Give Claude a result it can check#
  2. 2. Keep CLAUDE.md short, and check what loaded#
  3. 3. Separate instructions, settings, and enforcement#
  4. 4. Save decisions before context becomes a problem#
  5. 5. Give subagents a bounded packet#
  6. 6. Verify the behavior, then the delivery#
  7. When one session becomes several workers#
  8. Score your next session#
  9. What I would adopt first#
For terminals & agents: curl -s https://jedarden.com/guides/claude-code-best-practices.md

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 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 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%.

CohortSessionsCache-read share
Anthropic / interactive79298.0%
GLM / headless fleet8,34090.8%

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.

NeedWhere I put it
Project knowledge and conventionsCLAUDE.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 policyManaged settings

The settings documentation 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.

CohortToolShare of tool calls
Interactive mainBash82.1%
Interactive mainRead6.4%
Interactive mainEdit5.8%
Interactive mainWrite1.8%
Interactive mainGrep / Glob0.0%
Interactive mainAgent0.8%
Interactive mainWebSearch / WebFetch1.0%
Interactive mainOther2.2%
Headless mainBash76.5%
Headless mainRead15.9%
Headless mainEdit3.6%
Headless mainWrite1.0%
Headless mainGrep / Glob0.0%
Headless mainAgent0.2%
Headless mainWebSearch / WebFetch0.1%
Headless mainOther2.8%

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 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 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.

CohortSessions with compactionShare
Interactive46 of 7925.8%
Headless30 of 8,3540.4%

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 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.

CohortSubagent share of all tokensSubagent share of output tokens
All34.4%4.0%
Interactive48.1%14.4%
Headless0.7%0.4%

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 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 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 develops the planning and queue practices; 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.

PracticeEvidence to look for
Define the outcomeAn expected result and a check that can fail
Keep instructions conciseCurrent commands and non-obvious constraints
Enforce hard boundariesA tested permission, hook, or external gate
Save a handoffDecisions, checks, remaining work, next action
Bound delegationA question or result, scope, budget, and return format
Verify independentlyDiff 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.

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, independent verification, and what breaks at twenty agents.