Updated
Commands, context behavior, memory files, checkpoints, subagents, permissions, hooks and non-interactive execution were checked against current first-party Claude Code documentation on October 1, 2026.
Tested with
Claude Code documentation · TACL 2024 long-context study · ICLR 2024 SWE-bench paper
Claude Code can inspect a repository, edit files and execute tools. That makes it more useful than a completion system and more consequential than a chat interface. The central question is therefore not whether the model can produce plausible code. It is whether a human–agent workflow can make the resulting change bounded, testable, reviewable and recoverable.
The rules below are operational controls, not guarantees of correctness. Most come from Anthropic's first-party documentation. Two independent research results provide useful background: long-context models can underuse information depending on where it appears, and repository-level issue resolution is evaluated by applying patches and running tests rather than by judging prose. Neither result, by itself, proves that a particular Claude Code workflow is optimal.
This article distinguishes three kinds of statement:
| Evidence class | What it supports | What it does not support |
|---|---|---|
| Current Claude Code documentation | Product behavior, commands and recommended workflows | Independent estimates of productivity or defect reduction |
| Peer-reviewed experiments | Findings under a published dataset and evaluation protocol | Universal claims about every model, repository or future release |
| Engineering recommendation | A reproducible way to reduce operational risk | A vendor-independent law or guaranteed outcome |
The phrase survival rule is deliberately practical. It means a control that limits the cost of a predictable failure mode: misunderstood scope, irrelevant context, unverifiable output, excessive authority or unsafe automation.
An agentic coding session can be represented as a feedback system:
- A user specifies an objective, constraints and an acceptable result.
- The agent observes repository state through files, search and commands.
- It selects an action under the available tool permissions.
- The environment returns evidence: diffs, diagnostics, tests or rendered output.
- The agent or reviewer compares that evidence with the acceptance criteria.
Failure can enter at every stage. A vague objective produces the wrong target. Incomplete observation produces a locally plausible patch. Broad permissions increase the effect of a mistaken action. Weak verification allows an incorrect change to appear complete.

Claude Code's official best-practices guide recommends giving the agent a check it can run: tests, a build, a linter, a fixture comparison or a screenshot. This is stronger than asking the agent to “make it work,” because it turns completion into an observable condition.
A useful task specification contains four parts:
| Field | Example |
|---|---|
| Outcome | Session refresh succeeds after the access token expires |
| Scope | Authentication application service and its tests |
| Constraints | Preserve the public API; add no dependency |
| Evidence | Reproduction test fails before the patch and passes after it; full typecheck passes |
Tests are evidence, not proof. A passing suite establishes only that the tested properties held in that environment. For security-sensitive or user-facing work, combine automated checks with a diff review, threat-oriented reasoning or visual inspection.
Key takeaway
Ask for artifacts that can falsify success: a failing reproduction, a passing command, a rendered screenshot or a constrained diff. Confidence expressed in prose is not verification.

For unfamiliar or cross-cutting work, separate exploration from implementation:
- Observe. Identify entry points, dependencies, tests and repository constraints without editing.
- Plan. State the intended files, invariants, failure cases and verification commands.
- Mutate. Make the smallest coherent change that implements the plan.
- Evaluate. Run the specified checks, inspect the diff and account for failures.
Claude Code supports a plan permission mode that allows analysis without file changes. The documentation recommends planning when the approach is uncertain, the code is unfamiliar or several files are involved. It also warns that planning adds overhead; a typo or obvious one-line edit usually does not need a separate planning phase.
The important principle is not ritual. It is preventing an irreversible or wide-reaching action from occurring before the agent has enough evidence to select it.
Effective prompts name the target, the observed symptom, constraints and a verification method. They can also point to an existing implementation pattern. This reduces ambiguity without dictating an implementation that the repository may contradict.
Users are logged out when an access token expires even though the refresh token
is valid. Inspect the existing session flow before editing. Keep the public API
unchanged, add a regression test for this exact failure and run the auth tests
plus the typechecker. Do not change files outside src/auth without explaining why.This contract leaves room for investigation while constraining the observable result and blast radius. By contrast, “fix auth” underspecifies the outcome, while a long sequence of guessed code edits may overconstrain the solution.
Anthropic documents the context window as a principal operational constraint: conversation history, files and command output all consume it; Claude Code automatically compacts history near its limit; /clear starts fresh context; and /compact can guide summarisation.
Independent long-context research offers a narrower but relevant warning. Liu et al. found that several language models performed worse when relevant evidence appeared in the middle of long inputs. The experiments were retrieval and question-answering tasks, not Claude Code sessions, so they support caution about context utilisation rather than a precise threshold for coding quality.
Good context management follows from information value:
- Start a new session for an unrelated task.
- Prefer symbol search, focused file ranges and targeted test output over indiscriminate repository dumps.
- Keep the active objective, constraints, modified-file list and unresolved failures through compaction.
- Move verbose, independent investigation into an isolated subagent only when its summary will be sufficient.
- Avoid repeatedly injecting full logs when the relevant error and surrounding trace are enough.

Claude Code currently supports CLAUDE.md, AGENTS.md, path-scoped rules, skills and auto memory. These mechanisms do not have the same purpose.
| Mechanism | Appropriate content | Main risk |
|---|---|---|
CLAUDE.md or AGENTS.md | Commands, architecture invariants and rules needed in most sessions | Always-on context becomes noisy or contradictory |
| Path-scoped rules | Constraints that apply only to selected files | Incorrect patterns load rules in the wrong scope |
| Skills | Detailed domain knowledge or repeatable, on-demand workflows | Vague descriptions prevent appropriate activation |
| Auto memory | Learned preferences and repository observations | Stale or incorrect notes persist until reviewed |
| Hooks | Deterministic enforcement around tool events | Faulty automation blocks valid work or creates noisy output |
Anthropic explicitly describes memory files as context rather than enforced configuration. A statement such as “never edit .env” is advisory when written only in an instruction file. If the prohibition must hold, enforce it with permissions, sandbox policy or a PreToolUse hook.
The practical test for an always-loaded instruction is: would its absence predictably cause an expensive mistake in many sessions? If not, move it closer to the task or omit it.
A coding agent processes repository text, command output, issue descriptions and sometimes web content. Some of those inputs may be untrusted. Prompt injection is therefore an operational security problem, not merely a prompting problem.
Claude Code provides permission rules and optional filesystem/network sandboxing. The exact starting permission mode varies by configuration and product surface, so do not assume a universal default. Instead, inspect the active policy and apply least privilege:
- allow only the tools and paths required by the task;
- deny access to secrets and production credentials;
- isolate shell commands and network destinations where practical;
- review commands that upload, deploy, delete or mutate external state;
- use deterministic hooks for rules that must not depend on model judgment;
- never treat a successful build as a security review.
Permission is part of the experiment
A result produced with broad filesystem, network and deployment authority has a different risk profile from the same result produced in an isolated worktree or disposable container. Record the execution boundary along with the verification evidence.
Claude Code's current interface allows Esc to interrupt an action and Esc twice or /rewind to open the rewind menu. A checkpoint can restore conversation state, file edits or both, and can summarise part of the conversation.
The boundary matters: checkpoints track edits made through Claude's file-editing tools. Changes produced by shell commands or external processes are not necessarily captured. Checkpoint retention is also finite. Consequently, checkpoints are useful for local experimentation but are not a substitute for Git, backups or a clean worktree.
Before a risky experiment:
- inspect
git statusand separate unrelated changes; - record or commit a known-good state where appropriate;
- define the rollback target;
- stop and redirect as soon as the agent violates scope;
- re-check the working tree after any rewind.
Subagents have isolated contexts, configurable tools and independent permissions. They can prevent a high-volume investigation from filling the main conversation and can provide a fresh review. They also make additional model requests, consume usage limits and may lack conversational context that was not included in their prompt.
Use a subagent when the task is independently answerable and its output can be evaluated: locating an implementation path, comparing a diff with a written specification or reviewing for a named vulnerability class. Avoid delegation when the subtask depends on tacit product decisions, tightly coupled edits or continuous negotiation with the main task.
A useful delegation contract states:
- the question to answer;
- the files or evidence it may inspect;
- the tools it may use;
- the required output format;
- what it must not change;
- how the main agent will verify the result.
Fresh-context review can reduce commitment to the author's approach, but it is not automatically independent in the scientific sense: the reviewer may share the same model family, prompts or blind spots. Human review remains necessary where the consequence justifies it.
Non-interactive mode supports commands such as claude -p and structured output formats for scripts and CI. Parallel sessions can be isolated with Git worktrees so their edits do not collide. These features scale both useful work and failure.
Before automation, make the single-run protocol stable:
| Control | Question |
|---|---|
| Input pinning | Is the prompt, repository revision and configuration recorded? |
| Authority | Are allowed tools, paths, network access and credentials minimal? |
| Termination | Are turn, time and cost limits explicit? |
| Evaluation | Is success computed by tests or another observable criterion? |
| Isolation | Can concurrent runs overwrite the same files or state? |
| Recovery | Can a failed run be discarded without damaging the previous state? |
| Auditability | Are commands, diffs, outputs and final status retained? |
Do not place an open-ended coding prompt directly in a privileged CI environment. Start with a read-only or disposable environment, validate structured output, then widen authority only when the evidence supports it.
Productivity claims about coding agents are sensitive to task selection, repository state and verification strength. For team adoption, measure the workflow rather than relying on memorable demonstrations.
- Select a fixed set of representative tasks, including failures and small maintenance work.
- Record the repository commit, tool version, model selection, permissions and prompt.
- Define task-specific acceptance tests before the run.
- Repeat comparable tasks enough times to expose variance.
- Record success, human correction time, changed-file count, test regressions, elapsed time and usage cost.
- Inspect failed and apparently successful runs for untested behavior and scope expansion.
SWE-bench established the importance of repository-level evaluation by applying generated patches to real projects and executing issue-specific and regression tests. It does not measure every dimension of production engineering, including security, maintainability, product correctness or the cost of human supervision. Internal evaluation should therefore include those dimensions explicitly.
| Failure pattern | Observable symptom | Primary control |
|---|---|---|
| Scope drift | Unrelated files or behavior change | File boundary, diff review, stop early |
| Context pollution | Repeated contradictions or forgotten constraints | /clear, focused compaction, shorter evidence |
| Verification theatre | The agent says “done” without reproducible output | Predeclared commands and captured results |
| Instruction inflation | Important rules are buried in persistent context | Short core file, scoped rules and skills |
| Permission inflation | Convenience allowlists become broad authority | Least privilege, sandboxing and deny rules |
| Unsafe parallelism | Sessions overwrite or depend on one another | Worktrees, explicit ownership and integration order |
| Reviewer confirmation | A second agent repeats the author's assumptions | Independent criteria and adversarial test cases |
The durable pattern is straightforward: constrain what the agent is asked to do, constrain what it can do, and require evidence for what it claims to have done. The specific commands will evolve. Those controls remain useful because they address the structure of agentic work rather than the personality of one model release.
- Best practices for Claude Code — Anthropic's current workflow guidance and the primary source for verification, planning, context management and automation behavior.
- How Claude remembers your project — current behavior of
CLAUDE.md,AGENTS.md, scoped rules and auto memory. - Extend Claude Code — functional boundaries among memory files, skills, hooks, MCP and subagents.
- Checkpointing — checkpoint creation, restore options, retention and limitations.
- Create custom subagents — context isolation, permissions, usage and delegation behavior.
- Security — permissions, sandboxing, prompt-injection considerations and user responsibility.
- CLI reference — authoritative command and flag reference.
- Liu et al. (2024), Lost in the Middle: How Language Models Use Long Contexts, Transactions of the Association for Computational Linguistics, 12, 157–173.
- Jimenez et al. (2024), SWE-bench: Can Language Models Resolve Real-World GitHub Issues?, ICLR 2024.
