reverse-claude
The reverse-engineering manual for Claude Code.
Extracted from ~28,000 lines of production source into actionable, portable patterns.
Install
npx skills add skillcreatorai/reverse-claudeWorks with Claude Code, Cursor, Windsurf, and any agent that supports skills.
Usage
/reverse-claude how does the permission cascade work?/reverse-claude lock down permissions for production/reverse-claude design a plugin discovery system7 Modules
Permissioned Invocation
7 patternsHow 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
Plugin & Skill Lifecycle
6 patternsHow 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
Agent Orchestration
7 patternsHow 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
Context Compaction & Retry
10 patternsHow 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
Self-Configuration
6 patternsPoint 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
Query Engine
3 patternsThe 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
Message Pipeline & Cost
4 patternsHow 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
| Ask | Get |
|---|---|
| How do permissions work? | The 10-step cascade with pseudocode and edge cases |
| Set up auto-format hooks | Exact settings.json with PostToolUse hook config |
| Why was my command denied? | Decision tree showing deny > ask > allow priority |
| Configure autonomous mode | Permission rules + deny safety net recipe |
| Build a plugin system | Filesystem loader, state migration, registry patterns |
| Design retry logic | Classified retry with backoff, jitter, circuit breaker |