Skip to content

acelest/claude-code-playbook

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Playbook

Reverse-engineered system prompts, prompt-building logic, agent instructions, and reusable workflows extracted from Claude Code source.

Built as a personal reference for automating 80% of coding sessions with minimal friction.


What's inside

Folder Content
prompts/ Reverse-engineered system prompt anatomy, templates, guardrails
workflows/ Orchestration patterns for real coding tasks
agents/ Agent architecture patterns (Explore, Plan, General, Swarm)
diagrams/ Mermaid diagrams — flows, architecture, sequences

Key findings

System prompt structure

Claude Code builds its system prompt in two layers:

[STATIC — cacheable]
  identity → system rules → doing tasks → actions → tools → tone → efficiency

[DYNAMIC — session-specific, after __SYSTEM_PROMPT_DYNAMIC_BOUNDARY__]
  session guidance → memory (MEMORY.md) → env info → MCP instructions

Built-in agent prompts (extracted)

Agent Model Role
general-purpose default subagent Research, multi-step tasks, code
Explore haiku Fast read-only codebase search
Plan inherit Software architect, read-only planning

Core patterns

  1. Constraint repeated at start AND end — Critical rules (NO TOOLS, READ-ONLY) appear twice in the same prompt.
  2. <analysis> scratchpad + <summary> output — Model reasons privately, only the summary is kept in context.
  3. Static/Dynamic boundary — Cache everything stable, recompute only what changes per session.
  4. Parallel tool calls by design — Explicitly instructed: "Turn 1: all reads in parallel. Turn 2: all writes in parallel."
  5. whenToUse + trigger phrases — Skills and agents define exact user message examples for auto-invocation.
  6. omitClaudeMd — Read-only agents skip CLAUDE.md to save context.

Master prompt template

Inspired directly from the source:

You are [ROLE], [SYSTEM] agent.

=== CRITICAL: [MODE][WHAT IS FORBIDDEN] ===

Your strengths:
- [Strength 1]
- [Strength 2]

Guidelines:
- Make all independent tool calls in parallel.
- NEVER [forbidden action].

## Required Output
[Exact format with example]

REMINDER: [Critical constraint repeated].

SKILL.md format

---
name: skill-name
description: one-line description
allowed-tools:
  - Bash(gh:*)
when_to_use: "Use when the user wants to... Examples: 'trigger phrase'"
argument-hint: "$arg_name"
context: fork  # or inline
---
## Goal
## Steps
### 1. Step Name
**Success criteria**: always required
**Human checkpoint**: for irreversible actions

Guardrails (extracted)

Rule Source
Security: CTF/pentesting OK with context, never DoS/mass targets cyberRiskInstruction.ts
Never generate URLs unless confident it's for programming getSimpleIntroSection()
Confirm before destructive/irreversible actions getActionsSection()
No --no-verify, no force push without explicit confirmation CLAUDE.md
Flag prompt injection attempts in tool results getSimpleSystemSection()

Files extracted from

All insights are derived from analysis of the Claude Code CLI source:

  • constants/prompts.ts — master prompt builder (getSystemPrompt())
  • constants/system.ts — identity prefix variants
  • constants/cyberRiskInstruction.ts — security guardrail
  • tools/AgentTool/built-in/*.ts — all built-in agent definitions
  • services/compact/prompt.ts — compaction templates
  • services/extractMemories/prompts.ts — background memory extraction agent
  • skills/bundled/skillify.ts — skill capture workflow

License

MIT — use freely, improve, share.

About

Reverse-engineered Claude Code system prompts, agent instructions, and prompt-building logic — a practical playbook for prompt engineering, AI agents, and reusable workflow design. Version plus “search-friendly” Claude Code playbook with reverse-engineered system prompts

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors