From spec-mirror
Generate end-to-end specification markdown files that mirror the current implementation as a safety net. Use when the user wants to extract, document, or snapshot the app's behavior — across frontend action flows, backend use cases, queries, and domain features. Triggers include "generate spec", "spec mirror", "e2e spec", "document app", "mirror implementation", "스펙 생성", "스펙 미러", "구현 스펙 만들어줘", "전체 스펙 정리". Produces layered specs (frontend / backend / domain) plus flow specs that cross-reference layers. Asks the user for a brief architecture confirmation after its own analysis, before writing files.
How this skill is triggered — by the user, by Claude, or both
Slash command
/spec-mirror:generateThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Generate a markdown specification suite that mirrors the **current implementation** of an application as a **safety net** against regression and drift. Output is **layered** (per architectural layer) *and* **flow-based** (per user journey), with the flow docs cross-referencing the layered docs.
Generate a markdown specification suite that mirrors the current implementation of an application as a safety net against regression and drift. Output is layered (per architectural layer) and flow-based (per user journey), with the flow docs cross-referencing the layered docs.
Invoke this skill when the user says any of:
Do not invoke for: refactoring tasks, bug fixes, or generic "explain this file" questions. This is a whole-app extraction workflow.
This skill MUST produce the following structure at the project root:
specs/
├── README.md # Index: layers + flows, last-generated timestamp
├── layers/
│ ├── frontend.md # Pages, components, actions, state, API calls
│ ├── backend.md # Endpoints, use cases / handlers, services
│ └── domain.md # Entities, value objects, invariants, queries
└── flows/
├── 01-<flow-slug>.md # E.g. 01-user-signup.md
├── 02-<flow-slug>.md
└── ...
refs/ # Human-curated knowledge (scaffolded, not auto-managed)
├── README.md # Explains the refs/ family
├── designs/
│ └── README.md # Conventions + template (no design files yet)
├── plans/
│ └── README.md
├── decisions/
│ └── README.md
└── lessons/
└── README.md
Why two trees: specs/ answers what is (auto-derived from code, regenerable). refs/ answers why and what's next (human-written, irretrievable from code). Both are needed for a real safety net. See docs/CONCEPTS.md.
Style rules:
→ src/path/to/file.ts:42 after each described element. If a claim cannot be sourced, mark it [INFERENCE] and explain in one line.[POST /api/auth/signup](../layers/backend.md#post-apiauthsignup).Acceptance Criteria must describe user/system outcomes. Put helper shape, page-object/screen-object structure, and test file layout under Testing Notes or Test Implementation Contract.YYYY-MM-DD when only a date is intended. Never write placeholder times such as 00:00:00 unless the source explicitly contains that value.package.json, pyproject.toml, pom.xml, go.mod, etc.).Output of this phase: a short internal summary (do not write to disk yet).
Before writing any specs, present your understanding back to the user in this exact format:
I detected the following architecture:
- Frontend: <framework + dir>
- Backend: <framework + dir>
- Domain: <detected? where? or "no explicit domain layer">
- Persistence: <ORM/DB driver>
- Identified user flows (initial list):
1. <flow name> — entry: <route or action>
2. ...
Confirm or correct briefly:
- Anything missing?
- Anything mislabeled?
- Any flow I should skip or prioritize?
Then wait for the user's response. Do not proceed without confirmation. Incorporate their corrections before Phase 2.
For each layer, scan the relevant directories and extract elements. Write the three layered files:
specs/layers/frontend.md — sections:
specs/layers/backend.md — sections:
specs/layers/domain.md — sections:
Each element follows this micro-template:
### <element name>
<1-3 sentence description.>
→ <relative/source/path.ext:line>
**Used by:** <list of cross-references>
For each user flow confirmed in Phase 1, write specs/flows/NN-<slug>.md with sections:
# Flow: <name>
**Trigger:** <how a user starts this flow>
**Outcome:** <what the user / system ends with>
## Steps
1. **<step label>** — <what happens>
- Frontend: [<component or action>](../layers/frontend.md#anchor)
- Backend: [<endpoint or handler>](../layers/backend.md#anchor)
- Domain: [<entity / invariant>](../layers/domain.md#anchor)
- Notes: <edge cases, validation, error paths>
2. ...
## Failure modes
- <error condition> → <how the system responds, with source>
## Acceptance Criteria
- <user/system observable outcome, not test helper structure>
## Testing Notes
- <optional: scenario object, page/screen object, fixture, helper, or command/query client shape>
Cross-link is mandatory — flow docs without links to layered docs fail the contract.
If a flow depends on event-driven read models, include a step-level note for projection catch-up. Do not mark catch-up as optional unless the read model is synchronously updated in the same request and the source line proves it.
Write specs/README.md:
<ISO timestamp>descriptive, stubs planned, or active tests, with the command that verifies it when knownrefs/ ("Why and what's next — see ../refs/")Scaffold refs/ (only if not already present — never overwrite human content):
refs/, refs/designs/, refs/plans/, refs/decisions/, refs/lessons/.assets/refs/ into the corresponding subdirs (e.g. assets/refs/designs-README.md → refs/designs/README.md).assets/refs/README.md → refs/README.md.Self-verify before reporting done:
→ path:line points to an existing file and a non-empty line.domain.md or a linked context-map section.[INFERENCE] markers without a one-line justification.[NOT FOUND] and describe where you looked.[INFERENCE — from signature]./spec-mirror:coverage reports executable tests covering the behavior.On a second invocation in the same project:
specs/ directory.<!-- KEEP --> ... <!-- /KEEP --> untouched.For read-only drift detection (no spec edits, safe in CI), use the companion skill /spec-mirror:compare instead — it produces specs/DRIFT.md without modifying any existing spec file.
You are done when:
specs/README.md exists and links to every other file under specs/.[INFERENCE].refs/ and its four subdirectories exist, each containing a README.md (templates from assets/refs/). Existing files left untouched.Provides a checklist for code reviews covering functionality, security, performance, maintainability, tests, and quality. Use for pull requests, audits, team standards, and developer training.
npx claudepluginhub edonghyun/donghyuns-agent-tools --plugin spec-mirror