You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
An independent research project documenting the internal prompt architecture and agentic behavior of Claude Code, Anthropic's AI-powered software engineering assistant.
This documentation was produced through behavioral analysis, output observation, and study of publicly available discussions. It serves as an educational resource for understanding how modern agentic AI coding assistants are designed.
Overview
Claude Code uses a sophisticated multi-layered prompt architecture. The main system prompt is not a static string but is dynamically assembled at runtime from modular section-builder functions. A boundary marker splits it into a globally cacheable prefix and a session-specific suffix, enabling prompt caching across API calls.
Beyond the core identity prompt, the system includes specialized agent prompts, a multi-worker coordinator, a 2-stage security classifier for auto-approving tool calls, and a suite of utility prompts for memory selection, session search, and tool summarization.
User Message
|
v
[Micro-Compaction] -- Cache-aware tool result deletion
|
v
[Compact Service] -- Full/partial summarization
|
v
[Prompt Suggestion] -- Predict next user command
|
v
[Away Summary] -- Session recap if user was idle
Memory System
Memory Loading Order (first loaded = lowest priority):
|
|-- Enterprise managed config
|-- User global config
|-- Project config (shared, checked in)
|-- Project rules directory
|-- Local config (private, git-ignored)
|
| @include directives resolve transitively (max depth: 5)
| Frontmatter paths field enables conditional injection
Environment Variables
Variable
Effect
CLAUDE_CODE_SIMPLE
Activates the minimal 4-line system prompt
USER_TYPE=ant
Enables internal-only sections and model overrides
Feature flags
Gate proactive mode, verification agents, fork subagents, and more
This project exists as an educational resource for AI researchers, developers building agentic systems, and anyone interested in understanding the design patterns behind production-grade AI coding assistants.
The documented patterns cover topics relevant to the broader AI engineering community:
Multi-agent orchestration and coordination
Security classification for autonomous tool use
Context window management and conversation compaction
Memory systems with hierarchical override semantics
Prompt caching strategies for latency optimization
Disclaimer
This is an independent research project. The content represents analysis and observations of Claude Code's behavior and architecture. This project is not affiliated with, endorsed by, or connected to Anthropic in any way. All trademarks belong to their respective owners.
About
Independent research documenting the internal prompt architecture, agent directives, and security classifiers of Claude Code