The agentic loop
Every interaction follows the same cycle:1
You send a message
You type a request in the terminal REPL. Claude receives your message along with context about your project.
2
Claude plans
Claude decides what steps are needed — which files to read, which commands to run, and in what order.
3
Claude uses tools
Claude invokes tools one at a time (or in parallel when safe) to carry out each step. Each tool call is logged in your terminal as it happens.
4
Claude responds
Once the task is complete, Claude gives you a final response. If a tool call requires your approval, the loop pauses and waits for your input before continuing.
The tool system
Claude has access to a set of tools that let it interact with your filesystem, shell, and the web. Each tool is a discrete module with its own input schema and permission model.Shell execution
BashTool runs shell commands in your working directory.
File operations
FileReadTool, FileWriteTool, and FileEditTool read, create, and partially modify files. FileEditTool performs string replacements rather than full rewrites.
Code search
GlobTool matches files by pattern. GrepTool searches file contents using ripgrep.
Web access
WebFetchTool retrieves URL content. WebSearchTool runs web searches.
Language intelligence
LSPTool integrates with Language Server Protocol to provide language-aware context such as type information and symbol resolution.
Sub-agents
AgentTool spawns sub-agents to work on subtasks in parallel. TeamCreateTool and TeamDeleteTool manage groups of agents working together.
Notebooks
NotebookEditTool reads and edits Jupyter notebooks.
MCP tools
MCPTool invokes tools exposed by connected Model Context Protocol servers.
TaskCreateTool, TaskUpdateTool), plan mode (EnterPlanModeTool, ExitPlanModeTool), git worktree isolation (EnterWorktreeTool, ExitWorktreeTool), and scheduled triggers (CronCreateTool).
The REPL model
Claude Code runs as an interactive REPL (Read-Eval-Print Loop) in your terminal. Each session maintains a conversation history, and you can continue building on previous messages within the same session. The UI is built with React and Ink, which renders interactive components directly in your terminal — including permission prompts, file diffs, and progress indicators. You can also use slash commands (prefixed with/) to trigger specific actions like /commit, /review, /memory, and /diff. Type / to see the full list of available commands.
How Claude understands your codebase
Before Claude makes changes, it gathers context. Depending on what you ask, it may:- Read specific files with FileReadTool
- Search for patterns across your codebase with GrepTool or GlobTool
- Run shell commands to inspect the environment (e.g.,
git log,ls) - Use LSPTool to resolve types and symbols at a language level
- Load your
CLAUDE.mdproject instructions (if present) at startup
Runtime and API
Claude Code runs on the Bun JavaScript runtime and communicates with Claude via the Anthropic API. Responses stream in real time as Claude works, and token usage is tracked automatically. Run/cost at any point to see how many tokens the current session has consumed.
Claude Code uses your Anthropic API credentials. Run
/login to authenticate, or set the ANTHROPIC_API_KEY environment variable before starting a session.