hippo: Understanding how Claude Code works under the hood helps you anticipate its behavior, write sharper prompts, and know when to trust it versus when to stay hands-on.


1. What Is Claude Code?

Claude Code is not a code-completion plugin—it is an agentic framework. It wraps Claude models with a tool system, context management, and an execution environment, turning a language model into an agent that can actively read, edit, run, and verify code.

Characteristic Code Completion Agentic Coding (Claude Code)
Trigger You type, it autocompletes You state a goal, it executes
Input Scope Current file Entire codebase + conversation history
Output Code snippets End-to-end task results
Capabilities Writing code Reading and writing code, running commands, debugging, searching the web

hippo: This distinction matters—give it goals, not step-by-step instructions. Let Claude decide which tools to invoke and how to combine them.


2. Official Documentation Breakdown

2.1 The Agentic Loop and Tool System

When you hand Claude a task, it cycles through three phases: Gather context → Take action → Verify results. The loop repeats until the task is complete, and you can interrupt or steer it at any point.

Take “fix the failing tests” as an example. Claude runs through the workflow on its own:

  1. Run the test suite to see which tests fail (Execution tools)
  2. Read the error output to pinpoint the root cause (Search tools)
  3. Search and inspect the relevant source files (File operation tools)
  4. Edit files to fix the bug (File operation tools)
  5. Re-run the test suite to verify the fix (Execution tools)

Each step feeds directly into the next—that is the agentic loop in action.

Five core tool categories:

Category Capabilities
File operations Read, edit, create, and rename files
Search Find files by pattern, search contents with regex, explore the codebase
Execution Run shell commands, start servers, run tests, use git
Web Search the web, fetch documentation, look up error messages
Code intelligence Check type errors, jump to definitions, find references

On top of the core tools sit four extension layers: Skills (custom capabilities), MCP (external tool protocol), Hooks (lifecycle hooks), and Subagents (isolated child agents). They leave the underlying loop unchanged while expanding what Claude can reach.

2.2 Model Selection

Claude Code relies on Claude models to understand code and reason through tasks. Multiple models are available with clear trade-offs: Sonnet handles most day-to-day coding tasks well, while Opus delivers stronger reasoning for complex architectural decisions.

1
2
claude --model <name>    # Specify a model at launch
/model # Switch models mid-session

hippo: Sonnet is plenty for daily work. Switch to Opus for complex refactors or architecture design for better cost efficiency.

2.3 What Claude Can Access

When you run claude inside a directory, Claude Code gains access to:

  • Your project: Files in the current directory and its subdirectories, plus other locations with your permission
  • Your terminal: Any command you can run from the command line—build tools, git, package managers, system utilities, and scripts
  • Your git state: Current branch, uncommitted changes, and recent commit history
  • Your CLAUDE.md: Markdown file holding project rules, conventions, and context
  • Auto memory: Learnings Claude saves automatically as it works (project patterns and your preferences). The first 200 lines or 25KB of MEMORY.md (whichever comes first) load at the start of every session
  • Your configured extensions: MCP servers, Skills, Subagents, Claude in Chrome, and more

hippo: Seeing the entire project is what allows Claude to coordinate edits across multiple files—fundamentally different from file-scoped autocomplete.

2.4 Execution Environments and Interfaces

Claude Code runs in three execution environments, all powered by the same agentic loop:

Environment Where Code Runs Typical Use Cases
Local Your machine Default mode; full access to local files and tools
Cloud Anthropic-managed VM Working on repositories not cloned locally, offloading tasks
Remote Control Your machine, driven from a browser Operate via the web UI while keeping data local

Beyond the terminal, Claude Code also runs via the desktop app, IDE extensions, claude.ai/code, Slack integration, and CI/CD pipelines. The surface changes; the agentic loop stays the same.

2.5 Session Management and Context Window

Sessions are independent: Every new session starts with a clean context window and no prior conversation history. Cross-session persistence relies on two mechanisms—**CLAUDE.md** (project rules) and auto memory (the first 200 lines or 25KB of MEMORY.md, whichever comes first, loaded automatically at session start).

1
2
3
4
5
6
7
8
9
10
# Resume and fork sessions
claude --continue # Resume session with the same ID
claude --resume # Same as above
claude --continue --fork-session # Fork into a new ID, keeping history isolated

# Context management
/context # Inspect context usage
/compact # Compact manually
/compact focus on the API changes # Focused compaction to keep specific details
/mcp # Inspect context cost of MCP servers

Working across branches: Each Claude Code conversation is a session bound to the current directory, so resuming only lists sessions from that directory. Claude reads whatever files exist on the active branch—switching branches swaps the files on disk while leaving conversation history intact, so Claude still remembers what you discussed earlier.

Because sessions are scoped to directories, you can use git worktrees (creating separate directories for different branches) to run multiple Claude sessions in parallel.

hippo: Git worktrees are great for parallel work—have Claude build a feature in one worktree and fix a bug in another without stepping on each other’s toes.

Compaction when context fills up: As a session approaches the context limit, Claude Code manages space automatically—clearing older tool outputs first (such as verbose test logs), then summarizing earlier conversation turns while preserving your requests and key code. Durable rules belong in CLAUDE.md rather than conversation history.

Two ways to steer what compaction keeps:

  1. Add a “Compact Instructions” section to CLAUDE.md specifying what should survive compaction
  2. Run /compact focus on ... for targeted compaction—for example, /compact focus on the API changes

If a single file or tool output is so large that context immediately refills after each summary, Claude Code halts auto-compaction after a few attempts and raises a thrashing error to avoid an infinite loop. Use /context to inspect context usage and /mcp to check the context footprint of your MCP servers.

Skills vs. Subagents context behavior:

Mechanism Context Behavior Best Practice
Skills Descriptions load at session start (~100–500 tokens); full content loads on demand Set disable-model-invocation: true to prevent automatic loading
Subagents Isolated context window; does not consume main conversation space Isolate large tasks (such as refactoring an entire module)

2.6 Checkpoints and Permissions

Checkpoints act as Claude Code’s undo safety net: before every file edit, it automatically takes a snapshot, and pressing Esc twice rewinds to the previous checkpoint. Keep in mind that checkpoints only cover local files—they cannot roll back shell commands, database mutations, or remote API calls.

Four permission modes (cycle with Shift+Tab):

Mode File Edits Shell Commands Best For
Default Ask Ask New users, sensitive projects
Auto-accept edits Auto Auto-runs common filesystem commands like mkdir and mv; others still require confirmation Daily development
Plan Mode Disallowed Disallowed Planning complex tasks
Auto mode Auto Auto Research preview, high risk
1
2
3
4
5
6
7
8
9
10
// .claude/settings.json - Auto-allow specific commands without confirmation
{
"permissions": {
"allow": [
"Bash(npm test)",
"Bash(git status)",
"Bash(git diff)"
]
}
}
1
2
3
4
# Set permission mode from the CLI
claude --permission-mode plan # Plan Mode
claude --permission-mode accept # Auto-accept edits
claude --permission-mode default # Default

Permission settings follow three precedence scopes: Global (~/.claude/settings.json) < Project (.claude/settings.json) < CLI (--permission-mode), with later scopes overriding earlier ones.


3. Tips from the Official Docs

The official docs include a set of practical habits. Here are the ones that matter most in daily work:

3.1 Work Conversationally—Don’t Chase the Perfect Prompt

Claude Code is built for back-and-forth dialogue. You don’t need a flawless opening prompt—state what you want and iterate. If the first attempt misses the mark, don’t start over; point out what’s wrong and let Claude adjust. You can also interrupt mid-run whenever you want to steer the direction.

3.2 Give Claude a Way to Verify Its Work

Claude performs noticeably better when it can check its own output. Give it test cases, paste screenshots of the target UI, or define expected outputs. This pays off especially well for visual work—drop in a design mockup and ask Claude to compare its implementation against it.

3.3 Explore Before Implementing

For complex problems, separate research from coding. Enter Plan Mode (Shift+Tab twice) to analyze the codebase first, review the proposed plan, and only then execute. This two-phase workflow consistently beats jumping straight into edits.

3.4 Delegate Instead of Micromanaging

Treat Claude like a capable teammate—provide context and direction, then trust it to work out the details. You don’t need to dictate which files to open or which commands to run; Claude figures that out on its own.


4. Field Notes from Practice

hippo: Here are the pitfalls I ran into in real projects and the habits that fixed them:

4.1 Letting Context Fill Up Degrades Output

The biggest trap I hit was letting a single session drag on indefinitely. Once the context window fills up, Claude starts dropping earlier constraints and output quality degrades sharply.

My fix: After shipping a major feature, run /clear proactively. Before clearing, ask Claude to write a brief progress summary to a .md file, then have the fresh session read that file to pick up where you left off. It works far better than pushing through a bloated context.

4.2 Prompt Precision Makes a Big Difference

Vague Prompt Precise Prompt
“Optimize the code” “Replace this O(n²) sort with an O(n log n) implementation”
“Fix the bug” “Fix the TypeError on line 42 of login.ts caused by a missing undefined check”
“Add a feature” “Send a welcome email on user registration by reusing the existing mailer service”

The sharper your initial prompt, the fewer course corrections you’ll need later.

4.3 Explore First, and Always Plan Sensitive Operations

For complex tasks, I default to Plan Mode so Claude analyzes the codebase and lays out a plan for review before touching any files. This is critical for production configs, destructive deletions, and database migrations—checkpoints only protect local files, while remote side effects are irreversible.


5. Summary

Core principle: Give goals rather than step-by-step instructions, manage your context proactively, and always verify sensitive operations.


Series Navigation


Based on the official How Claude Code Works documentation.

Last updated: 2026-04-09