How Anthropic's agentic coding tool actually works under the hood — its loop, its building blocks, the canonical workflow, and how enterprises put it to work.
MODEL 01
It's an agent, not autocomplete
You hand it a goal, not line-by-line prompts. It reads files, runs commands, and loops on its own results until done.
MODEL 02
The harness is the product
The model reasons; Claude Code supplies the tools, context management, and execution environment that turn a model into a coding agent.
MODEL 03
You stay in the loop
Permission prompts, plan mode, and checkpoints keep a human in control — which is what makes autonomy safe on real codebases.
The agentic loop — gather, act, verify, repeat
One line: Every task runs the same cycle — Claude gathers context, takes an action with a tool, reads the result, and repeats until no more tool calls are needed.
Picture a capable colleague at your keyboard who narrates as they go. You say "fix the failing tests." Claude runs the tests to see what broke → reads the error → searches for the relevant file → reads it → edits it → re-runs the tests to check. Each result tells it what to do next. Mechanically it's a simple rule: keep calling tools until the answer needs no more tools (engineers describe it as a while(tool_use) loop). A small fix might loop 8–12 times in under a minute; a big refactor chains dozens of steps and course-corrects along the way.
The three phases (they blend together)
Gather context — search and read files, pull git state, fetch docs from the web, load CLAUDE.md, ask you a question if something's missing.
Take action — edit files, run shell commands, start servers, use git, call external tools via MCP.
Verify results — run tests, check type errors, compare against a screenshot, then decide whether to loop again.
Powered by two things
Models that reason — Sonnet handles most coding; Opus for harder architectural reasoning. Swap mid-session with /model.
Tools that act — five built-in families: file ops, search, execution, web, code intelligence. Without tools the model can only talk; tools are what make it agentic.
The key advance over Copilot-style tools is autonomy. You give it a goal, not a prompt per line, and it iterates on its own failures — gathering, acting, and verifying without you driving each step.
What Claude can see and touch — the working environment
One line: Run claude in a directory and it gains scoped access to your project, terminal, git state, and any extensions you've configured.
Unlike an inline assistant that only sees the file you're staring at, Claude Code sees the whole project — so when you say "fix the auth bug" it can search across files, read several to understand how they connect, make coordinated edits, run the tests, and commit. It works inside your real environment using your real tools, rather than in some opaque backend.
What it gets access to
Your project — files in the directory + subdirectories (others only with permission).
Your terminal — anything you could run: build tools, git, package managers, scripts.
Your git state — current branch, uncommitted changes, recent commit history.
CLAUDE.md + auto memory — your standing instructions, plus learnings it saved itself (see B1).
Extensions — MCP servers, skills, subagents, and browser control, when you configure them.
CLAUDE.md and memory — persistent project context
One line: A markdown file in your project root that Claude reads at the start of every session — the highest-leverage thing you can set up.
Think of it as the onboarding doc you'd hand a new hire. Coding standards, architecture decisions, preferred libraries, the commands to build and test, a review checklist. Because Claude re-reads it each session, a good CLAUDE.md dramatically cuts how many back-and-forth iterations a task needs. There's also auto memory: Claude quietly saves learnings (like build commands and debugging insights) to a MEMORY.md as it works, and reloads them next time — so the project gets easier to work in over time.
Generate a starter with /init; put rules you never want lost here, not in the chat (chat history can get compacted away).
Scopes stack: organization-wide → project → personal, so teams can share standards.
Permission modes and checkpoints — the safety layer
One line: Claude asks before risky actions, you pick how much autonomy to grant, and every file edit is reversible.
A dial between "ask me everything" and "just go." Tap Shift+Tab to cycle modes. Before editing any file Claude takes a snapshot, so Esc Esc rewinds you to an earlier state — like a local undo separate from git. Actions that hit the outside world (databases, deploys, APIs) can't be checkpointed, which is exactly why Claude always asks before those.
The four permission modes
Default — asks before file edits and shell commands.
Auto-accept edits — edits + safe filesystem commands run without asking; still asks for the rest. Good for rapid prototyping loops.
Plan mode — read-only; produces a plan you approve before any change. Best for production code.
Auto mode — evaluates every action with background safety checks (research preview).
"Supervised autonomy" — decisions about what ships stay with the human. Plan mode isn't a limitation; it's what makes autonomous operation trustworthy rather than risky.
One line: Four ways to extend the core loop — add knowledge, connect tools, automate guardrails, and parallelize work.
If the loop is the engine, these are the bolt-ons. Skills are reusable playbooks ("how we review a PR") packaged as files Claude loads only when relevant. MCP is a universal adapter that lets Claude read a Jira ticket, a Google Doc, or a Slack thread as if they were built-in tools. Hooks are automatic triggers — "run the formatter after every edit," "lint before every commit." Subagents are disposable helpers with their own context window that go do one scoped job and hand back a summary, so deep digging doesn't clog the main conversation.
Primitive
What it adds
Example
Skills
Packaged repeatable workflows, loaded on demand
/review-pr, /deploy-staging
MCP
Connects external data/tools via an open standard
Read Drive docs, update Jira, pull Slack
Hooks
Shell commands before/after Claude's actions
Auto-format on edit; lint before commit
Subagents
Isolated context for delegated/parallel work
One reviews tests while another reads diffs
Subagents = quick parallel research within one task (fresh context, returns a summary). Agent teams = genuinely parallel workstreams (e.g. one agent on the backend, another on frontend tests), coordinated by a lead agent that assigns subtasks and merges results.
Context management — keeping the agent sharp
One line: The context window holds everything Claude is "thinking about"; as it fills, Claude prunes and compacts automatically — but early instructions can get lost.
The context window is the agent's desk — limited surface area. It holds the conversation, file contents, command outputs, CLAUDE.md, and loaded skills. When the desk fills, Claude first clears old tool outputs, then summarizes the conversation if needed (compaction). Your requests and key code survive; fine-grained instructions from early on may not — which is why durable rules belong in CLAUDE.md. Run /context to see what's eating space.
Compaction is automatic near the limit; steer it with a "Compact Instructions" section in CLAUDE.md or /compact focus on the API changes.
Skills stay out of context until used; subagents keep their digging in a separate window — both are context-saving levers.
MCP tool definitions are deferred (loaded on demand via tool search), so only tool names cost context until called.
The "kitchen-sink session" — start one task, veer into an unrelated one, jump back, and now context is full of noise and quality drops. Fix: keep sessions focused, or start fresh (a new session begins with a clean window).
Sessions, resume and fork — continuity and parallelism
One line: Conversations are saved locally so you can resume, fork, or run several in parallel — each tied to a directory.
Every session is written to a local logbook (a plaintext file under ~/.claude/). That's what lets you resume tomorrow exactly where you stopped, or fork — branch off to try a different approach without disturbing the original thread. To run multiple Claudes at once without their edits colliding, give each its own folder via git worktrees. Sessions are independent: a new one starts fresh, which is why persistent rules live in CLAUDE.md, not chat history.
claude --continue / --resume picks up the same session; --fork-session branches with a new ID.
Worktrees = isolated git checkouts for true parallel sessions; the Desktop app and web manage these visually.
Explore → Plan → Code → Commit — the canonical workflow
One line: The most reliable results come from separating research from writing code — explore first, plan, then implement, then commit.
Explore — Ask Claude to read the relevant code and understand it, without writing any code yet. Use plan mode (read-only).
Plan — Have it produce a plan for the change. Review and refine it through conversation before approving.
Code — Let it implement against the agreed plan, ideally with a test or screenshot to verify against.
Commit — It stages changes, writes the commit message, and can open a PR with a structured description.
The habits that make it work
Be specific upfront — name files, constraints, and example patterns; specific prompts often succeed on the first try.
Give it something to verify against — test cases, expected output, a screenshot of the target UI. Self-checking sharply improves results.
Delegate, don't dictate — give context and direction like you would a capable colleague; let Claude figure out which files to read.
Interrupt and steer — if it goes down the wrong path, just type a correction; no need to wait or restart.
Non-interactive mode (claude -p "…") pipes Claude into CI, pre-commit hooks, and scripts, with --output-format json for parsing.
Jumping straight to code lets small misunderstandings compound. Forcing an explore-and-plan step surfaces the misunderstanding before any code is written — cheaper to fix a plan than a pile of edits.
Surfaces and execution environments — one engine, many doors
One line: The same agentic loop runs everywhere; what changes is where the code executes and how you interact. Your CLAUDE.md, settings, and MCP servers carry across all of them.
One brain, many doors into it. The terminal is the full-featured home base; the IDE extension (VS Code, JetBrains) adds inline diffs; the Desktop app runs several sessions side-by-side; the web and iOS app let you kick off long tasks and check back later. You can even start on the web and pull the task into your terminal with --teleport, or hand a terminal session to Desktop for visual diff review.
Execution environment
Where code runs
Use case
Local
Your machine
Default. Full access to your files and tools.
Cloud
Anthropic-managed VMs
Offload long tasks; work on repos you don't have locally.
Remote Control
Your machine, driven from a browser
Use the web UI while everything stays local.
Automation and team entry points
CI/CD — GitHub Actions / GitLab CI for automated code review and issue triage; @-mention Claude in Slack with a bug report and get a PR back.
Routines — scheduled recurring work (morning PR reviews, overnight CI-failure analysis, weekly dependency audits) on managed infra, so they run even when your machine is off.
Agent SDK — embed the same loop in your own apps with full control over tools, permissions, and orchestration.
Enterprise use cases — real deployments and results
One line: The same loop powers fintech, e-commerce, dev tools, supply chain, telecom, and finance — at scales from dozens to tens of thousands of developers.
Ramp · Fintech
Org-wide adoption beyond engineering. A grassroots rollout where data teams query the Snowflake warehouse in natural language, and non-technical staff in sales, risk, finance, and recruiting pull insights without writing SQL.
1M+ lines of AI-suggested code in 30 days
50% weekly active usage across engineering
~80% faster incident investigation
Rakuten · E-commerce, 70+ businesses
Long autonomous runs on complex refactors. Used Claude Code to automate coding tasks across thousands of developers while holding enterprise-grade quality and security.
7 hrs sustained autonomous coding on one refactor
79% faster time-to-market (24 days → 5)
99.9% accuracy on complex code modifications
cubic · Dev tools
AI-native code review. Built review workflows on Claude to catch issues before merge, compressing development cycles.
60× faster code shipping
28% faster development cycles
Altana · Supply-chain AI
Building sophisticated AI/ML systems faster. Uses Claude Code to accelerate development of large-scale knowledge graphs for global supply chains.
2–10× faster development velocity
Other patterns worth knowing
Behavox (compliance/security) — rolled out to hundreds of developers as their "go-to pair programmer," reporting it outperformed other coding agents.
TELUS (telecom/health) — Claude powers the internal "Fuel iX" platform for 57,000 employees; developers use Claude Code in VS Code and GitHub for real-time refactoring.
Bridgewater (asset management) — Claude as an "investment analyst assistant" that writes Python for analysis, handles errors, and outputs charts — freeing analysts for strategy.
Anthropic internal — even the legal team built a "phone-tree" tool prototype with Claude Code; engineers use auto-accept mode for autonomous test-and-iterate loops.
How to think about enterprise value
Velocity — features ship faster; long refactors run autonomously (Ramp, Rakuten).
Quality and risk — automated review and incident response; permission/checkpoint model makes it safe on production code (cubic, Ramp).
Democratization — non-engineers build tools and query data in natural language (Ramp, Anthropic legal).
Onboarding and knowledge — point it at an unfamiliar codebase for an architecture walkthrough and auto-generated docs.
Governance — org-down permission policies, audit, and admin controls make org-wide rollout viable.
✦ Quiz — check your understanding (8 questions)
Pick an answer and hit "Check" to see if you've got it.
Question 1 of 8
What is Claude Code's core agentic loop?
Every task in Claude Code follows this cycle: gather context (read files, pull git state), take action (edit, run commands), verify results (run tests, check output), then repeat as needed.
Question 2 of 8
Where should durable project rules be written so they survive context compaction?
CLAUDE.md is read at the start of every session, so rules here survive compaction. Chat history can get summarized away; CLAUDE.md cannot.
Question 3 of 8
Which permission mode is read-only and best suited for reviewing changes to production code?
Plan mode is read-only — Claude produces a plan for you to approve before any change is made. This makes autonomous operation trustworthy on production code.
Question 4 of 8
What does a Subagent do differently from the main agent in a Claude Code session?
Subagents are disposable helpers with their own context — deep digging doesn't clog the main conversation, and they hand back a concise summary when done.
Question 5 of 8
What is the key benefit of the Explore → Plan → Code → Commit workflow?
Separating research from implementation is the key insight: small misunderstandings caught at the plan stage are far cheaper to fix than after code has been written.
Question 6 of 8
What is "compaction" in Claude Code's context management?
When the context window fills, Claude first clears old tool outputs, then summarizes the conversation if needed. Your code and requests survive; stale instructions from early in the session may not — which is why CLAUDE.md exists.
Question 7 of 8
What does a Hook do in Claude Code?
Hooks are shell commands that fire at fixed lifecycle points — before/after a tool call or turn. Classic uses: auto-format on edit, lint before commit, run type-checker after any file change.
Question 8 of 8
What does MCP (Model Context Protocol) do in the context of Claude Code?
MCP = Model Context Protocol. It's an open standard so external tools/data can be connected without bespoke glue per service. Claude can read a Jira ticket or a Google Doc as if they were built-in tools.
🃏 Flashcards — tap any card to reveal the definition
16 key terms from this guide. Tap to flip.
Agentic loop
tap to reveal →
Gather context → take action → verify → repeat. Runs until no more tool calls are needed. The core of Claude Code.
← tap to flip back
Agentic harness
tap to reveal →
Everything around the model — tools, context management, execution environment — that turns an LLM into a coding agent.
← tap to flip back
CLAUDE.md
tap to reveal →
Project-root markdown file of standards, commands, and context — read at the start of every session. Use /init to generate a starter.
← tap to flip back
Auto memory
tap to reveal →
Learnings Claude saves itself (to MEMORY.md) and reloads across sessions — build commands, debugging insights — no writing required.
← tap to flip back
Plan mode
tap to reveal →
Read-only permission mode — Claude produces a plan for you to approve before making any change. Press Shift+Tab twice to activate.
← tap to flip back
Checkpoint
tap to reveal →
A pre-edit file snapshot taken automatically. Press Esc Esc to rewind. Local, separate from git; applies to file changes only.
← tap to flip back
MCP
tap to reveal →
Model Context Protocol — open standard to connect external data/tools (Jira, Drive, Slack) as native tools without bespoke integration per service.
← tap to flip back
Skill
tap to reveal →
A packaged, on-demand workflow Claude loads only when relevant — e.g. /review-pr or /deploy-staging. Keeps context clean until needed.
← tap to flip back
Hook
tap to reveal →
A shell command that runs automatically before or after Claude's actions — format-on-edit, lint-before-commit, type-check after any file change.
← tap to flip back
Subagent
tap to reveal →
A disposable helper with its own context window. Does one scoped job and returns a summary — keeps deep digging from clogging the main session.
← tap to flip back
Agent team
tap to reveal →
Multiple full agents on parallel workstreams — e.g. one on backend, one on frontend tests — coordinated by a lead agent that merges results.
← tap to flip back
Compaction
tap to reveal →
Auto-summarizing older context when the window fills. Steerable via /compact or a "Compact Instructions" section in CLAUDE.md.
← tap to flip back
Worktree
tap to reveal →
An isolated git checkout so parallel Claude sessions don't collide on edits. The Desktop app manages these visually.
← tap to flip back
Non-interactive mode
tap to reveal →
claude -p "…" — pipes Claude into CI, hooks, and scripts. Use --output-format json for programmatic parsing of results.
← tap to flip back
Routines
tap to reveal →
Scheduled recurring tasks on Anthropic-managed infra — morning PR reviews, overnight CI-failure analysis — run even when your machine is off.
← tap to flip back
Agent SDK
tap to reveal →
Library to embed Claude Code's loop in your own apps with full control over tools, permissions, and orchestration logic.