modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -91,7 +91,7 @@ #### When context fills up -Claude Code manages context automatically as you approach the limit. It compacts the conversation into a summary. The summary keeps your requests and key code snippets, but detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool. +Claude Code manages context automatically as you approach the [auto-compact window](</docs/en/model-config#context-window-and-auto-compaction>). It compacts the conversation into a summary. The summary keeps your requests and key code snippets, but detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool. #### Manage context with skills and subagents
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -64,7 +64,7 @@ ## Work with sessions -Claude Code saves your conversation locally as you work. Each message, tool use, and result is written to a plaintext JSONL file under `~/.claude/projects/`, which enables rewinding, resuming, and forking sessions. Before Claude makes code changes, it also snapshots the affected files so you can revert if needed. For paths, retention, and how to clear this data, see [application data in `~/.claude`](</docs/en/claude-directory#application-data>). **Sessions are independent.** Each new session starts with a fresh context window, without the conversation history from previous sessions. Claude can persist learnings across sessions using [auto memory](</docs/en/memory#auto-memory>), and you can add your own persistent instructions in [CLAUDE.md](</docs/en/memory>). +Claude Code saves your conversation locally as you work. Each message, tool use, and result is written to a plaintext JSONL file under `~/.claude/projects/`, which enables rewinding, resuming, and forking sessions. Claude Code also snapshots the files Claude edits. For paths, retention, and how to clear this data, see [application data in `~/.claude`](</docs/en/claude-directory#application-data>). **Sessions are independent.** Each new session starts with a fresh context window, without the conversation history from previous sessions. Claude can persist learnings across sessions using [auto memory](</docs/en/memory#auto-memory>), and you can add your own persistent instructions in [CLAUDE.md](</docs/en/memory>). ### Work across branches @@ -103,7 +103,7 @@ ### Undo changes with checkpoints -**File edits are reversible.** Before Claude edits a file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are separate from git and remain available when you resume a conversation. They only cover file changes, and a restore [skips symlinked and hard-linked files](</docs/en/checkpointing#symlinked-and-hard-linked-paths-not-restored>). Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed. You control those with your permission mode and permission rules. +Claude Code snapshots the files Claude edits so you can restore those files. See [checkpoint limitations](</docs/en/checkpointing#limitations>). If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are separate from git and remain available when you resume a conversation. They only cover file changes, and a restore [skips symlinked and hard-linked files](</docs/en/checkpointing#symlinked-and-hard-linked-paths-not-restored>). Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed. You control those with your permission mode and permission rules. ### Control what Claude can do
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -2,7 +2,7 @@ ## The agentic loop -When you give Claude a task, it works through three phases: **gather context** , **take action** , and **verify results**. These phases blend together. Claude uses tools throughout, whether searching files to understand your code, editing to make changes, or running tests to check its work. The loop adapts to what you ask. A question about your codebase might only need context gathering. A bug fix cycles through all three phases repeatedly. A refactor might involve extensive verification. Claude decides what each step requires based on what it learned from the previous step, chaining dozens of actions together and course-correcting along the way. You’re part of this loop too. You can interrupt at any point to steer Claude in a different direction, provide additional context, or ask it to try a different approach. Claude works autonomously but stays responsive to your input. The agentic loop is powered by two components: models that reason and tools that act. Claude Code is the layer around the model that provides the tools and manages the context the model sees. This surrounding layer is what the term agentic harness refers to. +When you give Claude a task, it works through three phases: **gather context** , **take action** , and **verify results**. These phases blend together. Claude uses tools throughout, whether searching files to understand your code, editing to make changes, or running tests to check its work. The loop adapts to what you ask. A question about your codebase might only need context gathering. A bug fix cycles through all three phases repeatedly. A refactor might involve extensive verification. Claude decides what each step requires based on what it learned from the previous step, chaining dozens of actions together and course-correcting along the way. You’re part of this loop too. You can interrupt at any point to steer Claude in a different direction, provide additional context, or ask it to try a different approach. The agentic loop is powered by two components: models that reason and tools that act. Claude Code is the layer around the model that provides the tools and manages the context the model sees. This surrounding layer is what the term agentic harness refers to. ### Models @@ -60,7 +60,7 @@ ### Interfaces -You can access Claude Code through the terminal, the [desktop app](</docs/en/desktop>), [IDE extensions](</docs/en/vs-code>), [claude.ai/code](<https://claude.ai/code>), [Remote Control](</docs/en/remote-control>), [Slack](</docs/en/slack>), and [CI/CD pipelines](</docs/en/github-actions>). The interface determines how you see and interact with Claude, but the underlying agentic loop is identical. See [Use Claude Code everywhere](</docs/en/overview#use-claude-code-everywhere>) for the full list. +You can access Claude Code through the terminal, the [desktop app](</docs/en/desktop>), [IDE extensions](</docs/en/vs-code>), [claude.ai/code](<https://claude.ai/code>), [Remote Control](</docs/en/remote-control>), and [CI/CD pipelines](</docs/en/github-actions>). The interface determines how you see and interact with Claude, but the underlying agentic loop is identical. See [Use Claude Code everywhere](</docs/en/overview#use-claude-code-everywhere>) for the list. ## Work with sessions @@ -91,7 +91,7 @@ #### When context fills up -Claude Code manages context automatically as you approach the limit. It compacts the conversation into a summary. The summary keeps your requests and key code snippets, but detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool. +Claude Code manages context automatically as you approach the limit. It compacts the conversation into a summary. The summary keeps your requests and key code snippets, but detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool. #### Manage context with skills and subagents
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -68,7 +68,7 @@ ### Work across branches -Each Claude Code conversation is a session tied to your current directory. The `/resume` picker shows sessions from the current worktree by default, with keyboard shortcuts to widen the list to other worktrees or projects. See [Manage sessions](</docs/en/sessions#use-the-session-picker>) for the full list of picker shortcuts and how name resolution works. Claude sees your current branch’s files. When you switch branches, Claude sees the new branch’s files, but your conversation history stays the same. Claude remembers what you discussed even after switching. Since sessions are tied to directories, you can run parallel Claude sessions by using [git worktrees](</docs/en/worktrees>), which create separate directories for individual branches. +Each Claude Code conversation is a session tied to your current directory. The `/resume` picker shows sessions from the current worktree by default, with keyboard shortcuts to widen the list to other worktrees or projects. See [Manage sessions](</docs/en/sessions#use-the-session-picker>) for the full list of picker shortcuts and how name resolution works. Claude sees your current branch’s files. When you switch branches, Claude sees the new branch’s files, but your conversation history stays the same. Since sessions are tied to directories, you can run parallel Claude sessions by using [git worktrees](</docs/en/worktrees>), which create separate directories for individual branches. ### Resume or fork sessions @@ -131,7 +131,7 @@ ### It’s a conversation -Claude Code is conversational. You don’t need perfect prompts. Start with what you want, then refine: +Claude Code is conversational, so start with what you want, then refine: Fix the login bug
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -39,7 +39,7 @@ * **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too. * **Your git state.** Current branch, uncommitted changes, and recent commit history. * **Your[CLAUDE.md](</docs/en/memory>).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session. If your repository has an AGENTS.md for other coding agents, Claude [can read that](</docs/en/memory#agents-md>) in place of a CLAUDE.md. - * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like your preferences. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at the start of each session. + * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like your preferences. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at session start while auto memory is on. * **Extensions you configure.** [MCP servers](</docs/en/mcp>) for external services, [skills](</docs/en/skills>) for workflows, [subagents](</docs/en/sub-agents>) for delegated work, and [Claude in Chrome](</docs/en/chrome>) for browser interaction. Because Claude sees your whole project, it can work across it. When you ask Claude to “fix the authentication bug,” it searches for relevant files, reads multiple files to understand context, makes coordinated edits across them, runs tests to verify the fix, and commits the changes if you ask. This is different from inline code assistants that only see the current file.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -84,7 +84,7 @@ * Your CLAUDE.md files * The instructions of your [output style](</docs/en/output-styles>) - * A note when a file Claude read earlier changes on disk + * A note that a file Claude edited earlier has since changed on disk * The commit and pull request attribution lines To change or remove the attribution lines, set [`attribution`](</docs/en/settings-reference#attribution>). To remove Claude Code’s built-in commit and pull request instructions, set [`includeGitInstructions`](</docs/en/settings-reference#includegitinstructions>) to `false`. For the other switches, see [Turn off the context your agent replaces](</docs/en/agent-sdk/modifying-system-prompts#turn-off-the-context-your-agent-replaces>).
modified
Show diff (246 lines)
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -1,26 +1,14 @@ Claude Code is an agentic assistant that runs in your terminal. While it excels at coding, it can help with anything you can do from the command line: writing docs, running builds, searching files, researching topics, and more. This guide covers the core architecture, built-in capabilities, and tips for working effectively. For step-by-step walkthroughs, see [Common workflows](</docs/en/common-workflows>). For extensibility features like skills, MCP, and hooks, see [Extend Claude Code](</docs/en/features-overview>). -## - -​ - -The agentic loop +## The agentic loop When you give Claude a task, it works through three phases: **gather context** , **take action** , and **verify results**. These phases blend together. Claude uses tools throughout, whether searching files to understand your code, editing to make changes, or running tests to check its work. The loop adapts to what you ask. A question about your codebase might only need context gathering. A bug fix cycles through all three phases repeatedly. A refactor might involve extensive verification. Claude decides what each step requires based on what it learned from the previous step, chaining dozens of actions together and course-correcting along the way. You’re part of this loop too. You can interrupt at any point to steer Claude in a different direction, provide additional context, or ask it to try a different approach. Claude works autonomously but stays responsive to your input. The agentic loop is powered by two components: models that reason and tools that act. Claude Code is the layer around the model that provides the tools and manages the context the model sees. This surrounding layer is what the term agentic harness refers to. -### - -​ - -Models +### Models Claude Code uses Claude models to understand your code and reason about tasks. Claude can read code in any language, understand how components connect, and figure out what needs to change to accomplish your goal. For complex tasks, it breaks work into steps, executes them, and adjusts based on what it learns. [Multiple models](</docs/en/model-config>) are available with different tradeoffs. Sonnet handles most coding tasks well. Opus provides stronger reasoning for complex architectural decisions. Switch with `/model` during a session or start with `claude --model <name>`. When this guide says “Claude chooses” or “Claude decides,” it’s the model doing the reasoning. -### - -​ - -Tools +### Tools Tools are what make Claude Code agentic. Without tools, Claude can only respond with text. With tools, Claude can act: read your code, edit files, run commands, search the web, and interact with external services. Each tool use returns information that feeds back into the loop, informing Claude’s next decision. The built-in tools generally fall into five categories, each representing a different kind of agency. @@ -43,11 +31,7 @@ Each tool use gives Claude new information that informs the next step. This is the agentic loop in action. **Extending the base capabilities:** The built-in tools are the foundation. You can extend what Claude knows with [skills](</docs/en/skills>), connect to external services with [MCP](</docs/en/mcp>), automate workflows with [hooks](</docs/en/hooks>), and offload tasks to [subagents](</docs/en/sub-agents>). These extensions form a layer on top of the core agentic loop. See [Extend Claude Code](</docs/en/features-overview>) for guidance on choosing the right extension for your needs. -## - -​ - -What Claude can access +## What Claude can access When you run `claude` in a directory, Claude Code gains access to: @@ -60,19 +44,11 @@ Because Claude sees your whole project, it can work across it. When you ask Claude to “fix the authentication bug,” it searches for relevant files, reads multiple files to understand context, makes coordinated edits across them, runs tests to verify the fix, and commits the changes if you ask. This is different from inline code assistants that only see the current file. -## - -​ - -Environments and interfaces +## Environments and interfaces The agentic loop, tools, and capabilities are the same everywhere you use Claude Code. What changes is where the code executes and how you interact with it. -### - -​ - -Execution environments +### Execution environments Claude Code runs in three environments, each with different tradeoffs for where your code executes. @@ -82,51 +58,27 @@ **Cloud**| Anthropic-managed VMs, or [self-hosted environments](</docs/en/self-hosted-environments>) your organization operates| Offload tasks, work on repos you don’t have locally **Remote Control**| Your machine, controlled from a browser| Use the web UI while execution and your files stay local -### - -​ - -Interfaces +### Interfaces You can access Claude Code through the terminal, the [desktop app](</docs/en/desktop>), [IDE extensions](</docs/en/vs-code>), [claude.ai/code](<https://claude.ai/code>), [Remote Control](</docs/en/remote-control>), [Slack](</docs/en/slack>), and [CI/CD pipelines](</docs/en/github-actions>). The interface determines how you see and interact with Claude, but the underlying agentic loop is identical. See [Use Claude Code everywhere](</docs/en/overview#use-claude-code-everywhere>) for the full list. -## - -​ - -Work with sessions +## Work with sessions Claude Code saves your conversation locally as you work. Each message, tool use, and result is written to a plaintext JSONL file under `~/.claude/projects/`, which enables rewinding, resuming, and forking sessions. Before Claude makes code changes, it also snapshots the affected files so you can revert if needed. For paths, retention, and how to clear this data, see [application data in `~/.claude`](</docs/en/claude-directory#application-data>). **Sessions are independent.** Each new session starts with a fresh context window, without the conversation history from previous sessions. Claude can persist learnings across sessions using [auto memory](</docs/en/memory#auto-memory>), and you can add your own persistent instructions in [CLAUDE.md](</docs/en/memory>). -### - -​ - -Work across branches +### Work across branches Each Claude Code conversation is a session tied to your current directory. The `/resume` picker shows sessions from the current worktree by default, with keyboard shortcuts to widen the list to other worktrees or projects. See [Manage sessions](</docs/en/sessions#use-the-session-picker>) for the full list of picker shortcuts and how name resolution works. Claude sees your current branch’s files. When you switch branches, Claude sees the new branch’s files, but your conversation history stays the same. Claude remembers what you discussed even after switching. Since sessions are tied to directories, you can run parallel Claude sessions by using [git worktrees](</docs/en/worktrees>), which create separate directories for individual branches. -### - -​ - -Resume or fork sessions +### Resume or fork sessions Resuming a session with `claude --continue` or `claude --resume` reopens it under the same session ID and appends new messages to the existing conversation. Forking with `--fork-session` or `/branch` copies the history into a new session ID, leaving the original unchanged. For the resume flags, the `/resume` picker, naming, and what happens when the same session is open in two terminals, see [Manage sessions](</docs/en/sessions>). -### - -​ - -The context window +### The context window Claude’s context window holds your conversation history, file contents, command outputs, [CLAUDE.md](</docs/en/memory>), [auto memory](</docs/en/memory#auto-memory>), loaded skills, and system instructions. As you work, context fills up. Claude compacts automatically, but instructions from early in the conversation can get lost. Put persistent rules in CLAUDE.md, and run `/context` to see what’s using space. For an interactive walkthrough of what loads and when, see [Explore the context window](</docs/en/context-window>). -#### - -​ - -Context Claude Code adds on its own +#### Context Claude Code adds on its own If Claude follows a rule you didn’t write, such as adding a `Co-Authored-By` trailer to a commit, the rule may have come from a [system reminder](</docs/en/glossary#system-reminder>). As you work, Claude Code adds its own context to the conversation alongside your messages: @@ -137,43 +89,23 @@ To change or remove the attribution lines, set [`attribution`](</docs/en/settings-reference#attribution>). To remove Claude Code’s built-in commit and pull request instructions, set [`includeGitInstructions`](</docs/en/settings-reference#includegitinstructions>) to `false`. For the other switches, see [Turn off the context your agent replaces](</docs/en/agent-sdk/modifying-system-prompts#turn-off-the-context-your-agent-replaces>). -#### - -​ - -When context fills up +#### When context fills up Claude Code manages context automatically as you approach the limit. It compacts the conversation into a summary. The summary keeps your requests and key code snippets, but detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool. -#### - -​ - -Manage context with skills and subagents +#### Manage context with skills and subagents Beyond compaction, you can use other features to control what loads into context. [Skills](</docs/en/skills>) load on demand. Claude sees skill descriptions at session start, but the full content only loads when a skill is used. For skills you invoke manually, set `disable-model-invocation: true` to keep descriptions out of context until you need them. For skills you didn’t write, use [`skillOverrides`](</docs/en/skills#override-skill-visibility-from-settings>) to do the same from settings. [Subagents](</docs/en/sub-agents>) work in their own context window. A subagent starts fresh unless it’s a [fork](</docs/en/sub-agents#fork-the-current-conversation>), which starts with a copy of your conversation so far. Either way, the subagent’s tool calls stay out of your context, and Claude gets back a summary when the subagent finishes. See [context costs](</docs/en/features-overview#understand-context-costs>) for what each feature costs, and [reduce token usage](</docs/en/costs#reduce-token-usage>) for tips on managing context. -## - -​ - -Stay safe with checkpoints and permissions +## Stay safe with checkpoints and permissions Claude has two safety mechanisms: checkpoints let you undo file changes, and permissions control what Claude can do without asking. -### - -​ - -Undo changes with checkpoints +### Undo changes with checkpoints **File edits are reversible.** Before Claude edits a file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are separate from git and remain available when you resume a conversation. They only cover file changes, and a restore [skips symlinked and hard-linked files](</docs/en/checkpointing#symlinked-and-hard-linked-paths-not-restored>). Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed. You control those with your permission mode and permission rules. -### - -​ - -Control what Claude can do +### Control what Claude can do Choose a permission mode to set what Claude can do without asking you. Press `Shift+Tab` to cycle through the permission modes: @@ -186,30 +118,18 @@ * * * -## - -​ - -Work effectively with Claude Code +## Work effectively with Claude Code These tips help you get better results from Claude Code. For more on specific prompts, verification, and the rules worth enforcing rather than prompting for, see [Best practices](</docs/en/best-practices>). -### - -​ - -Ask Claude Code for help +### Ask Claude Code for help Claude Code can teach you how to use it. Ask questions like “how do I set up hooks?” or “what’s the best way to structure my CLAUDE.md?” and Claude will explain. Built-in commands also guide you through setup: * `/init` generates a starter CLAUDE.md for your project * `/doctor` runs a setup checkup that diagnoses installation and configuration issues and can fix them -### - -​ - -It’s a conversation +### It’s a conversation Claude Code is conversational. You don’t need perfect prompts. Start with what you want, then refine: @@ -221,22 +141,14 @@ [Claude adjusts approach] When the first attempt isn’t right, you don’t start over. You iterate. -#### - -​ - -Interrupt and steer +#### Interrupt and steer You can redirect Claude at any point without starting over. Do either of these: * **Press`Esc`** to stop Claude immediately. The running tool call is canceled and Claude waits for your next instruction. If you have messages queued, Claude Code [sends them next](</docs/en/interactive-mode#queue-messages-while-claude-works>). * **Type a correction and press`Enter`** without stopping Claude. The message shows as queued in the conversation. If Claude is running tool calls, it reads the message as soon as those calls finish, within the same turn, and adjusts before its next step. [Queue messages while Claude works](</docs/en/interactive-mode#queue-messages-while-claude-works>) covers when other queued entries are sent. -### - -​ - -Delegate, don’t dictate +### Delegate, don’t dictate Think of delegating to a capable colleague. Give context and direction, then trust Claude to figure out the details: @@ -245,11 +157,7 @@ You don’t need to specify which files to read or what commands to run. Claude figures that out. -## - -​ - -What’s next +## What’s next ## Extend with features
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -177,7 +177,7 @@ Choose a permission mode to set what Claude can do without asking you. Press `Shift+Tab` to cycle through the permission modes: - * **Auto** : a classifier reviews most actions in the background and blocks the risky ones instead of asking you. With Claude Code v2.1.283 or later, it’s the [built-in starting permission mode](</docs/en/permission-modes#which-mode-a-session-starts-in>) for interactive terminal and VS Code sessions, and on earlier versions only on Pro, Max, and Team plans + * **Auto** : a classifier reviews most actions in the background and blocks the risky ones instead of asking you. With Claude Code v2.1.283 or later, it’s the [built-in starting permission mode](</docs/en/permission-modes#which-mode-a-session-starts-in>) for interactive terminal and VS Code sessions. On earlier versions, it’s the built-in starting permission mode only on Pro, Max, Ultra, and Team plans. * **Manual** : Claude asks before file edits and shell commands * **Accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands * **Plan** : Claude explores and proposes a plan without editing your source files
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -192,7 +192,7 @@ Work effectively with Claude Code -These tips help you get better results from Claude Code. For more on specific prompts, verification, and planning, see [Best practices](</docs/en/best-practices>). +These tips help you get better results from Claude Code. For more on specific prompts, verification, and the rules worth enforcing rather than prompting for, see [Best practices](</docs/en/best-practices>). ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -143,7 +143,7 @@ When context fills up -Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool. +Claude Code manages context automatically as you approach the limit. It compacts the conversation into a summary. The summary keeps your requests and key code snippets, but detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool. ####
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -54,7 +54,7 @@ * **Your project.** Files in your directory and subdirectories, plus files elsewhere with your permission. * **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too. * **Your git state.** Current branch, uncommitted changes, and recent commit history. - * **Your[CLAUDE.md](</docs/en/memory>).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session. If your repository has an AGENTS.md for other coding agents, Claude [can read that](</docs/en/memory#agents-md>) on its own or alongside CLAUDE.md. + * **Your[CLAUDE.md](</docs/en/memory>).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session. If your repository has an AGENTS.md for other coding agents, Claude [can read that](</docs/en/memory#agents-md>) in place of a CLAUDE.md. * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like your preferences. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at the start of each session. * **Extensions you configure.** [MCP servers](</docs/en/mcp>) for external services, [skills](</docs/en/skills>) for workflows, [subagents](</docs/en/sub-agents>) for delegated work, and [Claude in Chrome](</docs/en/chrome>) for browser interaction.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -126,6 +126,21 @@ ​ +Context Claude Code adds on its own + +If Claude follows a rule you didn’t write, such as adding a `Co-Authored-By` trailer to a commit, the rule may have come from a [system reminder](</docs/en/glossary#system-reminder>). As you work, Claude Code adds its own context to the conversation alongside your messages: + + * Your CLAUDE.md files + * The instructions of your [output style](</docs/en/output-styles>) + * A note when a file Claude read earlier changes on disk + * The commit and pull request attribution lines + +To change or remove the attribution lines, set [`attribution`](</docs/en/settings-reference#attribution>). To remove Claude Code’s built-in commit and pull request instructions, set [`includeGitInstructions`](</docs/en/settings-reference#includegitinstructions>) to `false`. For the other switches, see [Turn off the context your agent replaces](</docs/en/agent-sdk/modifying-system-prompts#turn-off-the-context-your-agent-replaces>). + +#### + +​ + When context fills up Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -162,7 +162,7 @@ Choose a permission mode to set what Claude can do without asking you. Press `Shift+Tab` to cycle through the permission modes: - * **Auto** : a classifier reviews most actions in the background and blocks the risky ones instead of asking you. On Pro, Max, and Team plans, it’s the [built-in starting permission mode](</docs/en/permission-modes#which-mode-a-session-starts-in>) for interactive terminal and VS Code sessions + * **Auto** : a classifier reviews most actions in the background and blocks the risky ones instead of asking you. With Claude Code v2.1.283 or later, it’s the [built-in starting permission mode](</docs/en/permission-modes#which-mode-a-session-starts-in>) for interactive terminal and VS Code sessions, and on earlier versions only on Pro, Max, and Team plans * **Manual** : Claude asks before file edits and shell commands * **Accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands * **Plan** : Claude explores and proposes a plan without editing your source files @@ -215,7 +215,7 @@ You can redirect Claude at any point without starting over. Do either of these: * **Press`Esc`** to stop Claude immediately. The running tool call is canceled and Claude waits for your next instruction. If you have messages queued, Claude Code [sends them next](</docs/en/interactive-mode#queue-messages-while-claude-works>). - * **Type a correction and press`Enter`** without stopping Claude. The message shows as queued above the input box. If Claude is running tool calls, it reads the message as soon as those calls finish, within the same turn, and adjusts before its next step. [Queue messages while Claude works](</docs/en/interactive-mode#queue-messages-while-claude-works>) covers when other queued entries are sent. + * **Type a correction and press`Enter`** without stopping Claude. The message shows as queued in the conversation. If Claude is running tool calls, it reads the message as soon as those calls finish, within the same turn, and adjusts before its next step. [Queue messages while Claude works](</docs/en/interactive-mode#queue-messages-while-claude-works>) covers when other queued entries are sent. ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -30,7 +30,7 @@ **Search**| Find files by pattern, search content with regex, explore codebases **Execution**| Run shell commands, start servers, run tests, use git **Web**| Search the web, fetch documentation, look up error messages -**Code intelligence**| See type errors and warnings after edits, jump to definitions, find references (requires [code intelligence plugins](</docs/en/discover-plugins#code-intelligence>)) +**Code intelligence**| See type errors and warnings after edits, jump to definitions, find references (requires [code intelligence plugins](</docs/en/plugins/code-intelligence>)) These are the primary capabilities. Claude also has tools for spawning subagents, asking you questions, and other orchestration tasks. See [Tools available to Claude](</docs/en/tools-reference>) for the complete list. Claude chooses which tools to use based on your prompt and what it learns along the way. When you say “fix the failing tests,” Claude might:
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -6,7 +6,7 @@ The agentic loop -When you give Claude a task, it works through three phases: **gather context** , **take action** , and **verify results**. These phases blend together. Claude uses tools throughout, whether searching files to understand your code, editing to make changes, or running tests to check its work. The loop adapts to what you ask. A question about your codebase might only need context gathering. A bug fix cycles through all three phases repeatedly. A refactor might involve extensive verification. Claude decides what each step requires based on what it learned from the previous step, chaining dozens of actions together and course-correcting along the way. You’re part of this loop too. You can interrupt at any point to steer Claude in a different direction, provide additional context, or ask it to try a different approach. Claude works autonomously but stays responsive to your input. The agentic loop is powered by two components: models that reason and tools that act. Claude Code serves as the **agentic harness** around Claude: it provides the tools, context management, and execution environment that turn a language model into a capable coding agent. +When you give Claude a task, it works through three phases: **gather context** , **take action** , and **verify results**. These phases blend together. Claude uses tools throughout, whether searching files to understand your code, editing to make changes, or running tests to check its work. The loop adapts to what you ask. A question about your codebase might only need context gathering. A bug fix cycles through all three phases repeatedly. A refactor might involve extensive verification. Claude decides what each step requires based on what it learned from the previous step, chaining dozens of actions together and course-correcting along the way. You’re part of this loop too. You can interrupt at any point to steer Claude in a different direction, provide additional context, or ask it to try a different approach. Claude works autonomously but stays responsive to your input. The agentic loop is powered by two components: models that reason and tools that act. Claude Code is the layer around the model that provides the tools and manages the context the model sees. This surrounding layer is what the term agentic harness refers to. ### @@ -212,10 +212,10 @@ Interrupt and steer -You can redirect Claude at any point without waiting for the turn to finish or starting over: +You can redirect Claude at any point without starting over. Do either of these: * **Press`Esc`** to stop Claude immediately. The running tool call is canceled and Claude waits for your next instruction. If you have messages queued, Claude Code [sends them next](</docs/en/interactive-mode#queue-messages-while-claude-works>). - * **Type a correction and press`Enter`** to send it without stopping the running tool. Claude reads it as soon as the current action completes and adjusts before deciding its next step. + * **Type a correction and press`Enter`** without stopping Claude. The message shows as queued above the input box. If Claude is running tool calls, it reads the message as soon as those calls finish, within the same turn, and adjusts before its next step. [Queue messages while Claude works](</docs/en/interactive-mode#queue-messages-while-claude-works>) covers when other queued entries are sent. ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -54,7 +54,7 @@ * **Your project.** Files in your directory and subdirectories, plus files elsewhere with your permission. * **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too. * **Your git state.** Current branch, uncommitted changes, and recent commit history. - * **Your[CLAUDE.md](</docs/en/memory>).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session. + * **Your[CLAUDE.md](</docs/en/memory>).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session. If your repository has an AGENTS.md for other coding agents, Claude [can read that](</docs/en/memory#agents-md>) on its own or alongside CLAUDE.md. * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like your preferences. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at the start of each session. * **Extensions you configure.** [MCP servers](</docs/en/mcp>) for external services, [skills](</docs/en/skills>) for workflows, [subagents](</docs/en/sub-agents>) for delegated work, and [Claude in Chrome](</docs/en/chrome>) for browser interaction.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -66,7 +66,7 @@ Environments and interfaces -The agentic loop, tools, and capabilities described above are the same everywhere you use Claude Code. What changes is where the code executes and how you interact with it. +The agentic loop, tools, and capabilities are the same everywhere you use Claude Code. What changes is where the code executes and how you interact with it. ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -187,7 +187,7 @@ Claude Code can teach you how to use it. Ask questions like “how do I set up hooks?” or “what’s the best way to structure my CLAUDE.md?” and Claude will explain. Built-in commands also guide you through setup: - * `/init` walks you through creating a CLAUDE.md for your project + * `/init` generates a starter CLAUDE.md for your project * `/doctor` runs a setup checkup that diagnoses installation and configuration issues and can fix them ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -177,7 +177,7 @@ Work effectively with Claude Code -These tips help you get better results from Claude Code. +These tips help you get better results from Claude Code. For more on specific prompts, verification, and planning, see [Best practices](</docs/en/best-practices>). ### @@ -221,46 +221,6 @@ ​ -Be specific upfront - -The more precise your initial prompt, the fewer corrections you’ll need. Reference specific files, mention constraints, and point to example patterns. - - The checkout flow is broken for users with expired cards. - Check src/payments/ for the issue, especially token refresh. - Write a failing test first, then fix it. - -Vague prompts work, but you’ll spend more time steering. Specific prompts like the one above often succeed on the first attempt. - -### - -​ - -Give Claude something to verify against - -Claude performs better when it can check its own work. Include test cases, paste screenshots of expected UI, or define the output you want. - - Implement validateEmail. Test cases: 'user@example.com' → true, - 'invalid' → false, 'user@.com' → false. Run the tests after. - -For visual work, paste a screenshot of the design and ask Claude to compare its implementation against it. - -### - -​ - -Explore before implementing - -For complex problems, separate research from coding. Press `Shift+Tab` until the status bar shows `⏸ plan mode on`, then ask Claude to analyze the codebase first: - - Read src/auth/ and understand how we handle sessions. - Then create a plan for adding OAuth support. - -Review the plan, refine it through conversation, then let Claude implement. This two-phase approach produces better results than jumping straight to code. - -### - -​ - Delegate, don’t dictate Think of delegating to a capable colleague. Give context and direction, then trust Claude to figure out the details:
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -55,7 +55,7 @@ * **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too. * **Your git state.** Current branch, uncommitted changes, and recent commit history. * **Your[CLAUDE.md](</docs/en/memory>).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session. - * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like project patterns and your preferences. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at the start of each session. + * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like your preferences. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at the start of each session. * **Extensions you configure.** [MCP servers](</docs/en/mcp>) for external services, [skills](</docs/en/skills>) for workflows, [subagents](</docs/en/sub-agents>) for delegated work, and [Claude in Chrome](</docs/en/chrome>) for browser interaction. Because Claude sees your whole project, it can work across it. When you ask Claude to “fix the authentication bug,” it searches for relevant files, reads multiple files to understand context, makes coordinated edits across them, runs tests to verify the fix, and commits the changes if you ask. This is different from inline code assistants that only see the current file. @@ -128,7 +128,7 @@ When context fills up -Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names consume context until Claude uses a specific tool. Run `/mcp` to check per-server costs. +Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names and server instructions consume context until Claude uses a specific tool. #### @@ -278,7 +278,7 @@ ## Extend with features -Add Skills, MCP connections, and custom commands +Add skills and MCP connections ## Common workflows
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -136,7 +136,7 @@ Manage context with skills and subagents -Beyond compaction, you can use other features to control what loads into context. [Skills](</docs/en/skills>) load on demand. Claude sees skill descriptions at session start, but the full content only loads when a skill is used. For skills you invoke manually, set `disable-model-invocation: true` to keep descriptions out of context until you need them. For skills you didn’t write, use [`skillOverrides`](</docs/en/skills#override-skill-visibility-from-settings>) to do the same from settings. [Subagents](</docs/en/sub-agents>) get their own fresh context, completely separate from your main conversation. Their work doesn’t bloat your context. When done, they return a summary. This isolation is why subagents help with long sessions. See [context costs](</docs/en/features-overview#understand-context-costs>) for what each feature costs, and [reduce token usage](</docs/en/costs#reduce-token-usage>) for tips on managing context. +Beyond compaction, you can use other features to control what loads into context. [Skills](</docs/en/skills>) load on demand. Claude sees skill descriptions at session start, but the full content only loads when a skill is used. For skills you invoke manually, set `disable-model-invocation: true` to keep descriptions out of context until you need them. For skills you didn’t write, use [`skillOverrides`](</docs/en/skills#override-skill-visibility-from-settings>) to do the same from settings. [Subagents](</docs/en/sub-agents>) work in their own context window. A subagent starts fresh unless it’s a [fork](</docs/en/sub-agents#fork-the-current-conversation>), which starts with a copy of your conversation so far. Either way, the subagent’s tool calls stay out of your context, and Claude gets back a summary when the subagent finishes. See [context costs](</docs/en/features-overview#understand-context-costs>) for what each feature costs, and [reduce token usage](</docs/en/costs#reduce-token-usage>) for tips on managing context. ## @@ -152,7 +152,7 @@ Undo changes with checkpoints -**File edits are reversible.** Before Claude edits a file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are separate from git and remain available when you resume a conversation. They only cover file changes, and a restore [skips symlinked and hard-linked files](</docs/en/checkpointing#symlinked-and-hard-linked-paths-not-restored>). Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed, which is why Claude asks before running commands with external side effects. +**File edits are reversible.** Before Claude edits a file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are separate from git and remain available when you resume a conversation. They only cover file changes, and a restore [skips symlinked and hard-linked files](</docs/en/checkpointing#symlinked-and-hard-linked-paths-not-restored>). Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed. You control those with your permission mode and permission rules. ### @@ -160,12 +160,12 @@ Control what Claude can do -Press `Shift+Tab` to cycle through permission modes: - +Choose a permission mode to set what Claude can do without asking you. Press `Shift+Tab` to cycle through the permission modes: + + * **Auto** : a classifier reviews most actions in the background and blocks the risky ones instead of asking you. On Pro, Max, and Team plans, it’s the [built-in starting permission mode](</docs/en/permission-modes#which-mode-a-session-starts-in>) for interactive terminal and VS Code sessions * **Manual** : Claude asks before file edits and shell commands * **Accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands * **Plan** : Claude explores and proposes a plan without editing your source files - * **Auto** : Claude evaluates all actions with background safety checks You can also allow specific commands in `.claude/settings.json` so Claude doesn’t ask each time. This is useful for trusted commands like `npm test` or `git status`. Settings can be scoped from organization-wide policies down to personal preferences. See [Permissions](</docs/en/permissions>) for details. @@ -214,7 +214,7 @@ You can redirect Claude at any point without waiting for the turn to finish or starting over: - * **Press`Esc`** to stop Claude immediately. The running tool call is canceled and Claude waits for your next instruction. + * **Press`Esc`** to stop Claude immediately. The running tool call is canceled and Claude waits for your next instruction. If you have messages queued, Claude Code [sends them next](</docs/en/interactive-mode#queue-messages-while-claude-works>). * **Type a correction and press`Enter`** to send it without stopping the running tool. Claude reads it as soon as the current action completes and adjusts before deciding its next step. ### @@ -250,7 +250,7 @@ Explore before implementing -For complex problems, separate research from coding. Use plan mode (`Shift+Tab` twice) to analyze the codebase first: +For complex problems, separate research from coding. Press `Shift+Tab` until the status bar shows `⏸ plan mode on`, then ask Claude to analyze the codebase first: Read src/auth/ and understand how we handle sessions. Then create a plan for adding OAuth support.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -49,7 +49,7 @@ What Claude can access -This guide focuses on the terminal. Claude Code also runs in [VS Code](</docs/en/vs-code>), [JetBrains IDEs](</docs/en/jetbrains>), and other environments. When you run `claude` in a directory, Claude Code gains access to: +When you run `claude` in a directory, Claude Code gains access to: * **Your project.** Files in your directory and subdirectories, plus files elsewhere with your permission. * **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -79,7 +79,7 @@ Environment| Where code runs| Use case ---|---|--- **Local**| Your machine| Default. Full access to your files, tools, and environment -**Cloud**| Anthropic-managed VMs| Offload tasks, work on repos you don’t have locally +**Cloud**| Anthropic-managed VMs, or [self-hosted environments](</docs/en/self-hosted-environments>) your organization operates| Offload tasks, work on repos you don’t have locally **Remote Control**| Your machine, controlled from a browser| Use the web UI while execution and your files stay local ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -152,7 +152,7 @@ Undo changes with checkpoints -**Every file edit is reversible.** Before Claude edits any file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are separate from git and remain available when you resume a conversation. They only cover file changes. Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed, which is why Claude asks before running commands with external side effects. +**File edits are reversible.** Before Claude edits a file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are separate from git and remain available when you resume a conversation. They only cover file changes, and a restore [skips symlinked and hard-linked files](</docs/en/checkpointing#symlinked-and-hard-linked-paths-not-restored>). Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed, which is why Claude asks before running commands with external side effects. ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -80,7 +80,7 @@ ---|---|--- **Local**| Your machine| Default. Full access to your files, tools, and environment **Cloud**| Anthropic-managed VMs| Offload tasks, work on repos you don’t have locally -**Remote Control**| Your machine, controlled from a browser| Use the web UI while keeping everything local +**Remote Control**| Your machine, controlled from a browser| Use the web UI while execution and your files stay local ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -152,7 +152,7 @@ Undo changes with checkpoints -**Every file edit is reversible.** Before Claude edits any file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are local to your session, separate from git. They only cover file changes. Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed, which is why Claude asks before running commands with external side effects. +**Every file edit is reversible.** Before Claude edits any file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are separate from git and remain available when you resume a conversation. They only cover file changes. Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed, which is why Claude asks before running commands with external side effects. ### @@ -164,7 +164,7 @@ * **Manual** : Claude asks before file edits and shell commands * **Accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands - * **Plan** : Claude explores and proposes a plan without editing your source files; permission prompts still apply as in Manual mode + * **Plan** : Claude explores and proposes a plan without editing your source files * **Auto** : Claude evaluates all actions with background safety checks You can also allow specific commands in `.claude/settings.json` so Claude doesn’t ask each time. This is useful for trusted commands like `npm test` or `git status`. Settings can be scoped from organization-wide policies down to personal preferences. See [Permissions](</docs/en/permissions>) for details.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -165,7 +165,7 @@ * **Manual** : Claude asks before file edits and shell commands * **Accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands * **Plan** : Claude explores and proposes a plan without editing your source files; permission prompts still apply as in Manual mode - * **Auto** : Claude evaluates all actions with background safety checks. Currently a research preview + * **Auto** : Claude evaluates all actions with background safety checks You can also allow specific commands in `.claude/settings.json` so Claude doesn’t ask each time. This is useful for trusted commands like `npm test` or `git status`. Settings can be scoped from organization-wide policies down to personal preferences. See [Permissions](</docs/en/permissions>) for details.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -162,10 +162,10 @@ Press `Shift+Tab` to cycle through permission modes: - * **Default** : Claude asks before file edits and shell commands - * **Auto-accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands - * **Plan mode** : Claude explores and proposes a plan without editing your source files; permission prompts still apply as in default mode - * **Auto mode** : Claude evaluates all actions with background safety checks. Currently a research preview + * **Manual** : Claude asks before file edits and shell commands + * **Accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands + * **Plan** : Claude explores and proposes a plan without editing your source files; permission prompts still apply as in Manual mode + * **Auto** : Claude evaluates all actions with background safety checks. Currently a research preview You can also allow specific commands in `.claude/settings.json` so Claude doesn’t ask each time. This is useful for trusted commands like `npm test` or `git status`. Settings can be scoped from organization-wide policies down to personal preferences. See [Permissions](</docs/en/permissions>) for details. @@ -188,7 +188,7 @@ Claude Code can teach you how to use it. Ask questions like “how do I set up hooks?” or “what’s the best way to structure my CLAUDE.md?” and Claude will explain. Built-in commands also guide you through setup: * `/init` walks you through creating a CLAUDE.md for your project - * `/doctor` diagnoses common issues with your installation + * `/doctor` runs a setup checkup that diagnoses installation and configuration issues and can fix them ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -188,7 +188,6 @@ Claude Code can teach you how to use it. Ask questions like “how do I set up hooks?” or “what’s the best way to structure my CLAUDE.md?” and Claude will explain. Built-in commands also guide you through setup: * `/init` walks you through creating a CLAUDE.md for your project - * `/agents` helps you configure custom subagents * `/doctor` diagnoses common issues with your installation ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -164,7 +164,7 @@ * **Default** : Claude asks before file edits and shell commands * **Auto-accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands - * **Plan mode** : Claude uses read-only tools only, creating a plan you can approve before execution + * **Plan mode** : Claude explores and proposes a plan without editing your source files; permission prompts still apply as in default mode * **Auto mode** : Claude evaluates all actions with background safety checks. Currently a research preview You can also allow specific commands in `.claude/settings.json` so Claude doesn’t ask each time. This is useful for trusted commands like `npm test` or `git status`. Settings can be scoped from organization-wide policies down to personal preferences. See [Permissions](</docs/en/permissions>) for details.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -1,9 +1,3 @@ -> ## Documentation Index -> -> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> -> -> Use this file to discover all available pages before exploring further. - Claude Code is an agentic assistant that runs in your terminal. While it excels at coding, it can help with anything you can do from the command line: writing docs, running builds, searching files, researching topics, and more. This guide covers the core architecture, built-in capabilities, and tips for working effectively. For step-by-step walkthroughs, see [Common workflows](</docs/en/common-workflows>). For extensibility features like skills, MCP, and hooks, see [Extend Claude Code](</docs/en/features-overview>). ##
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -219,7 +219,10 @@ Interrupt and steer -You can interrupt Claude at any point. If it’s going down the wrong path, just type your correction and press Enter. Claude will stop what it’s doing and adjust its approach based on your input. You don’t have to wait for it to finish or start over. +You can redirect Claude at any point without waiting for the turn to finish or starting over: + + * **Press`Esc`** to stop Claude immediately. The running tool call is canceled and Claude waits for your next instruction. + * **Type a correction and press`Enter`** to send it without stopping the running tool. Claude reads it as soon as the current action completes and adjusts before deciding its next step. ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -142,7 +142,7 @@ Manage context with skills and subagents -Beyond compaction, you can use other features to control what loads into context. [Skills](</docs/en/skills>) load on demand. Claude sees skill descriptions at session start, but the full content only loads when a skill is used. For skills you invoke manually, set `disable-model-invocation: true` to keep descriptions out of context until you need them. [Subagents](</docs/en/sub-agents>) get their own fresh context, completely separate from your main conversation. Their work doesn’t bloat your context. When done, they return a summary. This isolation is why subagents help with long sessions. See [context costs](</docs/en/features-overview#understand-context-costs>) for what each feature costs, and [reduce token usage](</docs/en/costs#reduce-token-usage>) for tips on managing context. +Beyond compaction, you can use other features to control what loads into context. [Skills](</docs/en/skills>) load on demand. Claude sees skill descriptions at session start, but the full content only loads when a skill is used. For skills you invoke manually, set `disable-model-invocation: true` to keep descriptions out of context until you need them. For skills you didn’t write, use [`skillOverrides`](</docs/en/skills#override-skill-visibility-from-settings>) to do the same from settings. [Subagents](</docs/en/sub-agents>) get their own fresh context, completely separate from your main conversation. Their work doesn’t bloat your context. When done, they return a summary. This isolation is why subagents help with long sessions. See [context costs](</docs/en/features-overview#understand-context-costs>) for what each feature costs, and [reduce token usage](</docs/en/costs#reduce-token-usage>) for tips on managing context. ##
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -110,7 +110,7 @@ Work across branches -Each Claude Code conversation is a session tied to your current directory. The `/resume` picker shows sessions from the current worktree by default, with keyboard shortcuts to widen the list to other worktrees or projects. See [Resume previous conversations](</docs/en/common-workflows#resume-previous-conversations>) for the full list of picker shortcuts and how name resolution works. Claude sees your current branch’s files. When you switch branches, Claude sees the new branch’s files, but your conversation history stays the same. Claude remembers what you discussed even after switching. Since sessions are tied to directories, you can run parallel Claude sessions by using [git worktrees](</docs/en/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees>), which create separate directories for individual branches. +Each Claude Code conversation is a session tied to your current directory. The `/resume` picker shows sessions from the current worktree by default, with keyboard shortcuts to widen the list to other worktrees or projects. See [Manage sessions](</docs/en/sessions#use-the-session-picker>) for the full list of picker shortcuts and how name resolution works. Claude sees your current branch’s files. When you switch branches, Claude sees the new branch’s files, but your conversation history stays the same. Claude remembers what you discussed even after switching. Since sessions are tied to directories, you can run parallel Claude sessions by using [git worktrees](</docs/en/worktrees>), which create separate directories for individual branches. ### @@ -118,11 +118,7 @@ Resume or fork sessions -When you resume a session with `claude --continue` or `claude --resume`, you pick up where you left off using the same session ID. New messages append to the existing conversation. Your full conversation history is restored, but session-scoped permissions are not. You’ll need to re-approve those. To branch off and try a different approach without affecting the original session, use the `--fork-session` flag: - - claude --continue --fork-session - -This creates a new session ID while preserving the conversation history up to that point. The original session remains unchanged. Like resume, forked sessions don’t inherit session-scoped permissions. **Same session in multiple terminals** : If you resume the same session in multiple terminals, both terminals write to the same session file. Messages from both get interleaved, like two people writing in the same notebook. Nothing corrupts, but the conversation becomes jumbled. Each terminal only sees its own messages during the session, but if you resume that session later, you’ll see everything interleaved. For parallel work from the same starting point, use `--fork-session` to give each terminal its own clean session. +Resuming a session with `claude --continue` or `claude --resume` reopens it under the same session ID and appends new messages to the existing conversation. Forking with `--fork-session` or `/branch` copies the history into a new session ID, leaving the original unchanged. For the resume flags, the `/resume` picker, naming, and what happens when the same session is open in two terminals, see [Manage sessions](</docs/en/sessions>). ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -1,3 +1,9 @@ +> ## Documentation Index +> +> Fetch the complete documentation index at: <https://code.claude.com/docs/llms.txt> +> +> Use this file to discover all available pages before exploring further. + Claude Code is an agentic assistant that runs in your terminal. While it excels at coding, it can help with anything you can do from the command line: writing docs, running builds, searching files, researching topics, and more. This guide covers the core architecture, built-in capabilities, and tips for working effectively. For step-by-step walkthroughs, see [Common workflows](</docs/en/common-workflows>). For extensibility features like skills, MCP, and hooks, see [Extend Claude Code](</docs/en/features-overview>). ##
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -104,7 +104,7 @@ Work across branches -Each Claude Code conversation is a session tied to your current directory. When you resume, you only see sessions from that directory. Claude sees your current branch’s files. When you switch branches, Claude sees the new branch’s files, but your conversation history stays the same. Claude remembers what you discussed even after switching. Since sessions are tied to directories, you can run parallel Claude sessions by using [git worktrees](</docs/en/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees>), which create separate directories for individual branches. +Each Claude Code conversation is a session tied to your current directory. The `/resume` picker shows sessions from the current worktree by default, with keyboard shortcuts to widen the list to other worktrees or projects. See [Resume previous conversations](</docs/en/common-workflows#resume-previous-conversations>) for the full list of picker shortcuts and how name resolution works. Claude sees your current branch’s files. When you switch branches, Claude sees the new branch’s files, but your conversation history stays the same. Claude remembers what you discussed even after switching. Since sessions are tied to directories, you can run parallel Claude sessions by using [git worktrees](</docs/en/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees>), which create separate directories for individual branches. ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -241,8 +241,8 @@ Claude performs better when it can check its own work. Include test cases, paste screenshots of expected UI, or define the output you want. - Implement validateEmail. Test cases: '[[email protected]](</cdn-cgi/l/email-protection>)' → true, - 'invalid' → false, '[[email protected]](</cdn-cgi/l/email-protection>)' → false. Run the tests after. + Implement validateEmail. Test cases: 'user@example.com' → true, + 'invalid' → false, 'user@.com' → false. Run the tests after. For visual work, paste a screenshot of the design and ask Claude to compare its implementation against it.
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -132,7 +132,7 @@ When context fills up -Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names consume context until Claude uses a specific tool. Run `/mcp` to check per-server costs. +Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). If a single file or tool output is so large that context refills immediately after each summary, Claude Code stops auto-compacting after a few attempts and shows an error instead of looping. See [Auto-compaction stops with a thrashing error](</docs/en/troubleshooting#auto-compaction-stops-with-a-thrashing-error>) for recovery steps. Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names consume context until Claude uses a specific tool. Run `/mcp` to check per-server costs. #### @@ -167,7 +167,7 @@ Press `Shift+Tab` to cycle through permission modes: * **Default** : Claude asks before file edits and shell commands - * **Auto-accept edits** : Claude edits files without asking, still asks for commands + * **Auto-accept edits** : Claude edits files and runs common filesystem commands like `mkdir` and `mv` without asking, still asks for other commands * **Plan mode** : Claude uses read-only tools only, creating a plan you can approve before execution * **Auto mode** : Claude evaluates all actions with background safety checks. Currently a research preview
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -96,7 +96,7 @@ Work with sessions -Claude Code saves your conversation locally as you work. Each message, tool use, and result is stored, which enables rewinding, resuming, and forking sessions. Before Claude makes code changes, it also snapshots the affected files so you can revert if needed. **Sessions are independent.** Each new session starts with a fresh context window, without the conversation history from previous sessions. Claude can persist learnings across sessions using [auto memory](</docs/en/memory#auto-memory>), and you can add your own persistent instructions in [CLAUDE.md](</docs/en/memory>). +Claude Code saves your conversation locally as you work. Each message, tool use, and result is written to a plaintext JSONL file under `~/.claude/projects/`, which enables rewinding, resuming, and forking sessions. Before Claude makes code changes, it also snapshots the affected files so you can revert if needed. For paths, retention, and how to clear this data, see [application data in `~/.claude`](</docs/en/claude-directory#application-data>). **Sessions are independent.** Each new session starts with a fresh context window, without the conversation history from previous sessions. Claude can persist learnings across sessions using [auto memory](</docs/en/memory#auto-memory>), and you can add your own persistent instructions in [CLAUDE.md](</docs/en/memory>). ###
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -88,7 +88,7 @@ Interfaces -You can access Claude Code through the terminal, the [desktop app](</docs/en/desktop>), [IDE extensions](</docs/en/ide-integrations>), [claude.ai/code](<https://claude.ai/code>), [Remote Control](</docs/en/remote-control>), [Slack](</docs/en/slack>), and [CI/CD pipelines](</docs/en/github-actions>). The interface determines how you see and interact with Claude, but the underlying agentic loop is identical. See [Use Claude Code everywhere](</docs/en/overview#use-claude-code-everywhere>) for the full list. +You can access Claude Code through the terminal, the [desktop app](</docs/en/desktop>), [IDE extensions](</docs/en/vs-code>), [claude.ai/code](<https://claude.ai/code>), [Remote Control](</docs/en/remote-control>), [Slack](</docs/en/slack>), and [CI/CD pipelines](</docs/en/github-actions>). The interface determines how you see and interact with Claude, but the underlying agentic loop is identical. See [Use Claude Code everywhere](</docs/en/overview#use-claude-code-everywhere>) for the full list. ##
modified
Show diff (117 lines)
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -55,7 +55,7 @@ * **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too. * **Your git state.** Current branch, uncommitted changes, and recent commit history. * **Your[CLAUDE.md](</docs/en/memory>).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session. - * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like project patterns and your preferences. The first 200 lines of MEMORY.md are loaded at the start of each session. + * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like project patterns and your preferences. The first 200 lines or 25KB of MEMORY.md, whichever comes first, load at the start of each session. * **Extensions you configure.** [MCP servers](</docs/en/mcp>) for external services, [skills](</docs/en/skills>) for workflows, [subagents](</docs/en/sub-agents>) for delegated work, and [Claude in Chrome](</docs/en/chrome>) for browser interaction. Because Claude sees your whole project, it can work across it. When you ask Claude to “fix the authentication bug,” it searches for relevant files, reads multiple files to understand context, makes coordinated edits across them, runs tests to verify the fix, and commits the changes if you ask. This is different from inline code assistants that only see the current file. @@ -114,12 +114,6 @@ When you resume a session with `claude --continue` or `claude --resume`, you pick up where you left off using the same session ID. New messages append to the existing conversation. Your full conversation history is restored, but session-scoped permissions are not. You’ll need to re-approve those. To branch off and try a different approach without affecting the original session, use the `--fork-session` flag: -Report incorrect code - -Copy - -Ask AI - claude --continue --fork-session This creates a new session ID while preserving the conversation history up to that point. The original session remains unchanged. Like resume, forked sessions don’t inherit session-scoped permissions. **Same session in multiple terminals** : If you resume the same session in multiple terminals, both terminals write to the same session file. Messages from both get interleaved, like two people writing in the same notebook. Nothing corrupts, but the conversation becomes jumbled. Each terminal only sees its own messages during the session, but if you resume that session later, you’ll see everything interleaved. For parallel work from the same starting point, use `--fork-session` to give each terminal its own clean session. @@ -130,7 +124,7 @@ The context window -Claude’s context window holds your conversation history, file contents, command outputs, [CLAUDE.md](</docs/en/memory>), [auto memory](</docs/en/memory#auto-memory>), loaded skills, and system instructions. As you work, context fills up. Claude compacts automatically, but instructions from early in the conversation can get lost. Put persistent rules in CLAUDE.md, and run `/context` to see what’s using space. +Claude’s context window holds your conversation history, file contents, command outputs, [CLAUDE.md](</docs/en/memory>), [auto memory](</docs/en/memory#auto-memory>), loaded skills, and system instructions. As you work, context fills up. Claude compacts automatically, but instructions from early in the conversation can get lost. Put persistent rules in CLAUDE.md, and run `/context` to see what’s using space. For an interactive walkthrough of what loads and when, see [Explore the context window](</docs/en/context-window>). #### @@ -138,7 +132,7 @@ When context fills up -Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). Run `/context` to see what’s using space. MCP servers add tool definitions to every request, so a few servers can consume significant context before you start working. Run `/mcp` to check per-server costs. +Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). Run `/context` to see what’s using space. MCP tool definitions are deferred by default and loaded on demand via [tool search](</docs/en/mcp#scale-with-mcp-tool-search>), so only tool names consume context until Claude uses a specific tool. Run `/mcp` to check per-server costs. #### @@ -209,22 +203,10 @@ Claude Code is conversational. You don’t need perfect prompts. Start with what you want, then refine: -Report incorrect code - -Copy - -Ask AI - Fix the login bug [Claude investigates, tries something] -Report incorrect code - -Copy - -Ask AI - That's not quite right. The issue is in the session handling. [Claude adjusts approach] When the first attempt isn’t right, you don’t start over. You iterate. @@ -244,12 +226,6 @@ Be specific upfront The more precise your initial prompt, the fewer corrections you’ll need. Reference specific files, mention constraints, and point to example patterns. - -Report incorrect code - -Copy - -Ask AI The checkout flow is broken for users with expired cards. Check src/payments/ for the issue, especially token refresh. @@ -265,12 +241,6 @@ Claude performs better when it can check its own work. Include test cases, paste screenshots of expected UI, or define the output you want. -Report incorrect code - -Copy - -Ask AI - Implement validateEmail. Test cases: '[[email protected]](</cdn-cgi/l/email-protection>)' → true, 'invalid' → false, '[[email protected]](</cdn-cgi/l/email-protection>)' → false. Run the tests after. @@ -284,12 +254,6 @@ For complex problems, separate research from coding. Use plan mode (`Shift+Tab` twice) to analyze the codebase first: -Report incorrect code - -Copy - -Ask AI - Read src/auth/ and understand how we handle sessions. Then create a plan for adding OAuth support. @@ -303,12 +267,6 @@ Think of delegating to a capable colleague. Give context and direction, then trust Claude to figure out the details: -Report incorrect code - -Copy - -Ask AI - The checkout flow is broken for users with expired cards. The relevant code is in src/payments/. Can you investigate and fix it?
modified
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -175,6 +175,7 @@ * **Default** : Claude asks before file edits and shell commands * **Auto-accept edits** : Claude edits files without asking, still asks for commands * **Plan mode** : Claude uses read-only tools only, creating a plan you can approve before execution + * **Auto mode** : Claude evaluates all actions with background safety checks. Currently a research preview You can also allow specific commands in `.claude/settings.json` so Claude doesn’t ask each time. This is useful for trusted commands like `npm test` or `git status`. Settings can be scoped from organization-wide policies down to personal preferences. See [Permissions](</docs/en/permissions>) for details.
added
Show diff (331 lines)
--- a/how-claude-code-works.md +++ b/how-claude-code-works.md @@ -0,0 +1,328 @@ +Claude Code is an agentic assistant that runs in your terminal. While it excels at coding, it can help with anything you can do from the command line: writing docs, running builds, searching files, researching topics, and more. This guide covers the core architecture, built-in capabilities, and tips for working effectively. For step-by-step walkthroughs, see [Common workflows](</docs/en/common-workflows>). For extensibility features like skills, MCP, and hooks, see [Extend Claude Code](</docs/en/features-overview>). + +## + +​ + +The agentic loop + +When you give Claude a task, it works through three phases: **gather context** , **take action** , and **verify results**. These phases blend together. Claude uses tools throughout, whether searching files to understand your code, editing to make changes, or running tests to check its work. The loop adapts to what you ask. A question about your codebase might only need context gathering. A bug fix cycles through all three phases repeatedly. A refactor might involve extensive verification. Claude decides what each step requires based on what it learned from the previous step, chaining dozens of actions together and course-correcting along the way. You’re part of this loop too. You can interrupt at any point to steer Claude in a different direction, provide additional context, or ask it to try a different approach. Claude works autonomously but stays responsive to your input. The agentic loop is powered by two components: models that reason and tools that act. Claude Code serves as the **agentic harness** around Claude: it provides the tools, context management, and execution environment that turn a language model into a capable coding agent. + +### + +​ + +Models + +Claude Code uses Claude models to understand your code and reason about tasks. Claude can read code in any language, understand how components connect, and figure out what needs to change to accomplish your goal. For complex tasks, it breaks work into steps, executes them, and adjusts based on what it learns. [Multiple models](</docs/en/model-config>) are available with different tradeoffs. Sonnet handles most coding tasks well. Opus provides stronger reasoning for complex architectural decisions. Switch with `/model` during a session or start with `claude --model <name>`. When this guide says “Claude chooses” or “Claude decides,” it’s the model doing the reasoning. + +### + +​ + +Tools + +Tools are what make Claude Code agentic. Without tools, Claude can only respond with text. With tools, Claude can act: read your code, edit files, run commands, search the web, and interact with external services. Each tool use returns information that feeds back into the loop, informing Claude’s next decision. The built-in tools generally fall into five categories, each representing a different kind of agency. + +Category| What Claude can do +---|--- +**File operations**| Read files, edit code, create new files, rename and reorganize +**Search**| Find files by pattern, search content with regex, explore codebases +**Execution**| Run shell commands, start servers, run tests, use git +**Web**| Search the web, fetch documentation, look up error messages +**Code intelligence**| See type errors and warnings after edits, jump to definitions, find references (requires [code intelligence plugins](</docs/en/discover-plugins#code-intelligence>)) + +These are the primary capabilities. Claude also has tools for spawning subagents, asking you questions, and other orchestration tasks. See [Tools available to Claude](</docs/en/tools-reference>) for the complete list. Claude chooses which tools to use based on your prompt and what it learns along the way. When you say “fix the failing tests,” Claude might: + + 1. Run the test suite to see what’s failing + 2. Read the error output + 3. Search for the relevant source files + 4. Read those files to understand the code + 5. Edit the files to fix the issue + 6. Run the tests again to verify + +Each tool use gives Claude new information that informs the next step. This is the agentic loop in action. **Extending the base capabilities:** The built-in tools are the foundation. You can extend what Claude knows with [skills](</docs/en/skills>), connect to external services with [MCP](</docs/en/mcp>), automate workflows with [hooks](</docs/en/hooks>), and offload tasks to [subagents](</docs/en/sub-agents>). These extensions form a layer on top of the core agentic loop. See [Extend Claude Code](</docs/en/features-overview>) for guidance on choosing the right extension for your needs. + +## + +​ + +What Claude can access + +This guide focuses on the terminal. Claude Code also runs in [VS Code](</docs/en/vs-code>), [JetBrains IDEs](</docs/en/jetbrains>), and other environments. When you run `claude` in a directory, Claude Code gains access to: + + * **Your project.** Files in your directory and subdirectories, plus files elsewhere with your permission. + * **Your terminal.** Any command you could run: build tools, git, package managers, system utilities, scripts. If you can do it from the command line, Claude can too. + * **Your git state.** Current branch, uncommitted changes, and recent commit history. + * **Your[CLAUDE.md](</docs/en/memory>).** A markdown file where you store project-specific instructions, conventions, and context that Claude should know every session. + * **[Auto memory](</docs/en/memory#auto-memory>).** Learnings Claude saves automatically as you work, like project patterns and your preferences. The first 200 lines of MEMORY.md are loaded at the start of each session. + * **Extensions you configure.** [MCP servers](</docs/en/mcp>) for external services, [skills](</docs/en/skills>) for workflows, [subagents](</docs/en/sub-agents>) for delegated work, and [Claude in Chrome](</docs/en/chrome>) for browser interaction. + +Because Claude sees your whole project, it can work across it. When you ask Claude to “fix the authentication bug,” it searches for relevant files, reads multiple files to understand context, makes coordinated edits across them, runs tests to verify the fix, and commits the changes if you ask. This is different from inline code assistants that only see the current file. + +## + +​ + +Environments and interfaces + +The agentic loop, tools, and capabilities described above are the same everywhere you use Claude Code. What changes is where the code executes and how you interact with it. + +### + +​ + +Execution environments + +Claude Code runs in three environments, each with different tradeoffs for where your code executes. + +Environment| Where code runs| Use case +---|---|--- +**Local**| Your machine| Default. Full access to your files, tools, and environment +**Cloud**| Anthropic-managed VMs| Offload tasks, work on repos you don’t have locally +**Remote Control**| Your machine, controlled from a browser| Use the web UI while keeping everything local + +### + +​ + +Interfaces + +You can access Claude Code through the terminal, the [desktop app](</docs/en/desktop>), [IDE extensions](</docs/en/ide-integrations>), [claude.ai/code](<https://claude.ai/code>), [Remote Control](</docs/en/remote-control>), [Slack](</docs/en/slack>), and [CI/CD pipelines](</docs/en/github-actions>). The interface determines how you see and interact with Claude, but the underlying agentic loop is identical. See [Use Claude Code everywhere](</docs/en/overview#use-claude-code-everywhere>) for the full list. + +## + +​ + +Work with sessions + +Claude Code saves your conversation locally as you work. Each message, tool use, and result is stored, which enables rewinding, resuming, and forking sessions. Before Claude makes code changes, it also snapshots the affected files so you can revert if needed. **Sessions are independent.** Each new session starts with a fresh context window, without the conversation history from previous sessions. Claude can persist learnings across sessions using [auto memory](</docs/en/memory#auto-memory>), and you can add your own persistent instructions in [CLAUDE.md](</docs/en/memory>). + +### + +​ + +Work across branches + +Each Claude Code conversation is a session tied to your current directory. When you resume, you only see sessions from that directory. Claude sees your current branch’s files. When you switch branches, Claude sees the new branch’s files, but your conversation history stays the same. Claude remembers what you discussed even after switching. Since sessions are tied to directories, you can run parallel Claude sessions by using [git worktrees](</docs/en/common-workflows#run-parallel-claude-code-sessions-with-git-worktrees>), which create separate directories for individual branches. + +### + +​ + +Resume or fork sessions + +When you resume a session with `claude --continue` or `claude --resume`, you pick up where you left off using the same session ID. New messages append to the existing conversation. Your full conversation history is restored, but session-scoped permissions are not. You’ll need to re-approve those. To branch off and try a different approach without affecting the original session, use the `--fork-session` flag: + +Report incorrect code + +Copy + +Ask AI + + claude --continue --fork-session + +This creates a new session ID while preserving the conversation history up to that point. The original session remains unchanged. Like resume, forked sessions don’t inherit session-scoped permissions. **Same session in multiple terminals** : If you resume the same session in multiple terminals, both terminals write to the same session file. Messages from both get interleaved, like two people writing in the same notebook. Nothing corrupts, but the conversation becomes jumbled. Each terminal only sees its own messages during the session, but if you resume that session later, you’ll see everything interleaved. For parallel work from the same starting point, use `--fork-session` to give each terminal its own clean session. + +### + +​ + +The context window + +Claude’s context window holds your conversation history, file contents, command outputs, [CLAUDE.md](</docs/en/memory>), [auto memory](</docs/en/memory#auto-memory>), loaded skills, and system instructions. As you work, context fills up. Claude compacts automatically, but instructions from early in the conversation can get lost. Put persistent rules in CLAUDE.md, and run `/context` to see what’s using space. + +#### + +​ + +When context fills up + +Claude Code manages context automatically as you approach the limit. It clears older tool outputs first, then summarizes the conversation if needed. Your requests and key code snippets are preserved; detailed instructions from early in the conversation may be lost. Put persistent rules in CLAUDE.md rather than relying on conversation history. To control what’s preserved during compaction, add a “Compact Instructions” section to CLAUDE.md or run `/compact` with a focus (like `/compact focus on the API changes`). Run `/context` to see what’s using space. MCP servers add tool definitions to every request, so a few servers can consume significant context before you start working. Run `/mcp` to check per-server costs. + +#### + +​ + +Manage context with skills and subagents + +Beyond compaction, you can use other features to control what loads into context. [Skills](</docs/en/skills>) load on demand. Claude sees skill descriptions at session start, but the full content only loads when a skill is used. For skills you invoke manually, set `disable-model-invocation: true` to keep descriptions out of context until you need them. [Subagents](</docs/en/sub-agents>) get their own fresh context, completely separate from your main conversation. Their work doesn’t bloat your context. When done, they return a summary. This isolation is why subagents help with long sessions. See [context costs](</docs/en/features-overview#understand-context-costs>) for what each feature costs, and [reduce token usage](</docs/en/costs#reduce-token-usage>) for tips on managing context. + +## + +​ + +Stay safe with checkpoints and permissions + +Claude has two safety mechanisms: checkpoints let you undo file changes, and permissions control what Claude can do without asking. + +### + +​ + +Undo changes with checkpoints + +**Every file edit is reversible.** Before Claude edits any file, it snapshots the current contents. If something goes wrong, press `Esc` twice to rewind to a previous state, or ask Claude to undo. Checkpoints are local to your session, separate from git. They only cover file changes. Actions that affect remote systems (databases, APIs, deployments) can’t be checkpointed, which is why Claude asks before running commands with external side effects. + +### + +​ + +Control what Claude can do + +Press `Shift+Tab` to cycle through permission modes: + + * **Default** : Claude asks before file edits and shell commands + * **Auto-accept edits** : Claude edits files without asking, still asks for commands + * **Plan mode** : Claude uses read-only tools only, creating a plan you can approve before execution + +You can also allow specific commands in `.claude/settings.json` so Claude doesn’t ask each time. This is useful for trusted commands like `npm test` or `git status`. Settings can be scoped from organization-wide policies down to personal preferences. See [Permissions](</docs/en/permissions>) for details. + +* * * + +## + +​ + +Work effectively with Claude Code + +These tips help you get better results from Claude Code. + +### + +​ + +Ask Claude Code for help + +Claude Code can teach you how to use it. Ask questions like “how do I set up hooks?” or “what’s the best way to structure my CLAUDE.md?” and Claude will explain. Built-in commands also guide you through setup: + + * `/init` walks you through creating a CLAUDE.md for your project + * `/agents` helps you configure custom subagents + * `/doctor` diagnoses common issues with your installation + +### + +​ + +It’s a conversation + +Claude Code is conversational. You don’t need perfect prompts. Start with what you want, then refine: + +Report incorrect code + +Copy + +Ask AI + + Fix the login bug + +[Claude investigates, tries something] + +Report incorrect code + +Copy + +Ask AI + + That's not quite right. The issue is in the session handling. + +[Claude adjusts approach] When the first attempt isn’t right, you don’t start over. You iterate. + +#### + +​ + +Interrupt and steer + +You can interrupt Claude at any point. If it’s going down the wrong path, just type your correction and press Enter. Claude will stop what it’s doing and adjust its approach based on your input. You don’t have to wait for it to finish or start over. + +### + +​ + +Be specific upfront + +The more precise your initial prompt, the fewer corrections you’ll need. Reference specific files, mention constraints, and point to example patterns. + +Report incorrect code + +Copy + +Ask AI + + The checkout flow is broken for users with expired cards. + Check src/payments/ for the issue, especially token refresh. + Write a failing test first, then fix it. + +Vague prompts work, but you’ll spend more time steering. Specific prompts like the one above often succeed on the first attempt. + +### + +​ + +Give Claude something to verify against + +Claude performs better when it can check its own work. Include test cases, paste screenshots of expected UI, or define the output you want. + +Report incorrect code + +Copy + +Ask AI + + Implement validateEmail. Test cases: '[[email protected]](</cdn-cgi/l/email-protection>)' → true, + 'invalid' → false, '[[email protected]](</cdn-cgi/l/email-protection>)' → false. Run the tests after. + +For visual work, paste a screenshot of the design and ask Claude to compare its implementation against it. + +### + +​ + +Explore before implementing + +For complex problems, separate research from coding. Use plan mode (`Shift+Tab` twice) to analyze the codebase first: + +Report incorrect code + +Copy + +Ask AI + + Read src/auth/ and understand how we handle sessions. + Then create a plan for adding OAuth support. + +Review the plan, refine it through conversation, then let Claude implement. This two-phase approach produces better results than jumping straight to code. + +### + +​ + +Delegate, don’t dictate + +Think of delegating to a capable colleague. Give context and direction, then trust Claude to figure out the details: + +Report incorrect code + +Copy + +Ask AI + + The checkout flow is broken for users with expired cards. + The relevant code is in src/payments/. Can you investigate and fix it? + +You don’t need to specify which files to read or what commands to run. Claude figures that out. + +## + +​ + +What’s next + +## Extend with features + +Add Skills, MCP connections, and custom commands + +## Common workflows + +Step-by-step guides for typical tasks