|
| 1 | +--- |
| 2 | +name: capture-knowledge |
| 3 | +description: Capture structured knowledge about a code entry point and save it to the knowledge docs. Use when users ask to document, understand, or map code for a module, file, folder, function, or API. |
| 4 | +--- |
| 5 | + |
| 6 | +# Knowledge Capture Assistant |
| 7 | + |
| 8 | +Build structured understanding of code entry points with an analysis-first workflow. |
| 9 | + |
| 10 | +## Hard Rule |
| 11 | +- Do not create documentation until the entry point is validated and analysis is complete. |
| 12 | + |
| 13 | +## Workflow |
| 14 | + |
| 15 | +1. Gather & Validate |
| 16 | +- Confirm entry point (file, folder, function, API), purpose, and desired depth. |
| 17 | +- Verify it exists; resolve ambiguity or suggest alternatives if not found. |
| 18 | + |
| 19 | +2. Collect Source Context |
| 20 | +- Summarize purpose, exports, key patterns. |
| 21 | +- Folders: list structure, highlight key modules. |
| 22 | +- Functions/APIs: capture signature, parameters, return values, error handling. |
| 23 | + |
| 24 | +3. Analyze Dependencies |
| 25 | +- Build dependency view up to depth 3, track visited nodes to avoid loops. |
| 26 | +- Categorize: imports, function calls, services, external packages. |
| 27 | +- Exclude external systems or generated code. |
| 28 | + |
| 29 | +4. Synthesize |
| 30 | +- Overview (purpose, language, high-level behavior). |
| 31 | +- Core logic, execution flow, patterns. |
| 32 | +- Error handling, performance, security considerations. |
| 33 | +- Improvements or risks discovered during analysis. |
| 34 | + |
| 35 | +5. Create Documentation |
| 36 | +- Normalize name to kebab-case (`calculateTotalPrice` → `calculate-total-price`). |
| 37 | +- Create `docs/ai/implementation/knowledge-{name}.md` using the Output Template. |
| 38 | +- Include mermaid diagrams when they clarify flows or relationships. |
| 39 | + |
| 40 | +## Validation |
| 41 | +- Documentation covers all Output Template sections. |
| 42 | +- Summarize key insights, open questions, and related areas for deeper dives. |
| 43 | +- Confirm file path and remind to commit. |
| 44 | + |
| 45 | +## Output Template |
| 46 | +- Overview |
| 47 | +- Implementation Details |
| 48 | +- Dependencies |
| 49 | +- Visual Diagrams (mermaid) |
| 50 | +- Additional Insights |
| 51 | +- Metadata (date, depth, files touched) |
| 52 | +- Next Steps |
0 commit comments