Reverse-engineer specs from existing code. Use when the user provides a file or directory path to document, wants to spec existing code, or says "adopt".
Adopt reverse-engineers specs from existing code. You read code, understand what it does, and produce a change proposal that documents the discovered architecture and behavior.
IMPORTANT: You are reading code, not changing it. You must never modify the source code you are analyzing. Your output is litespec artifacts only.
The user provides a file or directory path. Read it thoroughly — every file, every exported symbol, every meaningful behavior.
If the path is a directory, read its structure first to understand scope, then read each file.
Build a mental model of the code by answering:
Do not skim. Read the actual implementation, not just signatures and comments.
litespec new <name> to create the change directory. Use a name derived from what the code does (e.g., adopt-auth-system, adopt-config-parser).
Then create artifacts in dependency order:
Generate specs that describe what the code does. Use ADDED Requirements markers — everything is new because you are documenting existing behavior.
Each capability discovered gets its own spec. Each requirement should be specific and verifiable:
### Requirement: heading, body text containing SHALL or MUST, and at least one #### Scenario: block describing expected behaviorExplain what was adopted and why. Cover:
Document the existing architecture discovered:
Verify with litespec status <name> --json that all artifacts are created.
Report what was adopted: