From thinkkit
Reverse-engineer any codebase into a reconstruction-grade specification — a document thorough enough that a fresh Claude Code session could rebuild a functionally equivalent repo from scratch using only the spec. Supports both initial creation and incremental updates (detects an existing spec and updates only what changed), and scales from small projects to large monorepos (triages repo size, asks the user about depth vs. breadth, and switches to a hierarchical multi-file spec under `SPECIFICATION/` when appropriate, with optional multi-session coverage). Use this skill whenever the user asks to "create a spec", "write a specification", "update the spec", "reverse-engineer this codebase", "create a blueprint", or says anything about producing or refreshing a document that captures everything needed to recreate a project. Also trigger when the user wants to "snapshot the architecture" or "write a technical spec for this repo". Note: this is different from map-the-repo, which generates a browsable wiki. This skill produces a reconstruction-grade specification.
How this skill is triggered — by the user, by Claude, or both
Slash command
/thinkkit:create-spec [output path | --loop to auto-run the whole priority list on an existing hierarchical spec][output path | --loop to auto-run the whole priority list on an existing hierarchical spec]This skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate a specification that fully captures a repository's behavior,
Generate a specification that fully captures a repository's behavior,
architecture, and design intent — complete enough that another engineer (or
a fresh Claude Code session) could reconstruct a functionally equivalent
codebase from the spec alone, without ever seeing the original source.
For small/medium repos this is a single SPECIFICATION.md; for large
repos it becomes a hierarchical SPECIFICATION/ directory (see Phase 0.5).
Code is the "what." A specification captures the "what," "why," and "why not." When you need to port a project, onboard someone, survive a rewrite, or just create an insurance policy against losing context, a specification that can stand on its own is invaluable. The bar is high on purpose: if the spec has gaps, the rebuild will have bugs.
If the user provides an argument, use it as the output path. Otherwise:
SPECIFICATION.md in the repository root.SPECIFICATION/ directory in the repository
root (see Phase 0.5 and references/large-repo-process.md).The specification must include all of the following. Each section should be detailed enough that someone could implement it without ambiguity.
The deep review required to write this spec will surface issues that aren't visible from a casual read. Capture them here, categorized by type:
For each item, note what it is, where it is, and the potential impact. Prioritize by severity — security and correctness issues first, then reliability, then performance, then cleanup.
This is an iterative process. Rushing produces a spec with gaps, and gaps defeat the entire purpose. The pressure-test loop is what separates a useful spec from a superficial one.
Before doing anything else, check whether a specification already exists. Check both possible layouts:
SPECIFICATION.md in the repo root (or the
user-provided path).SPECIFICATION/ directory containing
index.md and manifest.json (used for large repos — see Phase 0.5
and references/large-repo-process.md).If no existing spec is found → proceed to Phase 0.5.
If a single-file spec is found, switch to incremental update mode:
git diff <spec-commit>..HEAD --stat to identify what files/modules
have changed since the spec was generated. If no commit hash is present,
fall back to a full review but still preserve unchanged sections.If a hierarchical spec is found, load references/large-repo-process.md
and follow its multi-session resume flow (Step 9). Do not fall through to
Phase 0.5 — the tier has already been decided.
If the user has also explicitly opted into autonomous loop mode — for
example by passing --loop as the skill argument, or by saying "do them
all," "run the whole priority list," "power through every subsystem," or
similar — follow Step 9.5 of the reference instead of Step 9's default
single-pick flow. Loop mode is never implicit: if the opt-in is at all
ambiguous, ask before entering it, and never auto-advance on a fresh
invocation without the user's words authorizing it this session.
Before starting exploration on a fresh spec, measure the repository:
git ls-files filtered to source extensions;
fall back to find if not a git repo. Exclude vendor/build/dist dirs.package.json, pom.xml, build.gradle,
Cargo.toml, go.mod, pyproject.toml, *.csproj, *.sln,
CMakeLists.txt, BUILD, BUILD.bazel.Classification:
Small/medium — <2,000 source files AND ≤10 top-level modules
→ proceed to Phase 1 with the standard single-file flow. Output goes
to SPECIFICATION.md.
Large — ≥2,000 source files OR >10 top-level modules
→ load references/large-repo-process.md and follow it from Step 1.
Do NOT begin exploration until the user has picked a tier. The
large-repo flow produces a hierarchical spec under SPECIFICATION/
(kept separate from source) and may span multiple sessions.
Before writing anything, thoroughly explore the codebase:
Spend real effort here. Read the actual source files, don't just skim file names. The quality of the spec depends entirely on how well you understand the codebase.
Write the full specification covering all required sections. Be specific:
use actual type names, actual field names, actual endpoint paths. Vague
hand-waving ("the system handles errors appropriately") is a gap. For
hierarchical mode, this draft spans the root index.md and each
subsystems/<name>.md — see references/large-repo-process.md Steps 5–7.
This is the critical quality step. For each iteration:
Step 1 — Gap detection (without re-reading source): Go through each section of the spec and ask: "Could I actually implement this module from what's written here?" Flag every ambiguity, missing detail, or assumption that isn't spelled out. Be adversarial — look for:
Step 2 — Resolve gaps (go back to source): For each flagged gap, re-read the relevant source code and extract the missing detail.
Step 3 — Update the spec: Incorporate all resolved gaps into SPECIFICATION.md.
Step 4 — Final validation: Walk through the codebase and confirm that every significant behavior, contract, and design decision is captured in the spec. Focus on behavioral completeness — could someone implement each module's responsibilities from what's written? List any remaining gaps.
Termination condition: Stop iterating when the gap list from Step 4 is empty OR contains only cosmetic items (variable names, comment style, whitespace formatting).
After the pressure test loop converges, write the final clean version of SPECIFICATION.md. Include a metadata header at the top:
<!-- spec-meta: { "generated": "YYYY-MM-DD", "commit": "<short-hash>", "iterations": N } -->
This metadata enables incremental updates (Phase 0) in future runs.
CLAUDE.md integration: After writing the spec, check whether a CLAUDE.md exists in the repository root. If it does, and it does not already mention the specification, append a Specification section.
For single-file (small/medium) specs, use:
## Specification
This repository has a machine-generated specification at `SPECIFICATION.md`
(or the custom path). When making implementation changes, update the
corresponding sections of the specification to keep it in sync. Run
`/thinkkit:create-spec` to perform an incremental update.
For hierarchical (large-repo) specs, use the variant in
references/large-repo-process.md Step 10, which points at
SPECIFICATION/index.md, the subsystems/ directory, and the manifest.
If no CLAUDE.md exists, add a brief maintenance note to the top of the root spec (just below the metadata header):
> **Maintenance:** When the implementation changes, re-run
> `/thinkkit:create-spec` to incrementally update this document.
Guides creation, editing, and verification of skills for AI coding agents using test-driven development with subagent scenarios. Use when authoring or debugging skills.
npx claudepluginhub rappdw/thinkkit --plugin thinkkit