Claude Code, from first principles
Most people meet Claude Code and treat it like a chatbot in a terminal. It isn't. It's a harness — a machine that builds the model's context, runs deterministic code around it, and remembers across sessions. Understand that one idea and everything else falls into place. This guide takes you there in four moves.
The one idea
A chatbot delivers your prompt. Claude Code constructs one.
You run claude in your terminal and talk to the model — but it can also read your files, run shell commands, call tools, and loop until the job is done. The word “prompt” hides the whole trick, because it means two different things:
In a chatbot, (a) and (b) are the same thing. In Claude Code they’re radically different — and the gap between them is where all the quality comes from.
You control only a sliver of effective context — your typed prompt. The harness controls all the rest, and the iteration loop entirely. Same model, same sentence, three different worlds:
| Environment | What the model sees | Result |
|---|---|---|
| Chatbot, no tools | The sentence | Textbook code, generic style |
| Claude Code, no reading | Sentence + CLAUDE.md | Matches your declared conventions |
| Claude Code, agentic loop | Sentence + CLAUDE.md + reads adjacent files + runs tests | Matches the real codebase, passes tests, handles the edge cases your code handles |
The beginner's analogy
Using Claude Code is like hiring someone
Prompting
Asking a stranger on the street for directions. You get an answer — but the method is unpredictable, and never the same twice.
Agents
Hiring a specialist with a fixed job description. Same question, same approach, every time. The gain is consistency, not intelligence.
Skills
That specialist having specific training for specific tasks — exact steps for exact jobs, reusable across many specialists.
The anatomy
Everything lives in a .claude/ folder
The harness is configured by plain markdown and JSON files. Two homes: ~/.claude/ is global (all projects); .claude/ inside a repo is scoped to that project. Project overrides global.
The 8 primitives
Eight building blocks — that's the whole vocabulary
Subagents
.claude/agents/*.mdA separate Claude instance with its own context window, tools and model. Spawn one for research/review so the main thread stays clean. Claude auto-invokes it when the request matches its description.
Commands
.claude/commands/*.mdReusable prompt shortcuts you fire by typing /name. The file body is a prompt template; frontmatter can take $arguments, pin a model, or restrict tools. Never auto-invoked — always explicit.
Skills
.claude/skills/*/SKILL.mdPackaged expertise Claude auto-loads when a task matches its description (a compact skill listing sits in context at ~1% budget). Reusable checklists, recipes, workflows — pulled in without you pasting them.
Memory
CLAUDE.mdAlways-loaded project context — “the single most impactful way to improve output.” Ancestors load up the tree at startup; subdirectory CLAUDE.md files load lazily only when you touch those files. Siblings never load.
Settings
settings.jsonJSON that controls model, permissions, hooks, MCP, sandbox. Layered: managed > CLI > project-local > project > user. deny rules always win. Arrays like permissions.allow merge across scopes.
MCP servers
.mcp.jsonPlug-in connectors giving Claude live tools — current docs, a real browser, your database. stdio (local process) or http (remote). Start small: one team “went to 15 servers, used only 4.”
Power-ups
/powerupTen short animated in-terminal lessons, each teaching a feature people miss — rewind, plan mode, subagents, the effort dial. The fastest way for a beginner to discover what’s there.
CLI flags
$ claude …One-session overrides at launch — resume work, run headless in scripts, swap the model, or isolate in a git worktree. Sit above every file setting but below managed policy.
The signature pattern
Command → Agent → Skill
The three extension mechanisms compose into one pipeline. Claude prefers the lightest option that fits: Skill (inline) → Agent (separate context) → Command (only when you type /). Here’s the repo’s worked example, a weather orchestrator:
skills: frontmatter) — its full text is injected into the agent at startup as reference knowledge. Directly invoked (via the Skill tool) — it runs in the caller’s context to produce output. The weather example shows both on purpose.Scope & precedence
What lives global vs. project
| Category | Scope | Why |
|---|---|---|
| Tasks, agent teams | Global-only | Coordination must outlive any one project |
| Credentials, OAuth | Global-only | Never accidentally committed to a repo |
| Auto-memory | Global-only | Personal learning, not team config (though it’s about a project) |
| CLAUDE.md · settings · rules · agents · commands · skills · hooks · MCP | Both | Teams share project behavior; project overrides global |
Settings precedence, highest→lowest: managed policy → CLI flags → .claude/settings.local.json → .claude/settings.json → ~/.claude/settings.local.json → ~/.claude/settings.json. Above all: deny rules can never be overridden.
claude. Start in the wrong folder and you inherit the wrong rules.The objection
“Isn't it all just prompts to the model in the end?”
A common, half-right claim: skills, commands, subagents, hooks — they all become tokens the model sees, so a strong prompt alone should be equivalent. At the final inference call, that’s true. For an atomic one-shot task it’s entirely true — and that’s exactly the regime real engineering work is never in. Everywhere else it collapses, because ten harness capabilities operate at layers a prompt can’t reach:
| Capability | Why a prompt can't replicate it |
|---|---|
| Context isolation | A prompt fills one window; N subagents give ~N× effective context |
| Tool restrictions | Prompt instructions are advisory and can be ignored; deny rules cannot |
| Lazy-loaded rules & memory | A prompt is static; it can’t conditionally load based on files touched at runtime |
| Hooks | Deterministic shell code at lifecycle events that can block a tool call — even if the model “wants” to run it |
| Model routing | No token in a prompt can change which model answers (model: haiku/opus) |
| Parallelism | A prompt is sequential; the harness runs concurrent subagents |
| Cross-session persistence | A prompt dies with the session; memory + settings survive |
| Permission classification | A prompt can’t add a pre-execution safety layer to itself |
The harness controls what the system does — before tokens arrive, after they’re produced, across sessions, contexts and processes.
“You can write the world’s best recipe. Without a kitchen, you cannot cook at scale.”
“Features are not prompts with extra steps. They are harness-level primitives — deterministic execution, context architecture, infrastructure routing.”
The reason context is a skill
“Claude got dumber today” — the real story
Frozen weights ≠ frozen behavior. The weights don’t change after launch, but ~9 layers above them do — and the numbers are bigger than people think.
Anthropic confirmed three infrastructure bugs in a Sept 2025 postmortem (bad routing, TPU output corruption, a compiler mis-compilation) — real, but transient. The far more common cause of “it got dumber” happens inside your session: context pollution. Earlier mistakes accumulate and the model perpetuates them.
The honest boundary
When you don't need any of this
For an atomic, self-contained question — “write me a recursive Fibonacci” — the harness contributes nothing and a plain chatbot is equal. Use the right tool. The harness earns its keep the moment work spans files, sessions, tools, or needs a guarantee a prompt can only request.
Day 0 — get running
Install & authenticate
Install (macOS via Homebrew)
Open Terminal, then:
Verify
Log in
Run claude. On first launch pick a method: Claude.ai account (Pro/Max subscription — browser opens, authorize, done) or Anthropic API key (paste a key starting sk-ant-, stored once).
Day 1 — your first conversation
Three levels of control
claude, ask anything. Great for codebase questions, edits, explaining errors. Method is unpredictable — that’s fine to start.claude → /weather-orchestrator.The practitioner's playbook
What the people who ship all day actually do
Verification — the #1 unlock the ceiling on quality
- Give Claude a way to verify its own work. A feedback loop 2–3×’s the final quality. Backend → have it run the server end-to-end; frontend → give it a browser; desktop → Computer Use. — Boris
- “If your codebase doesn’t have feedback loops you’re never going to get decent output. That is the ceiling.” — Matt Pocock
- Make Claude your reviewer: “Grill me on these changes and don’t open a PR until I pass,” or “Prove to me this works.” — Boris
- TDD (red-green-refactor) instruments the code before it exists, so the model can’t cheat by wrapping a finished implementation in trivial tests. — Matt Pocock
Context management the smart zone vs the dumb zone
- The context window is everything the model sees — system prompt, conversation, every tool call + output, every file read. Fresh context = sharpest attention. — Thariq
- Beginners: keep it under ~40%; at 60% think about wrapping up. Experienced users read the task and push higher. — Dex
- Rewind > correcting. Correcting leaves the failed attempt in context; rewind (
esc-esc) to just after the file reads, then re-prompt with what you learned — clean context. — Thariq - /compact is lossy but keeps momentum (steer it:
/compact focus on the auth refactor). /clear + a hand-written brief lets you decide what survives — for high-stakes next steps. — Thariq - Persist what matters into static files (research doc, design doc, plan), not into a compaction you have to trust. — Dex
- Put context usage on your status line (
/statusline) — you need to see how close you are to the dumb zone. — Boris & Matt
Plan mode & specs think before it codes
- Start ~80% of sessions in Plan mode (
shift+tabtwice). Pour energy into the plan so Claude can one-shot the build. The moment it goes sideways, switch back to plan mode and re-plan. — Boris - Plan mode is just one instruction — “please don’t code.” You can literally just say that. — Boris
- Have one Claude write the plan, spin up a second to review it “as a staff engineer.” — Boris
- Specs-to-code without reading code doesn’t work. Both Matt and Dex tried it for ~6 months and quit. “The code is your battleground.” — Matt Pocock / Dex
- Vertical slices, not horizontal layers. AI wants to build all-DB → all-API → all-frontend, so nothing integrates until phase 3. Force thin slices that cross every layer. — Pragmatic Programmer, via Matt & Dex
- Mind the instruction budget: frontier models reliably follow only ~150–200 instructions; past that they half-attend. Split monoliths into focused prompts (<40 each). — Dex
CLAUDE.md discipline keep it tiny
- Boris’s personal CLAUDE.md is two lines. Everything else lives in the repo’s shared, git-checked CLAUDE.md the whole team edits. — Boris
- When it bloats, delete it and start fresh. Do the minimal thing to get the model on track; add back a little only when it drifts. — Boris
- After every correction: “Update your CLAUDE.md so you don’t make that mistake again.” Claude is eerily good at writing rules for itself. — Boris
- Beware doc rot. Stale PRDs/plans left in the repo mislead future agents — close them instead of hoarding them. — Matt Pocock
Subagents & parallelism the biggest productivity unlock
- Spin up 3–5 git worktrees, each its own Claude session. Boris runs “dozens of Claudes at all times.” — Boris
- The offload test: “Will I need this tool output again, or just the conclusion?” A subagent’s 20 reads and 3 dead-ends get garbage-collected on exit — only its report returns (~94k tokens spent barely move your main context). — Thariq / Matt
- Calibrate to difficulty: easy = inline; hard research/bug = “use three, five, even 10 subagents in parallel.” Append “use subagents” to throw more compute at a problem. — Boris
- Uncorrelated fresh contexts are test-time compute — more agents + the right topology = more capability. — Boris
Git, debugging & daily habits the inner loop
- Worktrees are the standard for parallel work:
claude -w, alias tabs2a/2b/2cto hop in one keystroke, keep a dedicated “analysis” worktree for logs. — Boris - Anything you do more than once a day → a slash command checked into
.claude/commands/(e.g./commit-push-pr). — Boris - Just ask Claude to debug it. Good logging is the unlock: “check this object, it messed up this way” and it searches the log and figures it out. Fix scary bugs in plan mode (it searches wide). — Boris
- Review before you QA — in a fresh context, or the reviewer runs in the dumb zone and is dumber than the implementer. — Matt Pocock
- New task → new session. — Thariq
- Use voice. “You speak 3× faster than you type, and your prompts get more detailed.” — Boris
- Pre-allow permissions (
/permissions, check settings into git;/fewer-permission-prompts) instead of--dangerously-skip-permissions. — Boris
Cross-cutting principles how to hold the whole thing
- “Never bet against the model.” Scaffolding buys ~10–20%, then the next model wipes the gain. Weigh “build it now” vs “wait two months and get it free.” — Boris (the Bitter Lesson)
- You can outsource the thinking, but not the understanding. You can’t direct agents well on something you don’t understand. — Karpathy
- Stay in the loop — models are jagged. Opus refactors a 100k-line codebase, then tells you to walk to a car wash 50m away. You own the taste and judgment. — Karpathy
- 2026 is “the year of no more slop.” Going 10× faster doesn’t matter if you throw it away in 6 months — aim for a sustainable 2–3× with quality intact. — Dex
Workflows & quick reference
RPI — Research → Plan → Implement
A gated pipeline: each phase must pass before the next. The Research gate kills non-viable features before any code is written.
Essential commands to know
| Command | Does |
|---|---|
/context | Visualize how full your context window is |
/compact · /clear | Free up context (lossy) · start fresh (clean slate) |
/rewind · esc-esc | Undo conversation and/or code to an earlier point |
/agents · /skills · /mcp | Manage subagents · skills · tool servers |
/memory · /init | Edit CLAUDE.md · create one for this project |
/usage · /model · /effort | Check limits · switch model · dial reasoning low→max |
/powerup | Ten animated lessons on features you’re missing |
claude -c · claude -w | Continue last session · start in a git worktree |