#005: BREAKING: Behind The Scenes of "Claude Code" Internal Prompts
In this issue we are going to look at the actual prompts that are used by Claude Code coding agent and which enable it to be highly efficient coding assistant.
Today we are going to look deep behind the scenes of Claude Code coding agent and understand how it is able to work so effectively with code. If you are not familiar with this type of agents, coding agents are AI driven programs that take instructions from the user and make repository-wide code edits.
Since a code repository can be very large, a coding agent relies heavily on tools. When a language model is fed with correct instructions, it too can emit answer back to the agent application about which tools it would like to call in order to accomplish the task and the agent then runs the tools and responds with the information back to the model.
In this way the model is able to execute highly complex tasks. This is the core functionality behind the ReAct style agent.
Claude Code agent uses a variety of simple yet highly specialized tools that enable it to interact with your codebase effectively. Each tool is designed for a specific purpose, from searching and reading files to editing code and executing commands. These tools work together to enable Claude Code to understand your code base and make appropriate modifications with your guidance.
The tools are designed to be both powerful and safe, with built-in validation and error handling to prevent unintended consequences.
What really makes the difference is 2 main things:
System prompt: this is the core instruction to the model about what it should do (including calling tools)
Tool description: this is a detailed description of HOW to use each tool.
Today we are going to look at the exact prompts that are used by Claude Code. Including the very long system prompt!
Here is the complete list of tools that we are going to cover:
AgentTool: Spawns a new independent agent to work on a complex task.
ArchitectTool: Designs software architecture without implementing it.
LSTool: list directories tool
BashTool: Runs shell commands
FileEditTool: Allows agents to edit a file without regenerating the whole file.
FileReadTool: Reads a file
FileWriteTool: Writes a file.
GlobTool: Find files based on path glob patterns.
GrepTool: Finds strings in files
NotebookEditTool: Edits a Jypiter notebook
NotebookReadTool: Reads a jypiter notebook
ThinkTool: Used by model to emit thoughts
What is really amazing here is that with these limited tools the Claude Code agent is able to accomplish very complex code editing tasks.
To fully understand how this is done, we have to dig deeper and look at each tool description that these tools expose to the model and through which we can make it easy for the model to pick the right tool for the job each step of the way. The model is then able to direct the agent to use tools and by doing so it then accomplishes code editing tasks.
Keep reading with a 7-day free trial
Subscribe to Agentic Engineering to keep reading this post and get 7 days of free access to the full post archives.