claude-code-system-prompts-research
```markdown
What this skill does
```markdown
---
name: claude-code-system-prompts-research
description: Research documentation of Claude Code's internal prompt architecture, agent directives, multi-agent orchestration patterns, and security classifiers
triggers:
- "how does claude code's system prompt work"
- "explain claude code agent architecture"
- "show me the auto mode classifier design"
- "how does claude code handle multi-agent orchestration"
- "what are claude code's security boundaries"
- "how does prompt caching work in claude code"
- "explain claude code memory system"
- "how does context window management work in claude code"
---
# Claude Code System Prompts Research
> Skill by [ara.so](https://ara.so) — Daily 2026 Skills collection.
An independent research project documenting the internal prompt architecture, agent directives, and security classifiers of **Claude Code** — Anthropic's AI-powered software engineering assistant. Use this skill to understand design patterns for production-grade agentic AI systems.
---
## What This Project Documents
This repository catalogs 30+ prompts recovered through behavioral analysis and output observation. It covers:
- **Core identity prompts** — how Claude Code defines itself and its constraints
- **Multi-agent orchestration** — coordinator patterns, sub-agent spawning, swarm communication
- **Security classifiers** — 2-stage auto-approval pipeline for tool calls
- **Context window management** — compaction, caching, micro-summarization
- **Memory systems** — hierarchical CLAUDE.md loading with override semantics
- **Specialized agents** — verification, exploration, agent-creation, browser automation
---
## Repository Structure
```
claude-code-system-prompts/
README.md
prompts/
01_main_system_prompt.md # Master assembled prompt
02_simple_mode.md # CLAUDE_CODE_SIMPLE minimal prompt
03_default_agent_prompt.md # Base inherited by all sub-agents
04_cyber_risk_instruction.md # Security allow/deny boundaries
05_coordinator_system_prompt.md # Multi-worker orchestrator
06_teammate_prompt_addendum.md # Swarm/team communication protocol
07_verification_agent.md # Adversarial testing specialist
08_explore_agent.md # Read-only codebase explorer
09_agent_creation_architect.md # Designs new agent configs
10_statusline_setup_agent.md # Terminal status line setup
11_permission_explainer.md # Tool risk explanations
12_yolo_auto_mode_classifier.md # 2-stage security classifier
13_tool_prompts.md # All 30+ tool descriptions
14_tool_use_summary.md # Git-commit-style tool labels
15_session_search.md # Semantic session search
16_memory_selection.md # Memory file relevance selector
17_auto_mode_critique.md # Reviews classifier rules
18_proactive_mode.md # Autonomous tick-based agent
19_simplify_skill.md # 3-agent parallel code review
20_session_title.md # Session title generator
21_compact_service.md # Conversation summarization
22_away_summary.md # Idle session recap
23_chrome_browser_automation.md # Browser extension integration
24_memory_instruction.md # CLAUDE.md @include directives
25_skillify.md # Skill creation interview
26_stuck_skill.md # Frozen session diagnostics
27_remember_skill.md # Promotes memory to CLAUDE.md
28_update_config_skill.md # settings.json/hooks manager
29_agent_summary.md # Sub-agent progress updates
30_prompt_suggestion.md # Predicts next user command
```
---
## Key Architecture Patterns
### 1. Dynamic Prompt Assembly
The main system prompt is not a static string. It is assembled at runtime from modular section-builder functions with a cache boundary splitting static and dynamic content:
```
┌─────────────────────────────────────────┐
│ STATIC PREFIX (cached globally) │
│ - Identity + Cyber Risk │
│ - Permission modes, hooks, reminders │
│ - Code style, security, reversibility │
│ - Tool preferences, parallel calls │
│ - Tone, output efficiency patterns │
├─────────────────────────────────────────┤
│ CACHE BOUNDARY │
├─────────────────────────────────────────┤
│ DYNAMIC SUFFIX (session-specific) │
│ - Agent tools, skills, verification │
│ - Memory file content (CLAUDE.md) │
│ - Model overrides │
│ - Environment: CWD, OS, git state │
│ - Language preferences │
│ - MCP server instructions │
│ - Context window state │
└─────────────────────────────────────────┘
```
**Key insight for your own agents:** Separate stable behavioral instructions (cache-eligible) from runtime context (session-specific). This reduces token costs significantly on repeated calls.
### 2. 2-Stage Auto-Mode Security Classifier
The `12_yolo_auto_mode_classifier.md` describes a pipeline for safely auto-approving tool calls:
```
Tool Call Request
│
▼
┌─────────────┐
│ Stage 1 │ Fast classification
│ Classifier │ Allow / Deny / Uncertain
└─────────────┘
│
Uncertain?
│
▼
┌─────────────┐
│ Stage 2 │ Extended thinking
│ Classifier │ Allow / Deny
└─────────────┘
```
Classifier prompt is assembled from four layers:
```
Base classifier instructions
+
Default rules (allow / deny / environment sections)
+
User overrides (replace entire sections)
+
Runtime context (tool name, args, working directory)
```
**Pattern to replicate:**
```python
def build_classifier_prompt(
base: str,
default_rules: dict,
user_overrides: dict,
tool_call: dict
) -> str:
rules = {**default_rules, **user_overrides} # overrides win
return f"""
{base}
## Rules
### Allow
{rules.get('allow', '')}
### Deny
{rules.get('deny', '')}
### Environment
{rules.get('environment', '')}
## Tool Call to Classify
Tool: {tool_call['name']}
Arguments: {tool_call['args']}
Working Directory: {tool_call['cwd']}
"""
```
### 3. Multi-Agent Coordinator (4-Phase Workflow)
From `05_coordinator_system_prompt.md`, the orchestrator follows a structured loop:
```
Phase 1: PLAN
- Decompose task into parallel work units
- Identify dependencies between units
- Determine concurrency limits
Phase 2: SPAWN
- Launch worker agents with isolated contexts
- Assign each a specific sub-task and tool subset
- Set verification requirements
Phase 3: MONITOR
- Collect periodic progress summaries (prompt 29)
- Detect blocked or stuck agents (prompt 26)
- Re-assign failed work units
Phase 4: INTEGRATE
- Merge outputs from all workers
- Run verification agent (prompt 07) against result
- Report to user with summary
```
**Spawning a sub-agent (conceptual pattern):**
```python
def spawn_worker(task: str, tools: list[str], read_only: bool = False) -> Agent:
base = load_prompt("03_default_agent_prompt.md")
if read_only:
base += load_prompt("08_explore_agent.md")
return Agent(
system_prompt=base,
allowed_tools=tools,
task=task,
reports_to="coordinator"
)
# Parallel exploration example
workers = [
spawn_worker("Map all API endpoints", tools=["read_file", "grep"], read_only=True),
spawn_worker("Find all database models", tools=["read_file", "grep"], read_only=True),
spawn_worker("List all test files", tools=["read_file", "glob"], read_only=True),
]
results = await asyncio.gather(*[w.run() for w in workers])
```
### 4. Memory System (Hierarchical CLAUDE.md)
From `24_memory_instruction.md`, memory files are loaded in priority order:
```
Priority (lowest →Related in Writing & Docs
jax-development
IncludedUse this skill when the user is writing, debugging, profiling, refactoring, reviewing, benchmarking, parallelising, exporting, or explaining JAX code, or when they mention JAX, jax.numpy, jit, grad, value_and_grad, vmap, scan, lax, random keys, pytrees, jax.Array, sharding, Mesh, PartitionSpec, NamedSharding, pmap, shard_map, Pallas, XLA, StableHLO, checkify, profiler, or the JAX repo. It helps turn NumPy or PyTorch-style code into pure functional JAX, fix tracer/control-flow/shape/PRNG bugs, remove recompiles and host-device syncs, choose transforms and sharding strategies, inspect jaxpr/lowering/IR, and benchmark compiled code correctly.
nature-article-writer
IncludedDrafts, rewrites, diagnostically critiques, and style-calibrates primary research manuscripts for Nature and Nature Portfolio journals. Use when the user wants a Nature-style title, summary paragraph or abstract, introduction, results, discussion, methods, figure legends, presubmission enquiry, cover letter, reviewer response, or when a scientific draft sounds generic, jargon-heavy, structurally weak, or AI-ish and needs precise, broad-reader-friendly prose without inventing data, analyses, or references. Best for primary research articles and letters rather than reviews or press releases unless explicitly adapting one.
deckrd
IncludedDocument-driven framework that derives requirements, specifications, implementation plans, and executable tasks from goals through structured AI dialogue. Use when user says "write requirements", "create spec", "plan implementation", "derive tasks", "structure this feature", "break down into tasks", or "document this module". Also use for reverse engineering existing code into docs (/deckrd rev). Do NOT use for direct code writing — use /deckrd-coder after tasks are generated. Do NOT use when the user only wants to run or fix existing code without planning.
clinical-decision-support
IncludedGenerate professional clinical decision support (CDS) documents for pharmaceutical and clinical research settings, including patient cohort analyses (biomarker-stratified with outcomes) and treatment recommendation reports (evidence-based guidelines with decision algorithms). Supports GRADE evidence grading, statistical analysis (hazard ratios, survival curves, waterfall plots), biomarker integration, and regulatory compliance. Outputs publication-ready LaTeX/PDF format optimized for drug development, clinical research, and evidence synthesis.
handling-sf-data
IncludedSalesforce data operations with 130-point scoring. Use this skill to create, update, delete, bulk import/export, generate test data, and clean up org records using sf CLI and anonymous Apex. TRIGGER when: user creates test data, performs bulk import/export, uses sf data CLI commands, needs data factory patterns for Apex tests, or needs to seed/clean records in a Salesforce org. DO NOT TRIGGER when: SOQL query writing only (use querying-soql), Apex test execution (use running-apex-tests), or metadata deployment (use deploying-metadata).
accelint-ac-to-playwright
IncludedConvert and validate acceptance criteria for Playwright test automation. Use when user asks to (1) review/evaluate/check if AC are ready for automation, (2) assess if AC can be converted as-is, (3) validate AC quality for Playwright, (4) turn AC into tests, (5) generate tests from acceptance criteria, (6) convert .md bullets or .feature Gherkin files to Playwright specs, (7) create test automation from requirements. Handles both bullet-style markdown and Gherkin syntax with JSON test plan generation and validation.