recipe-reverse-engineer
Generate PRD and Design Docs from existing codebase through discovery, generation, verification, and review workflow
What this skill does
**Context**: Reverse engineering workflow to create documentation from existing code Target: $ARGUMENTS ## Orchestrator Definition **Core Identity**: "I am an orchestrator." **Execution Protocol**: 1. **Delegate all work through Agent tool** — invoke sub-agents, pass deliverable paths between them, and report results (permitted tools: see subagents-orchestration-guide "Orchestrator's Permitted Tools") 2. **Process one step at a time**: Execute steps sequentially within each unit (2 → 3 → 4 → 5). Each step's output is the required input for the next step. Complete all steps for one unit before starting the next 3. **Pass `$STEP_N_OUTPUT` as-is** to sub-agents — the orchestrator bridges data without processing or filtering it **Task Registration**: Register phases first using TaskCreate, then steps within each phase as you enter it. Update status using TaskUpdate. ## Step 0: Initial Configuration ### 0.1 Scope Confirmation Use AskUserQuestion to confirm: 1. **Target path**: Which directory/module to document 2. **Depth**: PRD only, or PRD + Design Docs 3. **Reference Architecture**: layered / mvc / clean / hexagonal / none 4. **Human review**: Yes (recommended) / No (fully autonomous) 5. **Fullstack design**: Yes / No - Yes: For each functional unit, generate backend + frontend Design Docs - Note: Requires both agents (technical-designer, technical-designer-frontend) ### 0.2 Output Configuration - PRD output: `docs/prd/` or existing PRD directory - Design Doc output: `docs/design/` or existing design directory - Verify directories exist, create if needed ## Workflow Overview ``` Phase 1: PRD Generation Step 1: Scope Discovery (unified, single pass → group into PRD units → human review) Step 2-5: Per-unit loop (Generation → Verification → Review → Revision) Phase 2: Design Doc Generation (if requested) Step 6: Design Doc Scope Mapping (reuse Step 1 results, no re-discovery) Step 7-10: Per-unit loop (Generation → Verification → Review → Revision) ※ fullstack=Yes: each unit produces backend + frontend Design Docs ``` ## Phase 1: PRD Generation **Register using TaskCreate**: - Step 1: PRD Scope Discovery - Per-unit processing (Steps 2-5 for each unit) ### Step 1: PRD Scope Discovery **Agent tool invocation**: ``` subagent_type: dev-workflows:scope-discoverer description: "Discover functional scope" prompt: | Discover functional scope targets in the codebase. target_path: $USER_TARGET_PATH reference_architecture: $USER_RA_CHOICE focus_area: $USER_FOCUS_AREA (if specified) ``` **Store output as**: `$STEP_1_OUTPUT` **Quality Gate**: - At least one unit discovered → proceed - No units discovered → ask user for hints - `$STEP_1_OUTPUT.prdUnits` exists - All `sourceUnits` across `prdUnits` (flattened, deduplicated) match the set of `discoveredUnits` IDs — no unit missing, no unit duplicated - Each discovered unit's `unitInventory` has at least one non-empty category (routes, testFiles, or publicExports). Units with all three empty indicate incomplete discovery — re-run scope-discoverer with focus on that unit's relatedFiles **Human Review Point** (if enabled): Present `$STEP_1_OUTPUT.prdUnits` with their source unit mapping. The user confirms, adjusts grouping, or excludes units from scope. This is the most important review point — incorrect grouping cascades into all downstream documents. ### Step 2-5: Per-Unit Processing **FOR** each unit in `$STEP_1_OUTPUT.prdUnits` **(sequential, one unit at a time)**: #### Step 2: PRD Generation **Agent tool invocation**: ``` subagent_type: dev-workflows:prd-creator description: "Generate PRD" prompt: | Create reverse-engineered PRD for the following feature. Operation Mode: reverse-engineer External Scope Provided: true Feature: $PRD_UNIT_NAME (from $STEP_1_OUTPUT) Description: $PRD_UNIT_DESCRIPTION Related Files: $PRD_UNIT_COMBINED_RELATED_FILES Entry Points: $PRD_UNIT_COMBINED_ENTRY_POINTS Use provided scope as investigation starting point. If tracing entry points reveals files outside this scope, include them. Create final version PRD based on thorough code investigation. ``` **Store output as**: `$STEP_2_OUTPUT` (PRD path) #### Step 3: Code Verification **Prerequisite**: $STEP_2_OUTPUT (PRD path from Step 2) **Agent tool invocation**: ``` subagent_type: dev-workflows:code-verifier description: "Verify PRD consistency" prompt: | Verify consistency between PRD and code implementation. doc_type: prd document_path: $STEP_2_OUTPUT verbose: false ``` Note: Omit `code_paths` — the verifier independently discovers code scope from the document, ensuring independent verification not constrained by scope-discoverer's output. **Store output as**: `$STEP_3_OUTPUT` **Quality Gate**: - consistencyScore >= 70 AND verifiableClaimCount >= 20 → proceed to review - consistencyScore >= 70 BUT verifiableClaimCount < 20 → re-run verifier (investigation too shallow) - consistencyScore < 70 → flag for detailed review #### Step 4: Review **Required Input**: $STEP_3_OUTPUT (verification JSON from Step 3) **Agent tool invocation**: ``` subagent_type: dev-workflows:document-reviewer description: "Review PRD" prompt: | Review the following PRD considering code verification findings. doc_type: PRD target: $STEP_2_OUTPUT mode: composite code_verification: $STEP_3_OUTPUT ## Additional Review Focus - Alignment between PRD claims and verification evidence - Resolution recommendations for each discrepancy - Completeness of undocumented feature coverage ``` **Store output as**: `$STEP_4_OUTPUT` #### Step 5: Revision (conditional) **Trigger Conditions** (any one of the following): - Review status is "Needs Revision" or "Rejected" - Critical discrepancies exist in `$STEP_3_OUTPUT` - consistencyScore < 70 **Agent tool invocation**: ``` subagent_type: dev-workflows:prd-creator description: "Revise PRD" prompt: | Update PRD based on review feedback and code verification results. Operation Mode: update Existing PRD: $STEP_2_OUTPUT ## Review Feedback $STEP_4_OUTPUT ## Code Verification Results $STEP_3_OUTPUT Address discrepancies by severity. Critical and major items require correction. Minor items: correct if straightforward, otherwise leave as-is with rationale. ``` **Loop Control**: Maximum 2 revision cycles. After 2 cycles, flag for human review regardless of status. #### Unit Completion - [ ] Review status is "Approved" or "Approved with Conditions" - [ ] Human review passed (if enabled in Step 0) **Next**: Proceed to next unit. After all units → Phase 2. ## Phase 2: Design Doc Generation *Execute only if Design Docs were requested in Step 0* **Register using TaskCreate**: - Step 6: Design Doc Scope Mapping - Per-unit processing (Steps 7-10 for each unit) ### Step 6: Design Doc Scope Mapping **No additional discovery required.** Use `$STEP_1_OUTPUT.discoveredUnits` (implementation-granularity units) for technical profiles. Use `$STEP_1_OUTPUT.prdUnits[].sourceUnits` to trace which discovered units belong to each PRD unit. Each PRD unit from Phase 1 maps to Design Doc unit(s): - **Standard mode (fullstack=No)**: 1 PRD unit → 1 Design Doc (using technical-designer) - **Fullstack mode (fullstack=Yes)**: 1 PRD unit → 2 Design Docs (technical-designer + technical-designer-frontend) Map `$STEP_1_OUTPUT` units to Design Doc generation targets, carrying forward: - `technicalProfile.primaryModules` → Primary Files - `technicalProfile.publicInterfaces` → Public Interfaces - `dependencies` → Dependencies - `relatedFiles` → Scope boundary - `unitInventory` → Unit Inventory (routes, test files, public exports) **Store output as**: `$STEP_6_OUTPUT` ### Step 7-10: Per-Unit Processing **FOR** each unit in `$STEP_6_OUTPUT` **(sequential, one unit at a time)**: #### Step 7: Design Doc Generation **Scope**: Document the current architecture exactly as implemented in code. **Standard mode (fullstack=No)**: **Agent tool in
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.