"We built Claude Code expecting sessions to last 30 seconds. Now engineers run it for days."
— Boris Cherny, Member of Technical Staff, Anthropic

Most teams are still using Claude Code like autocomplete with better manners. Type a prompt, accept a suggestion, feel vaguely productive. Meanwhile, a small cohort of engineers has figured out it's not a coding assistant — it's an agentic operating system for your entire development workflow.

This guide is about joining that second group.

If You Only Remember 3 Things

  • Claude Code = environment, not prompts. The leverage is in what you build around the tool, not what you type into it.
  • CLAUDE.md is your highest-leverage asset. One well-crafted file compounds across every session, every engineer, every month.
  • Always use planning + feedback loops. One-shot prompting is the single fastest way to cap your productivity gains at 20%.

Everything else in this guide is elaboration on those three points.

Part 1: The Mental Model

The core agent logic in Claude Code is almost embarrassingly simple: a while loop. Model generates → tools execute → results feed back in. That's it.

What makes it extraordinary is what surrounds that loop: a graduated 5-layer context management pipeline, append-only JSONL session transcripts, a 7-mode permission gradient with ML-assisted auto-approval, git worktree–based subprocess isolation, and a hierarchical memory system the agent can write to itself. That's 98%+ of the codebase — operational infrastructure, not model magic.

The industry built elaborate orchestration graphs on top of weak models. Anthropic went the other way: keep the loop minimal, scaffold the environment so thoroughly that capable models can just work.

You are not crafting prompts. You are designing an environment.

If that clicks, the rest of this guide follows naturally. Invest two hours on the context substrate — CLAUDE.md hierarchy, tool integrations, feedback primitives — and you get gains that compound across your whole team indefinitely. Claude Cowork (Anthropic's desktop automation product) was built almost entirely through Claude Code sessions in 1.5 weeks. That's not a benchmark. That's a proof of concept.

Part 2: Setup in 10 Minutes

npm install -g @anthropic-ai/claude-code

Node.js required. You knew that. Here's what you probably skipped.

Run these slash commands first, before anything else:

/terminal-setup — Enables Shift+Enter for newlines. Without it you're firing prompts mid-sentence like it's 2009 IRC.
/install-github-app — Genuinely transformative. @mention Claude on any GitHub issue or PR directly.
/allowed-tools — Whitelist your frequent tools. After the fifteenth "Are you sure you want me to run grep?" you will either whitelist or quit.
/theme — Light/dark. Minor, but do it now.

macOS dictation: Enable it (System Settings → Accessibility → Dictation) and speak prompts while your hands stay on the trackpad examining output. Sounds gimmicky until you try it on a complex refactoring instruction.

Keyboard shortcuts worth memorizing:

ShortcutWhat It Does
Shift+TabAccept edits
#"Remember this" — writes to CLAUDE.md
!Run bash; output stays in context
@Reference files/folders
Esc EscJump back in history
Ctrl+RShow full output Claude sees

The # shortcut is the compounding one. Every # always use the Barley CLI for log inspection survives into every future session. Institutional memory, one keystroke at a time.

Part 3: CLAUDE.md — Your Most Important File That Isn't Code

CLAUDE.md files are plain Markdown that Claude Code loads automatically at session start. Three levels:

~/.claude/CLAUDE.md — Global, cross-project. Your personal engineering constitution: universal preferences, tool habits, style principles, safety policies.
project-root/CLAUDE.md — Project-specific. Checked into source control. Shared with the whole team. Architectural decisions, key file locations, testing conventions, onboarding shortcuts, known landmines.
CLAUDE.local.md — Personal project overrides. Gitignored. WIP experiments, "I keep forgetting to…" notes.

Subdirectory CLAUDE.md files load automatically. Create one in /src/payments/ and it only activates for payment-related work. Context is scoped, not flat.

What goes in: Bash commands, MCP tools, style constraints, architectural rules ("never raw SQL — always the repository layer"), testing oracles, known failure modes.

What stays out: Everything grep can find. CLAUDE.md is for what can't be discovered programmatically — decisions, conventions, tribal knowledge. Don't paste your README.

Signal density is the principle. A bloated CLAUDE.md is worse than a lean one. Boris's recommendation: under 200 lines. Every line earns its place.

The team multiplier: Once project-root CLAUDE.md is in source control, every new hire inherits an agent that already understands your architecture. Anthropic's technical onboarding dropped from 2–3 weeks to 2–3 days. Not because Claude Code is magic — because the knowledge that lived in senior engineers' heads now lives in a versioned file an AI can actually use.

Part 4: Common Mistakes That Kill Performance

These are not theoretical. They are what most teams are doing right now.

Treating it like GitHub Copilot. Copilot completes your next line. Claude Code can own an entire feature end to end — plan, implement, test, validate — if you let it. Using it for tab-completion is like hiring a senior engineer to sort your inbox.
No CLAUDE.md. Starting fresh every session. Every prompt has to re-explain your stack, your conventions, your constraints. You're paying the context tax every single time. Teams that skip CLAUDE.md are leaving 60–70% of the tool's value on the table permanently.
No test loop. "Write me a login component" → accept output → manually test in browser → find three bugs → iterate. This is the slowest possible workflow. Without a test oracle, the agent has no way to know if it succeeded. You become the oracle, which means you're back to babysitting.
One-shot prompting. Ask → get code → done. No plan review. No verification. No iteration. You're using an agentic tool as a glorified search engine. The output quality ceiling for one-shot prompting is much lower than people realize.
No tool integration. Claude Code doesn't know your internal CLI, your monitoring stack, your deployment scripts. If you don't tell it, it will either skip those steps or invent something wrong. Every time a session ends and you think "it should have checked the build first" — that's a CLAUDE.md edit you haven't made yet.

Part 5: The 5-Layer Context Pipeline (Why It Stays Coherent)

Most agent tools use brute-force context truncation. Claude Code runs a graduated pipeline before every model call — least destructive first, most destructive last:

Layer 1 — Budget Reduction: Caps tool result sizes. A 50,000-line grep doesn't choke the session.
Layer 2 — Snip: Trims old history. Recent, high-signal turns survive; ancient dialogue from three hours ago doesn't.
Layer 3 — Microcompact: Cache-aware compression. Frequently referenced content stays hot; one-off outputs compress. L1/L2 cache logic, but for tokens.
Layer 4 — Context Collapse: Projects a summary at read-time without mutating stored history. You can still rewind to exact previous states.
Layer 5 — Auto-Compact: Full model-generated summary. Last resort. The "nuclear option" that most other tools treat as their only option.

Boundary markers are preserved at every stage. Sessions stay coherent for days because the pipeline applies minimum intervention, not brute-force truncation.

Design your workflow accordingly: CLAUDE.md content is Layer 1-proof — always survives. Transient notes in NOTES.md are fine to let auto-compact handle. Put your most critical content at the top of CLAUDE.md — it's the most compression-resistant position.

Part 6: Sessions as Git Commits

Every session is stored as an immutable JSONL event log at ~/.claude/projects/. Every file edit, bash command, model response, tool call — recorded, in order, permanently.

Resume exactly, not approximately. Full fidelity including mid-task state. For a 20-minute sprint this is nice. For a multi-day architectural refactor it's essential.

Permissions reset on resume. Deliberately. This prevents permission creep — the subtle session-by-session expansion of what the agent is trusted to do without asking. Annoying the first time. Clearly right after you think about it.

Boris runs five parallel Claude Code instances on the same repo — different terminals, different worktrees, different subagents — and the JSONL architecture is what prevents chaos. Fork a subagent for risky refactors. Review the transcript. Merge what you want. Branch-based development, applied to AI-assisted work.

Part 7: Planning Mode + Feedback Loops

The shift from Copilot-style to agentic: give Claude a way to verify its own work.

Before any non-trivial task: "Brainstorm the approach. Write a plan. Run it by me before touching files."

Thirty seconds overhead. What it buys: the agent catches its own misunderstandings before they become broken code, you get a plan you can actually redirect, and there's a natural checkpoint before significant work goes in the wrong direction.

After approval, give it a test oracle:

The agent iterates automatically until it passes. Boris demonstrated this live: near-pixel-perfect UI replications from mockup screenshots, Claude running Puppeteer in a loop, comparing output, self-correcting. No human after approval. That's what agentic actually means.

Part 8: Multi-Agent Workflows

Open five terminals. SSH into Tmux. Spin up subagents via the SDK. Each gets its own git worktree — multiple working trees on the same repo, no conflicts, no Docker required.

Why it doesn't collapse into chaos:

Practical patterns:

Lead + specialists: One orchestrator, specialist subagents for frontend/backend/tests in parallel.
Risky refactor isolation: Fork a subagent for anything that touches critical paths, review transcript before merging.
Team parallelism: Each engineer's Claude Code session on their own branch; CLAUDE.md shared, CLAUDE.local.md personal.

Part 9: Tool Integration (Where Most Teams Leave Real Leverage)

Claude Code doesn't know your internal tooling. This seems obvious. It is also the thing most teams forget for months.

Tell it about your internal CLIs, monitoring commands, deployment scripts, and branch naming conventions. Put it all in CLAUDE.md. One entry, infinite sessions.

For structured integration: check an mcp.json into your repo with MCP server configurations. Every engineer who clones gets prompted to install once. After that, every Claude Code instance on your team has access to the same tools — database inspection, ticket system, internal docs. This is how individual productivity becomes organizational infrastructure.

Part 10: The Master Prompt

Run this once per project. Rerun every 2–4 weeks.

You are the Environment Architect for Claude Code — an expert at turning any
software project into a high-signal, self-improving agentic workspace.

Project context:
[PASTE YOUR PROJECT DESCRIPTION, TECH STACK, GOALS, PAIN POINTS,
TEAM SIZE, AND EXISTING ARCHITECTURAL DECISIONS HERE]

Your single output must be a complete, ready-to-deploy Claude Code environment:

1. Global CLAUDE.md (~80–150 lines) — cross-project rules, style guide,
   common bash/MCP tools, safety policies.

2. Project-root CLAUDE.md — architecture decisions, key files, onboarding
   shortcuts, testing oracles, feedback loops.

3. CLAUDE.local.md template (gitignore'd) — personal overrides, temp notes.

4. Hierarchical Memory Strategy — how the agent uses NOTES.md / TODO.md /
   DECISIONS.md, when to promote via # remember, conflict-resolution rules.

5. Skill & Hook Library — 5–8 MCP skills or lifecycle hooks with JSON schema
   and example usage.

6. Workflow Playbook — 3–4 reusable prompt templates: Planning Mode, Code
   Review Mode, Refactor Mode, Incident Response.

7. Compaction & Context Policy — instructions for the 5-layer pipeline,
   tool-result clearing, summarization, long-horizon session resumption.

8. Self-Improvement Rules — the agent periodically proposes CLAUDE.md
   refinements for human approval (generation → reflection → curation).

Constraints:
- Every file under 200 lines. Signal density over completeness.
- Reference Claude Code primitives: # remember, ! bash, @ files,
  sub-agent worktrees, auto-accept mode, permission gradients.
- Favor just-in-time glob/grep over pre-loading.
- Output: one Markdown block, clear headings, code fences per file.
  End with "Next Step" instructions.

Begin.

Fill in the project context honestly. Specific pain points yield better output than generic descriptions. The result won't be perfect — it'll be 80% there in one shot, which is 80% better than what most teams have after months of ad-hoc tuning.

Where This Breaks

Claude Code is genuinely powerful. It is not magic. Here's where it struggles, based on real usage patterns:

Large legacy codebases without documentation. When the codebase has no clear architecture, inconsistent naming, and years of undocumented decisions, even excellent CLAUDE.md files can't compensate. Claude Code amplifies your existing documentation quality — for better or worse.
Unclear requirements. "Make the dashboard better" produces confident, wrong work. Ambiguous requirements don't produce hedged output — they produce decisive output in the wrong direction. The planning step exists precisely to surface this before code gets written.
Missing test oracles. Without a way to verify its own work, the agent produces output, declares success, and hands it back to you. You become the test suite, which eliminates most of the agentic value.
Bad internal tooling. If your build process is fragile, your test suite is flaky, and your deployment scripts fail intermittently — Claude Code will amplify the chaos. Garbage in, garbage out applies to the feedback loop the same way it applies to data.
One pattern that surprises people: Claude Code is better at greenfield than refactoring. For new features on a clean surface, it's remarkable. For unpicking fifteen years of coupled code in a monolith, it needs much more hand-holding — smaller scopes, more frequent plan reviews, explicit constraints on what not to touch.

Part 11: The Cutting Edge

Self-improving contexts (ACE Framework, arXiv 2510.04618): Context as a living playbook the agent generates, reflects on, and curates. Generation → reflection → curation. You can run it manually now: end long sessions with "Review CLAUDE.md. What's missing, outdated, or wrong? Propose specific edits."
Graph-based agentic memory: Flat files hit limits in week-long multi-branch sessions. Research on hierarchical graph memory (GAM, HiMem) proposes explicit nodes for episodic, semantic, and strategic memory. For long-horizon work today: maintain explicit EPISODIC.md, SEMANTIC.md, PLAYBOOKS.md files.
Verified multi-agent orchestration: One agent executes, an independent verifier agent checks test coverage, security, and correctness before any commit. Anthropic has Code Review Agents in research preview. The trajectory is a formal Plan → Execute → Verify → Replan → Synthesize DAG.
The 2026 consensus: 2025 was agents. 2026 is agent harnesses — declarative infrastructure teams define once and every engineer inherits. Claude Code is already the most sophisticated harness in production; the next step is making the harness config itself a first-class team artifact.

Implementation Sequence

Week 1: Run the four slash commands. Start every session with Q&A before editing. Build your global CLAUDE.md.
Week 2: Run the Master Prompt on your primary project. Check project-root CLAUDE.md into source control.
Week 3: Document internal CLI tools. Configure MCP via mcp.json. Wire up feedback loops (test suite, build validation).
Week 4: Experiment with parallel sessions. End long sessions with a CLAUDE.md review request. Start treating context files as a first-class codebase.

After month one, your context files have compounded enough that new team members get better sessions from day one. After six months, your CLAUDE.md hierarchy is an organizational artifact as important as your ADRs.

The Actual Mindset Shift

The engineers who get the most from Claude Code aren't the ones with the best prompts. They're the ones who treat context engineering as a professional discipline — worth studying, iterating on, and improving continuously.

Claude Code is the first developer tool where your investment in the environment compounds over months and years. A new team member doesn't just inherit a codebase — they inherit an intelligent, contextually rich workspace that knows your architecture, your conventions, and your war stories.

The CLAUDE.md file is blank and waiting. What you build there is entirely up to you.

Sources

Anthropic Official

Academic Research

Community Resources

Crafted by Nicolas Martin with Claude | Fractal-Apps Pvt Ltd, Pondicherry | April 21, 2026