您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

deep-dive-instructions.md 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. # Deep-Dive Documentation Instructions
  2. <workflow>
  3. <critical>This workflow performs exhaustive deep-dive documentation of specific areas</critical>
  4. <critical>Handles: deep_dive mode only</critical>
  5. <critical>YOU MUST ALWAYS SPEAK OUTPUT In your Agent communication style with the configured `{communication_language}`</critical>
  6. <critical>YOU MUST ALWAYS WRITE all artifact and document content in `{document_output_language}`</critical>
  7. <step n="13" goal="Deep-dive documentation of specific area" if="workflow_mode == deep_dive">
  8. <critical>Deep-dive mode requires literal full-file review. Sampling, guessing, or relying solely on tooling output is FORBIDDEN.</critical>
  9. <action>Load existing project structure from index.md and project-parts.json (if exists)</action>
  10. <action>Load source tree analysis to understand available areas</action>
  11. <step n="13a" goal="Identify area for deep-dive">
  12. <action>Analyze existing documentation to suggest deep-dive options</action>
  13. <ask>What area would you like to deep-dive into?
  14. **Suggested Areas Based on Project Structure:**
  15. {{#if has_api_routes}}
  16. ## API Routes ({{api_route_count}} endpoints found)
  17. {{#each api_route_groups}}
  18. {{group_index}}. {{group_name}} - {{endpoint_count}} endpoints in `{{path}}`
  19. {{/each}}
  20. {{/if}}
  21. {{#if has_feature_modules}}
  22. ## Feature Modules ({{feature_count}} features)
  23. {{#each feature_modules}}
  24. {{module_index}}. {{module_name}} - {{file_count}} files in `{{path}}`
  25. {{/each}}
  26. {{/if}}
  27. {{#if has_ui_components}}
  28. ### UI Component Areas
  29. {{#each component_groups}}
  30. {{group_index}}. {{group_name}} - {{component_count}} components in `{{path}}`
  31. {{/each}}
  32. {{/if}}
  33. {{#if has_services}}
  34. ### Services/Business Logic
  35. {{#each service_groups}}
  36. {{service_index}}. {{service_name}} - `{{path}}`
  37. {{/each}}
  38. {{/if}}
  39. **Or specify custom:**
  40. - Folder path (e.g., "client/src/features/dashboard")
  41. - File path (e.g., "server/src/api/users.ts")
  42. - Feature name (e.g., "authentication system")
  43. Enter your choice (number or custom path):
  44. </ask>
  45. <action>Parse user input to determine: - target_type: "folder" | "file" | "feature" | "api_group" | "component_group" - target_path: Absolute path to scan - target_name: Human-readable name for documentation - target_scope: List of all files to analyze
  46. </action>
  47. <action>Store as {{deep_dive_target}}</action>
  48. <action>Display confirmation:
  49. Target: {{target_name}}
  50. Type: {{target_type}}
  51. Path: {{target_path}}
  52. Estimated files to analyze: {{estimated_file_count}}
  53. This will read EVERY file in this area. Proceed? [y/n]
  54. </action>
  55. <action if="user confirms 'n'">Return to Step 13a (select different area)</action>
  56. </step>
  57. <step n="13b" goal="Comprehensive exhaustive scan of target area">
  58. <action>Set scan_mode = "exhaustive"</action>
  59. <action>Initialize file_inventory = []</action>
  60. <critical>You must read every line of every file in scope and capture a plain-language explanation (what the file does, side effects, why it matters) that future developer agents can act on. No shortcuts.</critical>
  61. <check if="target_type == folder">
  62. <action>Get complete recursive file list from {{target_path}}</action>
  63. <action>Filter out: node_modules/, .git/, dist/, build/, coverage/, *.min.js, *.map</action>
  64. <action>For EVERY remaining file in folder:
  65. - Read complete file contents (all lines)
  66. - Extract all exports (functions, classes, types, interfaces, constants)
  67. - Extract all imports (dependencies)
  68. - Identify purpose from comments and code structure
  69. - Write 1-2 sentences (minimum) in natural language describing behaviour, side effects, assumptions, and anything a developer must know before modifying the file
  70. - Extract function signatures with parameter types and return types
  71. - Note any TODOs, FIXMEs, or comments
  72. - Identify patterns (hooks, components, services, controllers, etc.)
  73. - Capture per-file contributor guidance: `contributor_note`, `risks`, `verification_steps`, `suggested_tests`
  74. - Store in file_inventory
  75. </action>
  76. </check>
  77. <check if="target_type == file">
  78. <action>Read complete file at {{target_path}}</action>
  79. <action>Extract all information as above</action>
  80. <action>Read all files it imports (follow import chain 1 level deep)</action>
  81. <action>Find all files that import this file (dependents via grep)</action>
  82. <action>Store all in file_inventory</action>
  83. </check>
  84. <check if="target_type == api_group">
  85. <action>Identify all route/controller files in API group</action>
  86. <action>Read all route handlers completely</action>
  87. <action>Read associated middleware, controllers, services</action>
  88. <action>Read data models and schemas used</action>
  89. <action>Extract complete request/response schemas</action>
  90. <action>Document authentication and authorization requirements</action>
  91. <action>Store all in file_inventory</action>
  92. </check>
  93. <check if="target_type == feature">
  94. <action>Search codebase for all files related to feature name</action>
  95. <action>Include: UI components, API endpoints, models, services, tests</action>
  96. <action>Read each file completely</action>
  97. <action>Store all in file_inventory</action>
  98. </check>
  99. <check if="target_type == component_group">
  100. <action>Get all component files in group</action>
  101. <action>Read each component completely</action>
  102. <action>Extract: Props interfaces, hooks used, child components, state management</action>
  103. <action>Store all in file_inventory</action>
  104. </check>
  105. <action>For each file in file\*inventory, document: - **File Path:** Full path - **Purpose:** What this file does (1-2 sentences) - **Lines of Code:** Total LOC - **Exports:** Complete list with signatures
  106. - Functions: `functionName(param: Type): ReturnType` - Description
  107. - Classes: `ClassName` - Description with key methods
  108. - Types/Interfaces: `TypeName` - Description
  109. - Constants: `CONSTANT_NAME: Type` - Description - **Imports/Dependencies:** What it uses and why - **Used By:** Files that import this (dependents) - **Key Implementation Details:** Important logic, algorithms, patterns - **State Management:** If applicable (Redux, Context, local state) - **Side Effects:** API calls, database queries, file I/O, external services - **Error Handling:** Try/catch blocks, error boundaries, validation - **Testing:** Associated test files and coverage - **Comments/TODOs:** Any inline documentation or planned work
  110. </action>
  111. <template-output>comprehensive_file_inventory</template-output>
  112. </step>
  113. <step n="13c" goal="Analyze relationships and data flow">
  114. <action>Build dependency graph for scanned area:
  115. - Create graph with files as nodes
  116. - Add edges for import relationships
  117. - Identify circular dependencies if any
  118. - Find entry points (files not imported by others in scope)
  119. - Find leaf nodes (files that don't import others in scope)
  120. </action>
  121. <action>Trace data flow through the system: - Follow function calls and data transformations - Track API calls and their responses - Document state updates and propagation - Map database queries and mutations
  122. </action>
  123. <action>Identify integration points: - External APIs consumed - Internal APIs/services called - Shared state accessed - Events published/subscribed - Database tables accessed
  124. </action>
  125. <template-output>dependency_graph</template-output>
  126. <template-output>data_flow_analysis</template-output>
  127. <template-output>integration_points</template-output>
  128. </step>
  129. <step n="13d" goal="Find related code and similar patterns">
  130. <action>Search codebase OUTSIDE scanned area for:
  131. - Similar file/folder naming patterns
  132. - Similar function signatures
  133. - Similar component structures
  134. - Similar API patterns
  135. - Reusable utilities that could be used
  136. </action>
  137. <action>Identify code reuse opportunities: - Shared utilities available - Design patterns used elsewhere - Component libraries available - Helper functions that could apply
  138. </action>
  139. <action>Find reference implementations: - Similar features in other parts of codebase - Established patterns to follow - Testing approaches used elsewhere
  140. </action>
  141. <template-output>related_code_references</template-output>
  142. <template-output>reuse_opportunities</template-output>
  143. </step>
  144. <step n="13e" goal="Generate comprehensive deep-dive documentation">
  145. <action>Create documentation filename: deep-dive-{{sanitized_target_name}}.md</action>
  146. <action>Aggregate contributor insights across files:
  147. - Combine unique risk/gotcha notes into {{risks_notes}}
  148. - Combine verification steps developers should run before changes into {{verification_steps}}
  149. - Combine recommended test commands into {{suggested_tests}}
  150. </action>
  151. <action>Load complete deep-dive template from: ../templates/deep-dive-template.md</action>
  152. <action>Fill template with all collected data from steps 13b-13d</action>
  153. <action>Write filled template to: {project_knowledge}/deep-dive-{{sanitized_target_name}}.md</action>
  154. <action>Validate deep-dive document completeness</action>
  155. <template-output>deep_dive_documentation</template-output>
  156. <action>Update state file: - Add to deep_dive_targets array: {"target_name": "{{target_name}}", "target_path": "{{target_path}}", "files_analyzed": {{file_count}}, "output_file": "deep-dive-{{sanitized_target_name}}.md", "timestamp": "{{now}}"} - Add output to outputs_generated - Update last_updated timestamp
  157. </action>
  158. </step>
  159. <step n="13f" goal="Update master index with deep-dive link">
  160. <action>Read existing index.md</action>
  161. <action>Check if "Deep-Dive Documentation" section exists</action>
  162. <check if="section does not exist">
  163. <action>Add new section after "Generated Documentation":
  164. ## Deep-Dive Documentation
  165. Detailed exhaustive analysis of specific areas:
  166. </action>
  167. </check>
  168. <action>Add link to new deep-dive doc:
  169. - [{{target_name}} Deep-Dive](./deep-dive-{{sanitized_target_name}}.md) - Comprehensive analysis of {{target_description}} ({{file_count}} files, {{total_loc}} LOC) - Generated {{date}}
  170. </action>
  171. <action>Update index metadata:
  172. Last Updated: {{date}}
  173. Deep-Dives: {{deep_dive_count}}
  174. </action>
  175. <action>Save updated index.md</action>
  176. <template-output>updated_index</template-output>
  177. </step>
  178. <step n="13g" goal="Offer to continue or complete">
  179. <action>Display summary:
  180. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  181. ## Deep-Dive Documentation Complete! ✓
  182. **Generated:** {project_knowledge}/deep-dive-{{target_name}}.md
  183. **Files Analyzed:** {{file_count}}
  184. **Lines of Code Scanned:** {{total_loc}}
  185. **Time Taken:** ~{{duration}}
  186. **Documentation Includes:**
  187. - Complete file inventory with all exports
  188. - Dependency graph and data flow
  189. - Integration points and API contracts
  190. - Testing analysis and coverage
  191. - Related code and reuse opportunities
  192. - Implementation guidance
  193. **Index Updated:** {project_knowledge}/index.md now includes link to this deep-dive
  194. ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  195. </action>
  196. <ask>Would you like to:
  197. 1. **Deep-dive another area** - Analyze another feature/module/folder
  198. 2. **Finish** - Complete workflow
  199. Your choice [1/2]:
  200. </ask>
  201. <action if="user selects 1">
  202. <action>Clear current deep_dive_target</action>
  203. <action>Go to Step 13a (select new area)</action>
  204. </action>
  205. <action if="user selects 2">
  206. <action>Display final message:
  207. All deep-dive documentation complete!
  208. **Master Index:** {project_knowledge}/index.md
  209. **Deep-Dives Generated:** {{deep_dive_count}}
  210. These comprehensive docs are now ready for:
  211. - Architecture review
  212. - Implementation planning
  213. - Code understanding
  214. - Brownfield PRD creation
  215. Thank you for using the document-project workflow!
  216. </action>
  217. <action>Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete` — if the resolved value is non-empty, follow it as the final terminal instruction before exiting.</action>
  218. <action>Exit workflow</action>
  219. </action>
  220. </step>
  221. </step>
  222. </workflow>