Claude
Skills
Sign in
Back

claude-code-system-prompts-research

Included with Lifetime
$97 forever

```markdown

Writing & Docs

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