Chapter 5: Claude Code Deep Dive
Architecture & Capabilities
Claude Code is Anthropic's agentic coding tool, and today it is one of the most widely used. It is not autocomplete - it operates as an autonomous agent with deep codebase understanding, multi-file editing, command execution, and the ability to run in the terminal, inside VS Code and JetBrains, on the desktop, on the web, and as headless cloud tasks. It is powered by the Claude 5 family - Opus 5.5 and Sonnet 5.5, with Fable 5.2 available for the hardest reasoning work - with up to a 1M token context window. Through 2026 it grew an operations layer to match: Routines run scheduled agent work on cron, webhooks, or API triggers; cloud sessions continue across devices and can execute on self-hosted runners inside your own network; and parallel sessions coordinate through cross-session messaging.
Core Capabilities:
* Codebase Analysis: reads and understands entire project structures
* Multi-File Refactoring: coordinated changes across dozens of files
* Subagents: spawn specialized agents that work in parallel, each with its own context
* Hooks: deterministic shell commands the harness runs on tool events (lint, format, guardrails)
* Plan Mode: read-only planning and approval before any edits
* Skills: reusable, model-invoked capabilities packaged as folders of instructions and scripts
* Background and Cloud Tasks: long-running and asynchronous work that reports back
* Background Agents: several full sessions running at once, watched from one screen
* Dynamic Workflows: a rerunnable script that orchestrates many subagents, for audits and large migrations
* Projects: a longer body of work where Claude coordinates the parallel sessions itself
* Auto Memory: learnings saved across sessions without anyone authoring them
* MCP: native Model Context Protocol support for governed tool access
* Context Window: up to 1M tokens
MCP Server Integration
MCP servers extend Claude Code with custom capabilities. Servers are added with the CLI or declared in a project's .mcp.json:
// .mcp.json
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres"],
"env": {
"DATABASE_URL": "postgresql://localhost/mydb"
}
},
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp"]
}
}
}
Or from the terminal:
claude mcp add github -- npx -y @modelcontextprotocol/server-github
claude mcp add --transport http linear https://mcp.linear.app/sse
With these servers, Claude can query databases, drive a browser, manage Git, and call internal APIs without writing integration glue - all with permissions and audit trails in the wiring.
Effective Usage Patterns
Feature Implementation Pattern:
1. Describe the feature with business context and constraints
2. Claude proposes a plan in plan mode
3. Review and approve the plan
4. Claude implements across multiple files
5. Claude generates and runs tests
6. Review against success criteria, then iterate or ship
Orchestration Pattern:
1. Decompose a large task into independent units
2. Spawn subagents to handle units in parallel
3. Each subagent returns a structured result
4. A synthesis step verifies and integrates the work
Configuration and Memory
Claude Code reads CLAUDE.md from the project root (and nested directories), supports user-level and project-level settings, custom slash commands, hooks, and output styles. It also reads an existing AGENTS.md directly when the repo has no CLAUDE.md; a repo that has both starts CLAUDE.md with @AGENTS.md, so cross-tool context never needs a second copy (Chapter 3 has the table). Alongside the files you write, it now builds its own memory as it works, carrying learnings between sessions with nothing authored by hand. That is a quiet but real shift in the context story this book opened with: some of the context layer has stopped being a document you maintain and become a byproduct of use - which makes it convenient and, for anything load-bearing, still worth writing down where a reviewer can see it. The combination of CLAUDE.md for context, hooks for deterministic guardrails, and intent specs for outcomes is what turns Claude Code from a code generator into a governed contributor with measurable behavior.
Which Feature When
Claude Code gives you several ways to shape what the agent knows and does, and they overlap enough to confuse. The rule of thumb from its own documentation: if something must happen every time, make it a hook, not an instruction. Custom slash commands are now Skills, so they get no row of their own.
| Feature | What it is | Use it when | Do not use it for |
|---|---|---|---|
| CLAUDE.md | Project instructions loaded at the start of every session. | Claude gets a convention or command wrong twice; always-do and never-do rules; build and test commands. | Long reference material (move it to a Skill) or anything that must happen every time (use a hook) - it is a request, not enforcement. |
| Skills | A SKILL.md folder Claude loads on demand, or you run as /name. | You paste the same playbook into chat a third time; reference docs; a repeatable workflow such as /deploy. | Rules every session needs (CLAUDE.md) or guaranteed actions (hooks). |
| Subagents | Isolated workers with their own context that return a summary. | A side task would flood the conversation: reading many files, parallel research, a specialist reviewer. | Quick edits that need the full conversation; a subagent starts fresh. |
| Hooks | Scripts the tool runs at lifecycle events, with no model decision. | Something must happen every time: lint after each edit, block an unsafe command, log, notify. | Work that needs judgment - hooks do not reason. |
| MCP servers | Connections that give Claude tools and data from other systems. | You keep copying data from a system Claude cannot see: a database, a tracker, a browser. | Teaching Claude how your team uses a tool; MCP supplies access, a Skill supplies know-how. |
| Plugins | A bundle of Skills, hooks, subagents and MCP servers you install. | A second repository or teammate needs the same setup. | A one-off setup in a single repository; plain project files are simpler. |
| Output styles | A session-wide setting for role, tone and response format. | You keep asking for shorter answers, more explanation, or a non-engineering role. | Project facts (CLAUDE.md) or guarantees (hooks). |
Sources
- Models overview - Anthropic (Claude Platform Docs)
- Introducing routines in Claude Code - Anthropic
- Routines (Claude Code docs) - Anthropic (Claude Code Docs)
- Extend Claude Code: features overview - Claude Code docs