7 modules · 43 patterns

reverse-claude

The reverse-engineering manual for Claude Code.

Extracted from ~28,000 lines of production source into actionable, portable patterns.

7
Modules
43
Named Patterns
1,746
Lines
~28K
Source Analyzed

Install

bash
npx skills add skillcreatorai/reverse-claude

Works with Claude Code, Cursor, Windsurf, and any agent that supports skills.

Usage

Understand
/reverse-claude how does the permission cascade work?
Configure
/reverse-claude lock down permissions for production
Build
/reverse-claude design a plugin discovery system

7 Modules

01

Permissioned Invocation

7 patterns

How Claude Code decides what's safe to run. The permission cascade: deny > ask > allow > read-only > passthrough.

  • Permission decision cascade with 10-step priority chain
  • Asymmetric env-var stripping (allow vs deny)
  • Declarative flag validation for read-only commands
  • Speculative classifier that races the user
02

Plugin & Skill Lifecycle

6 patterns

How plugins are discovered, loaded, migrated, and updated. Walk directories, parse frontmatter, hydrate variables, register.

  • Filesystem-to-registry command loader with YAML frontmatter
  • Versioned state migration (V1 → V2) with idempotent guard
  • Background update with notification buffer for late listeners
  • MCP server lifecycle and name normalization
03

Agent Orchestration

7 patterns

How agents spawn across four execution modes. Feature flags control schema shape and dead code elimination at build time.

  • Polymorphic execution router (sync, async, teammate, remote)
  • Race-based foreground-to-background transition
  • Multi-tier feature flag cache with 5-layer override chain
  • Cascading abort controllers for clean cancellation
04

Context Compaction & Retry

10 patterns

How context stays manageable. Four increasingly expensive strategies with circuit breakers and classified retry.

  • Compaction hierarchy: micro → session memory → full → reactive
  • Auto-compact with circuit breaker (3 failure max)
  • Classified retry with adaptive backoff and jitter
  • Thinking block budget accounting for modern models
05

Self-Configuration

6 patterns

Point the skill at Claude Code itself. Settings hierarchy, permission rules, hooks, CLAUDE.md, and ready-to-use recipes.

  • 6-layer settings hierarchy (policy > local > project > user > plugin)
  • Permission rule syntax with deny-always-wins semantics
  • Hook events and types (command, prompt, agent, http)
  • Configuration recipes for lockdown, auto-format, autonomous mode
06

Query Engine

3 patterns

The core orchestration loop. Every iteration: one API call, stream response, execute tools concurrently, recover or continue.

  • Agentic message loop with state-machine recovery
  • Streaming tool execution with concurrent + ordered drain
  • Session lifecycle wrapper with usage tracking and GC
07

Message Pipeline & Cost

4 patterns

How messages are normalized, costs tracked per-model, errors classified for both machines and humans.

  • 4-phase message normalization pipeline
  • Per-model cost accumulation with recursive advisor accounting
  • Dual-function error classification (classify + convert)
  • Post-tool hook lifecycle with permission lattice

What It Does

AskGet
How do permissions work?The 10-step cascade with pseudocode and edge cases
Set up auto-format hooksExact settings.json with PostToolUse hook config
Why was my command denied?Decision tree showing deny > ask > allow priority
Configure autonomous modePermission rules + deny safety net recipe
Build a plugin systemFilesystem loader, state migration, registry patterns
Design retry logicClassified retry with backoff, jitter, circuit breaker