.claude/skills/extract-claude-code-prompt/SKILL.md
Extract Claude Code system prompt from its compiled binary or JS bundle into a structured template file. Produces a document mirroring the real API request with exact prompt text, ant-only variants, feature-gated sections, and minified-variable mappings. Use when extracting, documenting, or comparing Claude Code prompt versions.
npx skillsauth add korchasa/flow extract-claude-code-promptInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Procedure for recovering the complete Claude Code LLM request template from the binary or JS bundle.
| Input | Required | Description |
|-------|----------|-------------|
| Artifact path | Yes | Either: (a) Bun Mach-O arm64 ~200MB from ~/.local/share/claude/versions/<ver>, or (b) JS bundle cli.js ~11MB from npm package |
| Output path | Yes | Where to write the template .txt file |
The system prompt is an array of strings assembled internally.
Before sending to the API, they are joined into 3 TextBlockParam objects:
x-anthropic-billing-header: ...) — no cache"You are Claude Code, Anthropic's official CLI for Claude.") — cache_control: ephemeral\n\n — cache_control: ephemeralAdditionally, git status is appended as one more element before joining.
User context (CLAUDE.md, date) is sent as messages[0], wrapped in <system-reminder>.
Static (globally cacheable):
Dynamic boundary marker: __SYSTEM_PROMPT_DYNAMIC_BOUNDARY__
Dynamic (per-session):
8. Session guidance — Agent, Skill, Explore
9. Memory — CLAUDE.md contents
10. Environment — CWD, platform, model, cutoff
11. Language — optional, from settings.language
12. Output Style — optional, from outputStyleConfig
13. MCP Instructions — optional, from connected MCP servers
14. Scratchpad — optional, if enabled
15. Function Result Clearing — optional, if CACHED_MICROCOMPACT enabled
16. Summarize Tool Results — always present
17. Git status — appended last
| Condition | Gate | Affects |
|-----------|------|---------|
| Anthropic employee | USER_TYPE === 'ant' | Doing tasks, Using tools, Tone, Output style, Session guidance, numeric_length_anchors |
| Opus 4.6 + ant | quiet_salted_ember in clientDataCache | Additional anti_verbosity section |
| Feature flags | feature('FLAG_NAME') | TOKEN_BUDGET, KAIROS/BRIEF, CACHED_MICROCOMPACT, EXPERIMENTAL_SKILL_SEARCH |
| Non-interactive | isNonInteractiveSession() | Prefix variant, ! <command> hint removed |
| Fork subagent | isForkSubagentEnabled() | Agent tool guidance rewritten |
To find a version by date (e.g., "early January 2026"):
# Use the helper script to find versions by date range
scripts/cc-find-version.sh 2026-01-01 2026-01-10
# Or manually:
npm view @anthropic-ai/claude-code time --json | python3 -c "
import json, sys
data = json.load(sys.stdin)
for ver, ts in sorted(data.items()):
if '2026-01' in ts: print(f'{ver}: {ts}')
"
To download a specific version:
mkdir -p /tmp/claude-code-<ver> && cd /tmp/claude-code-<ver>
npm pack @anthropic-ai/claude-code@<ver>
tar xzf anthropic-ai-claude-code-*.tgz
To use the currently installed version:
which claude # → ~/.local/bin/claude (symlink)
ls -la $(which claude) # → follow to ~/.local/share/claude/versions/<ver>
claude --version # → e.g. 2.1.104
file <path-to-artifact>
| Result | Type | Size | Approach |
|--------|------|------|----------|
| Mach-O 64-bit executable arm64 | Bun binary | ~200MB | Use strings extraction (Phase 1A) |
| a /usr/bin/env node script text | JS bundle | ~11MB | Read JS directly (Phase 1B) |
Historical note: versions before ~2.1.90 ship as JS bundles; later versions are Bun Mach-O binaries.
strings <binary-path> > /tmp/binary-strings.txt
wc -l /tmp/binary-strings.txt
grep -n "You are an interactive agent" /tmp/binary-strings.txt
grep -n "Executing actions with care" /tmp/binary-strings.txt
grep -n "# Doing tasks" /tmp/binary-strings.txt
The JS bundle is a minified single-file Node.js script. The prompt is embedded as string literals.
wc -l <path>/cli.js # typically ~5000 lines
grep -n "You are Claude Code" <path>/cli.js # find identity prefix
grep -n "# Doing tasks" <path>/cli.js # find prompt sections
Skip Phase 2 (navigate binary strings) — proceed directly to Phase 3.
Strings exist in two forms — choose the right one:
| Form | Location | Pros | Cons | |------|----------|------|------| | Minified JS | ~line 139K | Complete assembly logic, all conditionals visible | Variable names mangled, one huge line | | Standalone constants | ~line 200K | Already expanded, human-readable | Fragmented — tool names replaced by empty strings, sections split across lines |
Prefer the minified JS form — it preserves the complete assembly logic including conditional branches. Use standalone constants only for cross-referencing.
To find the minified JS block, look for very long lines containing multiple function definitions:
grep -n "function.*Executing actions with care" /tmp/binary-strings.txt
The prompt functions typically cluster in one line of 5000+ characters. Check line sizes to confirm:
sed -n '<line_number>p' /tmp/binary-strings.txt | wc -c
Find the MACRO object containing version and build time:
grep -o 'VERSION:"[^"]*"' /tmp/binary-strings.txt | head -3
grep -o 'BUILD_TIME:"[^"]*"' /tmp/binary-strings.txt | head -3
This yields the header values: time: <BUILD_TIME>, version: <VERSION>.
grep -o 'var [A-Za-z0-9_]*="Bash"' /tmp/binary-strings.txt
grep -o 'var [A-Za-z0-9_]*="Read"' /tmp/binary-strings.txt
# repeat for Edit, Write, Glob, Grep, Agent, Skill, AskUserQuestion, TodoWrite, TaskCreate
quiet_salted_ember string:
grep "quiet_salted_ember" /tmp/binary-strings.txt | head -5
The function that checks this value (e.g., wJH(H)) is the ant-detection gate — trace its usage to find all ant-only branches.time: <build_time>\nversion: <version> only.system[N] block.\n\n), no artificial dividers.{{PLACEHOLDER}} for runtime values, {{[ANT-ONLY] ...}} for ant variants, {{If condition:}} for optional sections.We are analyzing the binary from outside — there is no live Claude Code session to compare against.
claude --version (installed) vs MACRO object in binary — confirm they are the same binary.scripts/cc-diff-templates.sh tmp/claude-prompts/claude-code-v<old>.txt tmp/claude-prompts/claude-code-v<new>.txt
Review the diff for: added/removed sections, changed tool names, new conditional gates. Confirm nothing was accidentally dropped.# System, # Doing tasks, etc.) as the minified JS — cross-reference both forms (Mach-O only).anti_verbosity section captured — or noted as absent in this versiontmp/claude-prompts/)All paths below are relative to the skill directory.
| Script | Purpose |
|--------|---------|
| scripts/cc-find-version.sh <from> <to> | Find Claude Code npm versions in a date range |
| scripts/cc-download-version.sh <ver> [dir] | Download version, detect artifact type, print metadata |
| scripts/cc-diff-templates.sh <old> <new> | Diff two extracted templates, report section-level changes |
development
Use when the user asks to add TypeScript strict-mode code-style rules to AGENTS.md for a TypeScript project using strict mode. Do NOT trigger for Deno projects (use setup-agent-code-style-deno) or non-strict TS configurations.
development
Use when the user asks to add Deno/TypeScript code-style rules to AGENTS.md, or during initial Deno project setup when code-style guidelines need to be established. Do NOT trigger for non-Deno TypeScript projects (use setup-agent-code-style-strict), or for runtime-agnostic style advice.
testing
Use when the user provides a source (URL, file path, or free text) to save into the project's memex — a long-term knowledge bank for AI agents. Stores the raw source, extracts entities into cross-linked pages, runs a backlink audit, and updates the index and activity log. Do NOT trigger on casual reads; only when the intent is to persist a source into the memex.
development
Use when the user asks to audit a memex (long-term knowledge bank for AI agents) for orphans, dead SALP REFs, missing sections, contradictions, or index drift. Runs a deterministic structural check, layers LLM-judgement findings, optionally auto-fixes trivial issues with `--fix`. Do NOT trigger on general code linting.