@ggailabs/cli-context 0.5.6 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @ggailabs/cli-context might be problematic. Click here for more details.

Files changed (282) hide show
  1. package/README.md +25 -181
  2. package/dist/.context/docs/GENESIS_SYSTEM_PROMPT.md +62 -0
  3. package/dist/.context/eng/agents/architect.md +15 -0
  4. package/dist/.context/eng/agents/backend_typescript.md +1000 -0
  5. package/dist/.context/eng/agents/bug_hunter.md +49 -0
  6. package/dist/.context/eng/agents/code_reviewer.md +313 -0
  7. package/dist/.context/eng/agents/devops_specialist.md +718 -0
  8. package/dist/.context/eng/agents/frontend_specialist.md +1027 -0
  9. package/dist/.context/eng/agents/qa_specialist.md +1234 -0
  10. package/dist/.context/eng/agents/security_reviewer.md +382 -0
  11. package/dist/.context/eng/agents/ui_specialist.md +16 -0
  12. package/dist/.context/eng/docs/AGENT_HANDOFF_PROMPT.md +44 -0
  13. package/dist/.context/eng/docs/GENESIS_DESIGN_SYSTEM.md +15 -0
  14. package/dist/.context/eng/docs/GG_METHODOLOGY.md +48 -0
  15. package/dist/.context/eng/docs/OPERATIONS_LOG.md +30 -0
  16. package/dist/.context/eng/docs/PROJECT_MAP.md +35 -0
  17. package/dist/.context/eng/docs/standards/devops.md +0 -0
  18. package/dist/.context/eng/docs/standards/frontend.md +0 -0
  19. package/dist/.context/eng/docs/standards/typescript.md +12 -0
  20. package/dist/.context/eng/skills/agent_logging.md +18 -0
  21. package/dist/.context/eng/skills/brainstorming.md +227 -0
  22. package/dist/.context/eng/skills/exploring_codebase.md +1217 -0
  23. package/dist/.context/eng/skills/patterns/compliance_check.md +246 -0
  24. package/dist/.context/eng/skills/patterns/coverage_table.md +401 -0
  25. package/dist/.context/eng/skills/patterns/exit_criteria.md +31 -0
  26. package/dist/.context/eng/skills/patterns/failure_recovery.md +74 -0
  27. package/dist/.context/eng/skills/patterns/quality_gate.md +295 -0
  28. package/dist/.context/eng/skills/patterns/standards_workflow.md +391 -0
  29. package/dist/.context/eng/skills/patterns/state_tracking.md +30 -0
  30. package/dist/.context/eng/skills/patterns/task_tracking.md +38 -0
  31. package/dist/.context/eng/skills/previce.md +45 -0
  32. package/dist/.context/eng/skills/tdd.md +421 -0
  33. package/dist/.context/eng/skills/writing_plans.md +105 -0
  34. package/dist/.context/plans/.gitkeep +0 -0
  35. package/dist/.context/pt-br/agents/architect.md +69 -0
  36. package/dist/.context/pt-br/agents/backend_typescript.md +1000 -0
  37. package/dist/.context/pt-br/agents/bug_hunter.md +49 -0
  38. package/dist/.context/pt-br/agents/code_reviewer.md +313 -0
  39. package/dist/.context/pt-br/agents/devops_specialist.md +718 -0
  40. package/dist/.context/pt-br/agents/frontend_specialist.md +1027 -0
  41. package/dist/.context/pt-br/agents/qa_specialist.md +1234 -0
  42. package/dist/.context/pt-br/agents/security_reviewer.md +382 -0
  43. package/dist/.context/pt-br/agents/ui_specialist.md +55 -0
  44. package/dist/.context/pt-br/docs/AGENT_HANDOFF_PROMPT.md +44 -0
  45. package/dist/.context/pt-br/docs/GENESIS_DESIGN_SYSTEM.md +88 -0
  46. package/dist/.context/pt-br/docs/GG_METHODOLOGY.md +48 -0
  47. package/dist/.context/pt-br/docs/OPERATIONS_LOG.md +30 -0
  48. package/dist/.context/pt-br/docs/PROJECT_MAP.md +37 -0
  49. package/dist/.context/pt-br/docs/standards/devops.md +707 -0
  50. package/dist/.context/pt-br/docs/standards/frontend.md +748 -0
  51. package/dist/.context/pt-br/docs/standards/typescript.md +1150 -0
  52. package/dist/.context/pt-br/skills/agent_logging.md +36 -0
  53. package/dist/.context/pt-br/skills/brainstorming.md +227 -0
  54. package/dist/.context/pt-br/skills/exploring_codebase.md +1217 -0
  55. package/dist/.context/pt-br/skills/patterns/compliance_check.md +246 -0
  56. package/dist/.context/pt-br/skills/patterns/coverage_table.md +401 -0
  57. package/dist/.context/pt-br/skills/patterns/exit_criteria.md +31 -0
  58. package/dist/.context/pt-br/skills/patterns/failure_recovery.md +74 -0
  59. package/dist/.context/pt-br/skills/patterns/quality_gate.md +295 -0
  60. package/dist/.context/pt-br/skills/patterns/standards_workflow.md +391 -0
  61. package/dist/.context/pt-br/skills/patterns/state_tracking.md +30 -0
  62. package/dist/.context/pt-br/skills/patterns/task_tracking.md +38 -0
  63. package/dist/.context/pt-br/skills/previce.md +45 -0
  64. package/dist/.context/pt-br/skills/tdd.md +421 -0
  65. package/dist/.context/pt-br/skills/writing_plans.md +105 -0
  66. package/dist/.context/workflow/.gitkeep +0 -0
  67. package/dist/commands/init.js +140 -0
  68. package/dist/commands/monitor.js +34 -0
  69. package/dist/index.js +20 -568
  70. package/dist/services/monitor-service.js +340 -0
  71. package/dist/services/scaffolder.js +164 -0
  72. package/package.json +16 -58
  73. package/LICENSE +0 -21
  74. package/dist/generators/agents/agentConfig.d.ts +0 -4
  75. package/dist/generators/agents/agentConfig.d.ts.map +0 -1
  76. package/dist/generators/agents/agentConfig.js +0 -180
  77. package/dist/generators/agents/agentConfig.js.map +0 -1
  78. package/dist/generators/agents/agentGenerator.d.ts +0 -9
  79. package/dist/generators/agents/agentGenerator.d.ts.map +0 -1
  80. package/dist/generators/agents/agentGenerator.js +0 -97
  81. package/dist/generators/agents/agentGenerator.js.map +0 -1
  82. package/dist/generators/agents/agentTypes.d.ts +0 -4
  83. package/dist/generators/agents/agentTypes.d.ts.map +0 -1
  84. package/dist/generators/agents/agentTypes.js +0 -25
  85. package/dist/generators/agents/agentTypes.js.map +0 -1
  86. package/dist/generators/agents/index.d.ts +0 -4
  87. package/dist/generators/agents/index.d.ts.map +0 -1
  88. package/dist/generators/agents/index.js +0 -12
  89. package/dist/generators/agents/index.js.map +0 -1
  90. package/dist/generators/agents/templates/index.d.ts +0 -4
  91. package/dist/generators/agents/templates/index.d.ts.map +0 -1
  92. package/dist/generators/agents/templates/index.js +0 -8
  93. package/dist/generators/agents/templates/index.js.map +0 -1
  94. package/dist/generators/agents/templates/indexTemplate.d.ts +0 -3
  95. package/dist/generators/agents/templates/indexTemplate.d.ts.map +0 -1
  96. package/dist/generators/agents/templates/indexTemplate.js +0 -36
  97. package/dist/generators/agents/templates/indexTemplate.js.map +0 -1
  98. package/dist/generators/agents/templates/playbookTemplate.d.ts +0 -4
  99. package/dist/generators/agents/templates/playbookTemplate.d.ts.map +0 -1
  100. package/dist/generators/agents/templates/playbookTemplate.js +0 -99
  101. package/dist/generators/agents/templates/playbookTemplate.js.map +0 -1
  102. package/dist/generators/agents/templates/types.d.ts +0 -14
  103. package/dist/generators/agents/templates/types.d.ts.map +0 -1
  104. package/dist/generators/agents/templates/types.js +0 -3
  105. package/dist/generators/agents/templates/types.js.map +0 -1
  106. package/dist/generators/documentation/documentationGenerator.d.ts +0 -15
  107. package/dist/generators/documentation/documentationGenerator.d.ts.map +0 -1
  108. package/dist/generators/documentation/documentationGenerator.js +0 -188
  109. package/dist/generators/documentation/documentationGenerator.js.map +0 -1
  110. package/dist/generators/documentation/guideRegistry.d.ts +0 -6
  111. package/dist/generators/documentation/guideRegistry.d.ts.map +0 -1
  112. package/dist/generators/documentation/guideRegistry.js +0 -82
  113. package/dist/generators/documentation/guideRegistry.js.map +0 -1
  114. package/dist/generators/documentation/index.d.ts +0 -2
  115. package/dist/generators/documentation/index.d.ts.map +0 -1
  116. package/dist/generators/documentation/index.js +0 -6
  117. package/dist/generators/documentation/index.js.map +0 -1
  118. package/dist/generators/documentation/templates/apiReferenceTemplate.d.ts +0 -2
  119. package/dist/generators/documentation/templates/apiReferenceTemplate.d.ts.map +0 -1
  120. package/dist/generators/documentation/templates/apiReferenceTemplate.js +0 -490
  121. package/dist/generators/documentation/templates/apiReferenceTemplate.js.map +0 -1
  122. package/dist/generators/documentation/templates/architectureTemplate.d.ts +0 -3
  123. package/dist/generators/documentation/templates/architectureTemplate.d.ts.map +0 -1
  124. package/dist/generators/documentation/templates/architectureTemplate.js +0 -66
  125. package/dist/generators/documentation/templates/architectureTemplate.js.map +0 -1
  126. package/dist/generators/documentation/templates/common.d.ts +0 -7
  127. package/dist/generators/documentation/templates/common.d.ts.map +0 -1
  128. package/dist/generators/documentation/templates/common.js +0 -58
  129. package/dist/generators/documentation/templates/common.js.map +0 -1
  130. package/dist/generators/documentation/templates/dataFlowTemplate.d.ts +0 -3
  131. package/dist/generators/documentation/templates/dataFlowTemplate.d.ts.map +0 -1
  132. package/dist/generators/documentation/templates/dataFlowTemplate.js +0 -40
  133. package/dist/generators/documentation/templates/dataFlowTemplate.js.map +0 -1
  134. package/dist/generators/documentation/templates/developmentWorkflowTemplate.d.ts +0 -2
  135. package/dist/generators/documentation/templates/developmentWorkflowTemplate.d.ts.map +0 -1
  136. package/dist/generators/documentation/templates/developmentWorkflowTemplate.js +0 -44
  137. package/dist/generators/documentation/templates/developmentWorkflowTemplate.js.map +0 -1
  138. package/dist/generators/documentation/templates/glossaryTemplate.d.ts +0 -3
  139. package/dist/generators/documentation/templates/glossaryTemplate.d.ts.map +0 -1
  140. package/dist/generators/documentation/templates/glossaryTemplate.js +0 -41
  141. package/dist/generators/documentation/templates/glossaryTemplate.js.map +0 -1
  142. package/dist/generators/documentation/templates/index.d.ts +0 -15
  143. package/dist/generators/documentation/templates/index.d.ts.map +0 -1
  144. package/dist/generators/documentation/templates/index.js +0 -30
  145. package/dist/generators/documentation/templates/index.js.map +0 -1
  146. package/dist/generators/documentation/templates/indexTemplate.d.ts +0 -3
  147. package/dist/generators/documentation/templates/indexTemplate.d.ts.map +0 -1
  148. package/dist/generators/documentation/templates/indexTemplate.js +0 -42
  149. package/dist/generators/documentation/templates/indexTemplate.js.map +0 -1
  150. package/dist/generators/documentation/templates/migrationTemplate.d.ts +0 -2
  151. package/dist/generators/documentation/templates/migrationTemplate.d.ts.map +0 -1
  152. package/dist/generators/documentation/templates/migrationTemplate.js +0 -422
  153. package/dist/generators/documentation/templates/migrationTemplate.js.map +0 -1
  154. package/dist/generators/documentation/templates/onboardingTemplate.d.ts +0 -2
  155. package/dist/generators/documentation/templates/onboardingTemplate.d.ts.map +0 -1
  156. package/dist/generators/documentation/templates/onboardingTemplate.js +0 -431
  157. package/dist/generators/documentation/templates/onboardingTemplate.js.map +0 -1
  158. package/dist/generators/documentation/templates/projectOverviewTemplate.d.ts +0 -3
  159. package/dist/generators/documentation/templates/projectOverviewTemplate.d.ts.map +0 -1
  160. package/dist/generators/documentation/templates/projectOverviewTemplate.js +0 -65
  161. package/dist/generators/documentation/templates/projectOverviewTemplate.js.map +0 -1
  162. package/dist/generators/documentation/templates/securityTemplate.d.ts +0 -2
  163. package/dist/generators/documentation/templates/securityTemplate.d.ts.map +0 -1
  164. package/dist/generators/documentation/templates/securityTemplate.js +0 -39
  165. package/dist/generators/documentation/templates/securityTemplate.js.map +0 -1
  166. package/dist/generators/documentation/templates/testingTemplate.d.ts +0 -2
  167. package/dist/generators/documentation/templates/testingTemplate.d.ts.map +0 -1
  168. package/dist/generators/documentation/templates/testingTemplate.js +0 -45
  169. package/dist/generators/documentation/templates/testingTemplate.js.map +0 -1
  170. package/dist/generators/documentation/templates/toolingTemplate.d.ts +0 -2
  171. package/dist/generators/documentation/templates/toolingTemplate.d.ts.map +0 -1
  172. package/dist/generators/documentation/templates/toolingTemplate.js +0 -42
  173. package/dist/generators/documentation/templates/toolingTemplate.js.map +0 -1
  174. package/dist/generators/documentation/templates/troubleshootingTemplate.d.ts +0 -2
  175. package/dist/generators/documentation/templates/troubleshootingTemplate.d.ts.map +0 -1
  176. package/dist/generators/documentation/templates/troubleshootingTemplate.js +0 -292
  177. package/dist/generators/documentation/templates/troubleshootingTemplate.js.map +0 -1
  178. package/dist/generators/documentation/templates/types.d.ts +0 -23
  179. package/dist/generators/documentation/templates/types.d.ts.map +0 -1
  180. package/dist/generators/documentation/templates/types.js +0 -3
  181. package/dist/generators/documentation/templates/types.js.map +0 -1
  182. package/dist/generators/plans/index.d.ts +0 -2
  183. package/dist/generators/plans/index.d.ts.map +0 -1
  184. package/dist/generators/plans/index.js +0 -6
  185. package/dist/generators/plans/index.js.map +0 -1
  186. package/dist/generators/plans/planGenerator.d.ts +0 -22
  187. package/dist/generators/plans/planGenerator.d.ts.map +0 -1
  188. package/dist/generators/plans/planGenerator.js +0 -109
  189. package/dist/generators/plans/planGenerator.js.map +0 -1
  190. package/dist/generators/plans/templates/indexTemplate.d.ts +0 -3
  191. package/dist/generators/plans/templates/indexTemplate.d.ts.map +0 -1
  192. package/dist/generators/plans/templates/indexTemplate.js +0 -37
  193. package/dist/generators/plans/templates/indexTemplate.js.map +0 -1
  194. package/dist/generators/plans/templates/planTemplate.d.ts +0 -3
  195. package/dist/generators/plans/templates/planTemplate.d.ts.map +0 -1
  196. package/dist/generators/plans/templates/planTemplate.js +0 -166
  197. package/dist/generators/plans/templates/planTemplate.js.map +0 -1
  198. package/dist/generators/plans/templates/types.d.ts +0 -19
  199. package/dist/generators/plans/templates/types.d.ts.map +0 -1
  200. package/dist/generators/plans/templates/types.js +0 -3
  201. package/dist/generators/plans/templates/types.js.map +0 -1
  202. package/dist/generators/shared/contextGenerator.d.ts +0 -7
  203. package/dist/generators/shared/contextGenerator.d.ts.map +0 -1
  204. package/dist/generators/shared/contextGenerator.js +0 -13
  205. package/dist/generators/shared/contextGenerator.js.map +0 -1
  206. package/dist/generators/shared/directoryTemplateHelpers.d.ts +0 -2
  207. package/dist/generators/shared/directoryTemplateHelpers.d.ts.map +0 -1
  208. package/dist/generators/shared/directoryTemplateHelpers.js +0 -12
  209. package/dist/generators/shared/directoryTemplateHelpers.js.map +0 -1
  210. package/dist/generators/shared/generatorUtils.d.ts +0 -16
  211. package/dist/generators/shared/generatorUtils.d.ts.map +0 -1
  212. package/dist/generators/shared/generatorUtils.js +0 -119
  213. package/dist/generators/shared/generatorUtils.js.map +0 -1
  214. package/dist/generators/shared/index.d.ts +0 -4
  215. package/dist/generators/shared/index.d.ts.map +0 -1
  216. package/dist/generators/shared/index.js +0 -10
  217. package/dist/generators/shared/index.js.map +0 -1
  218. package/dist/index.d.ts +0 -9
  219. package/dist/index.d.ts.map +0 -1
  220. package/dist/index.js.map +0 -1
  221. package/dist/prompts/defaults.d.ts +0 -3
  222. package/dist/prompts/defaults.d.ts.map +0 -1
  223. package/dist/prompts/defaults.js +0 -95
  224. package/dist/prompts/defaults.js.map +0 -1
  225. package/dist/services/baseLLMClient.d.ts +0 -12
  226. package/dist/services/baseLLMClient.d.ts.map +0 -1
  227. package/dist/services/baseLLMClient.js +0 -80
  228. package/dist/services/baseLLMClient.js.map +0 -1
  229. package/dist/services/fill/fillService.d.ts +0 -46
  230. package/dist/services/fill/fillService.d.ts.map +0 -1
  231. package/dist/services/fill/fillService.js +0 -254
  232. package/dist/services/fill/fillService.js.map +0 -1
  233. package/dist/services/init/initService.d.ts +0 -37
  234. package/dist/services/init/initService.d.ts.map +0 -1
  235. package/dist/services/init/initService.js +0 -167
  236. package/dist/services/init/initService.js.map +0 -1
  237. package/dist/services/llmClientFactory.d.ts +0 -8
  238. package/dist/services/llmClientFactory.d.ts.map +0 -1
  239. package/dist/services/llmClientFactory.js +0 -23
  240. package/dist/services/llmClientFactory.js.map +0 -1
  241. package/dist/services/openRouterClient.d.ts +0 -9
  242. package/dist/services/openRouterClient.d.ts.map +0 -1
  243. package/dist/services/openRouterClient.js +0 -49
  244. package/dist/services/openRouterClient.js.map +0 -1
  245. package/dist/services/plan/planService.d.ts +0 -57
  246. package/dist/services/plan/planService.d.ts.map +0 -1
  247. package/dist/services/plan/planService.js +0 -334
  248. package/dist/services/plan/planService.js.map +0 -1
  249. package/dist/services/shared/llmConfig.d.ts +0 -22
  250. package/dist/services/shared/llmConfig.d.ts.map +0 -1
  251. package/dist/services/shared/llmConfig.js +0 -38
  252. package/dist/services/shared/llmConfig.js.map +0 -1
  253. package/dist/types.d.ts +0 -65
  254. package/dist/types.d.ts.map +0 -1
  255. package/dist/types.js +0 -3
  256. package/dist/types.js.map +0 -1
  257. package/dist/utils/cliUI.d.ts +0 -27
  258. package/dist/utils/cliUI.d.ts.map +0 -1
  259. package/dist/utils/cliUI.js +0 -252
  260. package/dist/utils/cliUI.js.map +0 -1
  261. package/dist/utils/fileMapper.d.ts +0 -11
  262. package/dist/utils/fileMapper.d.ts.map +0 -1
  263. package/dist/utils/fileMapper.js +0 -146
  264. package/dist/utils/fileMapper.js.map +0 -1
  265. package/dist/utils/gitService.d.ts +0 -50
  266. package/dist/utils/gitService.d.ts.map +0 -1
  267. package/dist/utils/gitService.js +0 -470
  268. package/dist/utils/gitService.js.map +0 -1
  269. package/dist/utils/i18n.d.ts +0 -171
  270. package/dist/utils/i18n.d.ts.map +0 -1
  271. package/dist/utils/i18n.js +0 -381
  272. package/dist/utils/i18n.js.map +0 -1
  273. package/dist/utils/promptLoader.d.ts +0 -12
  274. package/dist/utils/promptLoader.d.ts.map +0 -1
  275. package/dist/utils/promptLoader.js +0 -81
  276. package/dist/utils/promptLoader.js.map +0 -1
  277. package/dist/utils/versionChecker.d.ts +0 -15
  278. package/dist/utils/versionChecker.d.ts.map +0 -1
  279. package/dist/utils/versionChecker.js +0 -49
  280. package/dist/utils/versionChecker.js.map +0 -1
  281. package/prompts/update_plan_prompt.md +0 -41
  282. package/prompts/update_scaffold_prompt.md +0 -47
@@ -0,0 +1,1217 @@
1
+ ---
2
+ name: ring:exploring-codebase
3
+ description: |
4
+ Autonomous two-phase codebase exploration - first discovers natural perspectives
5
+ (layers, components, boundaries), then dispatches adaptive deep-dive explorers
6
+ based on what was discovered. Synthesizes findings into actionable insights.
7
+
8
+ trigger: |
9
+ - Need to understand how a feature/system works across the codebase
10
+ - Starting work on unfamiliar codebase or component
11
+ - Planning changes that span multiple layers/components
12
+ - User asks "how does X work?" for non-trivial X
13
+ - Need architecture understanding before implementation
14
+
15
+ skip_when: |
16
+ - Pure reference lookup (function signature, type definition)
17
+ - Checking if specific file exists (yes/no question)
18
+ - Reading error message from known file location
19
+
20
+ WARNING: These are NOT valid skip reasons:
21
+ - "I already know the architecture" → Prior knowledge is incomplete
22
+ - "Simple question about location" → Location without context is incomplete
23
+ - "Production emergency, no time" → High stakes demand MORE rigor
24
+ - "Colleague told me structure" → High-level ≠ implementation details
25
+
26
+ related:
27
+ similar: [dispatching-parallel-agents, systematic-debugging]
28
+ sequence_after: [brainstorming]
29
+ sequence_before: [ring:writing-plans, ring:executing-plans]
30
+ ---
31
+
32
+ # Autonomous Two-Phase Codebase Exploration
33
+
34
+ ## Overview
35
+
36
+ Traditional exploration assumes structure upfront or explores sequentially. This skill takes an autonomous two-phase approach: **discover** the natural perspectives of the codebase first, then **deep dive** into each discovered perspective with targeted explorers.
37
+
38
+ **Core principle:** Let the codebase reveal its own structure, then explore each structure element thoroughly with adaptive parallel agents.
39
+
40
+ **MANDATORY ANNOUNCEMENT at start:**
41
+
42
+ "I'm using the ring:exploring-codebase skill to autonomously discover and explore the codebase structure.
43
+
44
+ Before proceeding, I've checked the Red Flags table and confirmed:
45
+ - [X] Production pressure makes me WANT to skip discovery → Using skill anyway
46
+ - [X] I think I 'already know' the structure → Discovery will validate assumptions
47
+ - [X] This seems like a simple question → Location without context is incomplete
48
+ - [X] Colleague gave me high-level info → Discovery finds what they forgot
49
+
50
+ The skill's core principle: **When pressure is highest, systematic approach matters most.**"
51
+
52
+ ## 🚨 Red Flags: When You're About to Make a Mistake
53
+
54
+ **STOP and use this skill if you catch yourself thinking:**
55
+
56
+ | Red Flag Thought | What It Means | Do This Instead |
57
+ |------------------|---------------|-----------------|
58
+ | "I already know this architecture" | ⚠️ Dunning-Kruger | Run discovery to validate assumptions |
59
+ | "Grep is faster for this simple question" | ⚠️ Optimizing for feeling productive | One exploration > multiple follow-ups |
60
+ | "Production is down, no time for process" | ⚠️ Panic mode | High stakes demand MORE rigor |
61
+ | "Colleague told me the structure" | ⚠️ Trusting abstractions | Discovery finds what they forgot |
62
+ | "Being pragmatic means skipping this" | ⚠️ Conflating speed with value | Real pragmatism = doing it right |
63
+ | "This is overkill for..." | ⚠️ Underestimating complexity | Incomplete understanding compounds |
64
+ | "I'll explore progressively if I get stuck" | ⚠️ Reactive vs proactive | Discovery prevents getting stuck |
65
+ | "Let me just quickly check..." | ⚠️ Ad-hoc investigation trap | Systematic > ad-hoc |
66
+
67
+ **If 2+ red flags triggered: YOU NEED THIS SKILL.**
68
+
69
+ ## 💥 Violation Consequences: Real Costs of Skipping
70
+
71
+ **"What's the worst that could happen if I skip discovery?"**
72
+
73
+ ### Consequence 1: The Cascade Effect
74
+ **Scenario:** Skip discovery → Fix in wrong component → Break integration → New production issue
75
+
76
+ **Example:**
77
+ - Bug: "Account creation failing"
78
+ - Assumption: "It's in onboarding component"
79
+ - Reality: Transaction component has new validation that breaks onboarding
80
+ - Your fix: Modify onboarding (wrong component)
81
+ - Result: Original bug persists, NEW bug in onboarding, 2 issues instead of 1
82
+
83
+ **Discovery would have revealed:** Transaction component owns the validation now.
84
+
85
+ ### Consequence 2: The Multiple Round-Trip Effect
86
+ **Scenario:** Grep for location → Answer question → User asks follow-up → Grep again → Another follow-up
87
+
88
+ **Example:**
89
+ - Q1: "Where is validation?" → Grep → Answer: `validation.go:45`
90
+ - Q2: "How does it integrate?" → Read files → Answer: "Called from use case"
91
+ - Q3: "What else validates?" → Grep again → Answer: "Assert package + HTTP layer"
92
+ - **Total: 3 round trips, 15 minutes, incomplete mental model**
93
+
94
+ **Exploration would have provided:** All answers in one comprehensive document, 10 minutes total.
95
+
96
+ ### Consequence 3: The Stale Knowledge Effect
97
+ **Scenario:** "I already know" → Work based on old mental model → Code has changed → Wrong implementation
98
+
99
+ **Example:**
100
+ - Your knowledge: "3 components (onboarding, transaction, crm)"
101
+ - Reality: New `audit` component added last month for compliance
102
+ - Your fix: Modify account creation in onboarding
103
+ - Missing: Audit component now logs all account operations
104
+ - Result: Account created but not audited, compliance violation
105
+
106
+ **Discovery would have revealed:** 4 components now, audit is mandatory.
107
+
108
+ ### Consequence 4: The Hidden Dependencies Effect
109
+ **Scenario:** Skip discovery → Miss shared libraries → Duplicate code → Technical debt
110
+
111
+ **Example:**
112
+ - Task: Add account validation rule
113
+ - Grep finds: `create-account.go` has validation
114
+ - You add: New validation in same file
115
+ - Discovery would reveal: `pkg/validator/account.go` has shared validation library
116
+ - Result: Duplicate logic, inconsistent validation across codebase
117
+
118
+ **Discovery would have revealed:** Centralized validation library for reuse.
119
+
120
+ ### Cost Summary Table
121
+
122
+ | Skip Reason | Time "Saved" | Actual Cost | Net Loss |
123
+ |-------------|--------------|-------------|----------|
124
+ | "I already know" | 6-10 min | 2+ hours debugging stale knowledge | -110 to -114 min |
125
+ | "Simple question" | 6-10 min | 3 round trips × 5 min each = 15 min | -5 to -9 min |
126
+ | "Production emergency" | 6-10 min | Wrong fix + cascade = 2+ hours | -110 to -114 min |
127
+ | "Colleague told me" | 6-10 min | Missing component/library = 1+ hour rework | -50 to -54 min |
128
+
129
+ **Pattern:** Every "time-saving" skip costs more time than it saves.**
130
+
131
+ ## The Two-Phase Flow
132
+
133
+ ### Phase 1: Discovery Pass (Meta-Exploration)
134
+ **Goal:** Understand "What IS this codebase?"
135
+
136
+ Launch 3-4 **discovery agents** to identify:
137
+ - Architecture pattern (hexagonal, layered, microservices, etc.)
138
+ - Major components/modules
139
+ - Natural boundaries and layers
140
+ - Organization principles
141
+ - Key technologies and frameworks
142
+
143
+ **Output:** Structural map of the codebase
144
+
145
+ ### Phase 2: Deep Dive Pass (Adaptive Exploration)
146
+ **Goal:** Understand "How does [target] work in each discovered area?"
147
+
148
+ Based on Phase 1 discoveries, launch **N targeted explorers** (where N adapts):
149
+ - One explorer per discovered perspective/component/layer
150
+ - Each explorer focuses on the target within their scope
151
+ - Number and type of explorers match codebase structure
152
+
153
+ **Output:** Comprehensive understanding of target across all perspectives
154
+
155
+ ## When to Use
156
+
157
+ **Decision flow:**
158
+ - Need codebase understanding? → Is it trivial (single file/function)? → Yes = Use Read/Grep directly
159
+ - No → Is it unfamiliar territory or spans multiple areas? → Yes = **Two-phase exploration**
160
+ - Are you about to make changes spanning multiple components? → Yes = **Two-phase exploration**
161
+
162
+ **Use when:**
163
+ - Understanding how a feature works in an unfamiliar codebase
164
+ - Starting work on new component/service
165
+ - Planning architectural changes
166
+ - Need to find where to implement new functionality
167
+ - User asks "how does X work?" for complex X in unknown codebase
168
+
169
+ **Don't use when:**
170
+ - Pure reference lookup: "What's the signature of function X?"
171
+ - File existence check: "Does utils.go exist?"
172
+ - Reading known error location: "Show me line 45 of errors.go"
173
+
174
+ **COMMON TRAPS - These SEEM like valid skip reasons but are NOT:**
175
+
176
+ ### ❌ Trap 1: "Simple Question About Location"
177
+ **Rationalization:** "User just asked 'where is X?' - grep is faster"
178
+
179
+ **Reality:** Location questions lead to "how does X work?" next
180
+ - Question: "Where is validation logic?"
181
+ - Grep answer: `validation.go:45`
182
+ - Follow-up: "How does it integrate with the system?"
183
+ - Follow-up: "What else validates this?"
184
+ - **Result:** 3 questions, incomplete picture, wasted time
185
+
186
+ **Counter:** Run exploration once, answer current + future questions.
187
+
188
+ ### ❌ Trap 2: "I Already Know the Architecture"
189
+ **Rationalization:** "I worked here before, discovery is redundant"
190
+
191
+ **Reality:** Prior knowledge is dangerously incomplete
192
+ - You know high-level (components exist)
193
+ - You don't know details (how they're wired, what changed)
194
+ - Assumptions about "known" code cause most bugs
195
+
196
+ **Counter:** Discovery validates assumptions and reveals what changed.
197
+
198
+ ### ❌ Trap 3: "Production Emergency, No Time"
199
+ **Rationalization:** "Production is down, skip the process"
200
+
201
+ **Reality:** High stakes demand MORE rigor, not less
202
+ - 6-10 min discovery prevents hours of wrong assumptions
203
+ - Production bugs from incomplete context cost >> discovery time
204
+ - "I know where to look" under stress = peak Dunning-Kruger
205
+
206
+ **Counter:** See "When Pressure is Highest" section below.
207
+
208
+ ### ❌ Trap 4: "Colleague Told Me Structure"
209
+ **Rationalization:** "They said '3 microservices', why rediscover?"
210
+
211
+ **Reality:** High-level descriptions miss critical details
212
+ - "3 microservices" doesn't mention shared libraries, background jobs, API gateways
213
+ - Mental models are abstractions, not complete maps
214
+ - People forget to mention "obvious" infrastructure
215
+
216
+ **Counter:** Use colleague info as validation context, not replacement for discovery.
217
+
218
+ ## When Pressure is Highest, Use Skill Most
219
+
220
+ **CRITICAL INSIGHT: Production emergencies DEMAND systematic understanding.**
221
+
222
+ ### The Emergency Trap
223
+
224
+ **False logic:** "Production down → Skip process → Fix faster"
225
+ **True logic:** "Production down → Need accuracy → Use systematic approach"
226
+
227
+ ### Why Discovery Matters MORE Under Pressure
228
+
229
+ | Shortcut Path | Systematic Path |
230
+ |---------------|-----------------|
231
+ | Grep "CreateAccount" (30 sec) | Run two-phase exploration (6-10 min) |
232
+ | Read 2-3 files (2 min) | Get complete architecture + target impl |
233
+ | Make assumption-based fix (10 min) | Fix with full context (5 min) |
234
+ | Fix breaks something else (2 hours) | Fix correct first time |
235
+ | **Total: 2+ hours + new bugs** | **Total: 15-20 minutes, done right** |
236
+
237
+ ### The "Surgeon Textbook" Analogy is Wrong
238
+
239
+ **Bad analogy:** "Surgeon doesn't read textbook while patient bleeds"
240
+ **Correct analogy:** "Surgeon checks vitals before operating"
241
+
242
+ Discovery is NOT reading theory - it's gathering critical context:
243
+ - ✅ Discovery = Checking patient vitals (essential context)
244
+ - ❌ Reading textbooks = Reading unnecessary theory
245
+
246
+ **You wouldn't skip vitals because "emergency" - same principle applies here.**
247
+
248
+ ### Production Emergency Protocol
249
+
250
+ When production is down:
251
+
252
+ 1. **Acknowledge the pressure** - "This is urgent, I feel pressure to skip discovery"
253
+ 2. **Recognize the trap** - "That pressure is EXACTLY when I need systematic approach"
254
+ 3. **Invest 6-10 minutes** - Run two-phase exploration
255
+ 4. **Fix with confidence** - Full context prevents cascading failures
256
+
257
+ **Reality check:** If you don't have 6-10 minutes for discovery, you don't have 2+ hours to undo wrong fixes.
258
+
259
+ ## Real vs False Pragmatism
260
+
261
+ ### False Pragmatism (Shortcuts that Backfire)
262
+
263
+ | Shortcut | Seems Pragmatic | Actual Result |
264
+ |----------|-----------------|---------------|
265
+ | "Skip discovery, I already know" | Saves 6-10 min | Hours debugging wrong assumptions |
266
+ | "Grep for simple questions" | Faster than exploration | Multiple follow-up questions, incomplete picture |
267
+ | "Production emergency, no process" | Fixes faster | Wrong fix, breaks more things |
268
+ | "Colleague told me structure" | Use existing knowledge | Miss shared libs, background jobs, actual impl |
269
+
270
+ ### Real Pragmatism (Invest to Save)
271
+
272
+ | Systematic Approach | Costs | Saves |
273
+ |---------------------|-------|-------|
274
+ | 6-10 min two-phase exploration | 6-10 minutes | Hours of debugging wrong assumptions |
275
+ | Complete understanding first | Discovery time | Multiple follow-up questions |
276
+ | Systematic under pressure | Feeling "slow" | Fixing wrong thing, cascading failures |
277
+ | Validate colleague's mental model | Discovery vs assumption | Missing critical infrastructure |
278
+
279
+ **Real pragmatism = Doing it right when stakes are high.**
280
+
281
+ **False pragmatism = Taking shortcuts that create bigger problems.**
282
+
283
+ ### When Pragmatism Tells You to Skip...
284
+
285
+ If you think "being pragmatic means skipping this," ask:
286
+
287
+ 1. **Am I conflating "fast" with "good"?** Speed without accuracy is just fast failure.
288
+ 2. **Am I optimizing for feeling productive?** Grep gives quick dopamine, but incomplete understanding.
289
+ 3. **Am I making excuses under pressure?** High stakes demand MORE rigor, not less.
290
+ 4. **Am I assuming I know more than I do?** Dunning-Kruger peaks under stress.
291
+
292
+ **If you answered yes to any: Use the skill anyway.**
293
+
294
+ ## Rationalization Table
295
+
296
+ When you're tempted to skip the skill, check this table:
297
+
298
+ | Rationalization | Why It Feels Right | Why It's Wrong | Counter |
299
+ |-----------------|--------------------|-----------------|---------|
300
+ | **"I already know the architecture"** | You worked here before | Prior knowledge is high-level abstractions | Discovery reveals what you don't know to ask |
301
+ | **"Simple question, grep is faster"** | Just need a file location | Leads to follow-ups, incomplete picture | One exploration answers current + future questions |
302
+ | **"Production emergency, no time"** | Every second counts | Wrong fix wastes hours, creates new bugs | 6-10 min discovery prevents hours of wrong assumptions |
303
+ | **"Colleague told me the structure"** | They work here, they'd know | Mental models miss details (shared libs, jobs) | Use as validation context, not replacement |
304
+ | **"Being pragmatic not dogmatic"** | Process shouldn't be rigid | Shortcuts under pressure cause bigger problems | Real pragmatism = right approach when stakes high |
305
+ | **"Match tool to scope"** | Simple task = simple tool | Context-free answer requires follow-ups | Comprehensive once > multiple partial searches |
306
+ | **"Skip discovery to save time"** | 3-5 min vs 6-10 min | Saving 5 min, losing hours on wrong assumptions | False economy - incomplete understanding compounds |
307
+ | **"Progressive investigation works"** | Start narrow, expand if stuck | Ad-hoc misses systematic patterns | Discovery first prevents getting stuck |
308
+
309
+ ## Process
310
+
311
+ Copy this checklist to track progress:
312
+
313
+ ```
314
+ Two-Phase Exploration Progress:
315
+ - [ ] Phase 0: Scope Definition (exploration target identified)
316
+ - [ ] Phase 1: Discovery Pass (structure discovered - 3-4 agents)
317
+ - [ ] Phase 2: Deep Dive Pass (N adaptive explorers launched)
318
+ - [ ] Phase 3: Result Collection (all agents completed)
319
+ - [ ] Phase 4: Synthesis (discovery + deep dive integrated)
320
+ - [ ] Phase 5: Action Recommendations (next steps identified)
321
+ ```
322
+
323
+ ## Phase 0: Scope Definition
324
+
325
+ **Step 0.1: Identify Exploration Target**
326
+
327
+ From user request, extract:
328
+ - **Core subject:** What feature/system/component to explore?
329
+ - **Context clue:** Why are they asking? (planning change, debugging, learning)
330
+ - **Depth needed:** Surface understanding or comprehensive dive?
331
+
332
+ **Step 0.2: Set Exploration Boundaries**
333
+
334
+ Define scope to keep agents focused:
335
+ - **Include:** Directories/components relevant to target
336
+ - **Exclude:** Build config, vendor code, generated files (unless specifically needed)
337
+ - **Target specificity:** "account creation" vs "entire onboarding service"
338
+
339
+ ## Phase 1: Discovery Pass (Meta-Exploration)
340
+
341
+ **Goal:** Discover the natural structure of THIS codebase
342
+
343
+ **Step 1.1: Launch Discovery Agents in Parallel**
344
+
345
+ **CRITICAL: Single message with 3-4 Task tool calls**
346
+
347
+ Dispatch discovery agents simultaneously:
348
+
349
+ ```
350
+ Task(subagent_type="Explore", description="Architecture discovery",
351
+ prompt="[Architecture Discovery prompt]")
352
+
353
+ Task(subagent_type="Explore", description="Component discovery",
354
+ prompt="[Component Discovery prompt]")
355
+
356
+ Task(subagent_type="Explore", description="Layer discovery",
357
+ prompt="[Layer Discovery prompt]")
358
+
359
+ Task(subagent_type="Explore", description="Organization discovery",
360
+ prompt="[Organization Discovery prompt]")
361
+ ```
362
+
363
+ See **Discovery Agent Prompts** section below for templates.
364
+
365
+ **Step 1.2: Collect Discovery Results**
366
+
367
+ Wait for all discovery agents to complete. Extract from results:
368
+
369
+ **Structural Elements:**
370
+ - Architecture pattern(s) used
371
+ - List of major components/services
372
+ - Layers within components (if applicable)
373
+ - Directory organization principle
374
+ - Technology stack per component
375
+
376
+ **Perspective Matrix:**
377
+ Create a matrix of discovered perspectives:
378
+ ```
379
+ Components: [A, B, C]
380
+ Layers (per component): [HTTP, UseCase, Repository, Domain]
381
+ Boundaries: [Component boundaries, Layer boundaries]
382
+ Organization: [By feature, By layer, By domain]
383
+ ```
384
+
385
+ **Step 1.3: Determine Deep Dive Strategy**
386
+
387
+ Based on discoveries, decide exploration approach:
388
+
389
+ | Discovery Result | Deep Dive Strategy |
390
+ |------------------|-------------------|
391
+ | 3 components × 4 layers | Launch 3 explorers (one per component) |
392
+ | Single component, clear layers | Launch 4 explorers (one per layer) |
393
+ | Microservices architecture | Launch N explorers (one per service) |
394
+ | Monolith by feature | Launch explorers per major feature |
395
+ | Mix of patterns | Adaptive: explore each unique area |
396
+
397
+ **Step 1.4: Validate Discovery Quality**
398
+
399
+ ✅ **Quality checks:**
400
+ - [ ] Architecture pattern clearly identified
401
+ - [ ] Major components/modules enumerated
402
+ - [ ] Boundaries and layers documented
403
+ - [ ] File paths provided as evidence
404
+ - [ ] No major "unknown" areas remaining
405
+
406
+ If quality insufficient: Re-run specific discovery agents with refined prompts.
407
+
408
+ ## Phase 2: Deep Dive Pass (Adaptive Exploration)
409
+
410
+ **Goal:** Explore target within each discovered perspective
411
+
412
+ **Step 2.1: Generate Adaptive Prompts**
413
+
414
+ For each discovered perspective, create a targeted prompt:
415
+
416
+ **Template structure:**
417
+ ```
418
+ Explore [TARGET] in [DISCOVERED_COMPONENT/LAYER].
419
+
420
+ Context from discovery:
421
+ - This is the [COMPONENT_NAME] which handles [RESPONSIBILITY]
422
+ - Architecture: [PATTERN]
423
+ - Location: [DIRECTORY_PATHS]
424
+ - Related components: [DEPENDENCIES]
425
+
426
+ Task:
427
+ 1. Find how [TARGET] is implemented in this area
428
+ 2. Trace execution flow within this scope
429
+ 3. Identify key files and functions (with file:line references)
430
+ 4. Document patterns and conventions used
431
+ 5. Note integration points with other areas
432
+
433
+ Boundaries:
434
+ - Stay within [DIRECTORY_SCOPE]
435
+ - Maximum depth: [BASED_ON_LAYER]
436
+ - Focus on [TARGET] specifically
437
+
438
+ Output format: [Structured report with file:line references]
439
+ ```
440
+
441
+ **Step 2.2: Dispatch Adaptive Explorers in Parallel**
442
+
443
+ **CRITICAL: Single message with N Task tool calls** (N = number of discovered perspectives)
444
+
445
+ Example for 3-component system:
446
+ ```
447
+ Task(subagent_type="Explore", description="Explore target in Component A",
448
+ prompt="[Adaptive prompt for Component A]")
449
+
450
+ Task(subagent_type="Explore", description="Explore target in Component B",
451
+ prompt="[Adaptive prompt for Component B]")
452
+
453
+ Task(subagent_type="Explore", description="Explore target in Component C",
454
+ prompt="[Adaptive prompt for Component C]")
455
+ ```
456
+
457
+ **Agent Configuration:**
458
+ - **subagent_type:** `Explore` (fast agent specialized for codebase exploration)
459
+ - **model:** `haiku` (fast, cost-effective)
460
+ - **run_in_background:** No (await results for synthesis)
461
+
462
+ **Step 2.3: Await All Deep Dive Agents**
463
+
464
+ Block until all N agents complete. Do not proceed with partial results.
465
+
466
+ ## Phase 3: Result Collection
467
+
468
+ **Step 3.1: Organize Findings**
469
+
470
+ Separate results into two buckets:
471
+
472
+ **Discovery Results (from Phase 1):**
473
+ - Architecture map
474
+ - Component catalog
475
+ - Layer definitions
476
+ - Organization principles
477
+
478
+ **Deep Dive Results (from Phase 2):**
479
+ - Per-perspective exploration reports
480
+ - File:line references for target
481
+ - Patterns observed in each area
482
+ - Integration points discovered
483
+
484
+ **Step 3.2: Quality Check Deep Dives**
485
+
486
+ For each deep dive agent result:
487
+ - ✅ Check completeness (did it find the target?)
488
+ - ✅ Verify file:line references provided
489
+ - ✅ Confirm it stayed within scope
490
+ - ⚠️ Note gaps ("target not found in this area" is valid)
491
+ - ⚠️ Identify conflicts between areas
492
+
493
+ **Step 3.3: Cross-Reference Discovery vs Deep Dive**
494
+
495
+ Validate that deep dives align with discovered structure:
496
+ - Do findings match the architecture pattern?
497
+ - Are all discovered components covered?
498
+ - Are there surprises (things not in discovery)?
499
+
500
+ If major misalignment: Investigation needed (discovery was incomplete or incorrect).
501
+
502
+ ## Phase 4: Synthesis
503
+
504
+ **Step 4.1: Integrate Discovery + Deep Dive**
505
+
506
+ Create unified understanding by layering deep dives onto discovery:
507
+
508
+ **Integration process:**
509
+ 1. Start with structural map (from Phase 1)
510
+ 2. Overlay target implementation (from Phase 2 per area)
511
+ 3. Identify how target flows across discovered boundaries
512
+ 4. Document patterns consistent across areas
513
+ 5. Highlight variations between areas
514
+
515
+ **Step 4.2: Create Synthesis Document**
516
+
517
+ **Output format:**
518
+
519
+ ```markdown
520
+ # Autonomous Codebase Exploration: [Target]
521
+
522
+ ## Executive Summary
523
+ [2-3 sentences: architecture + how target works]
524
+
525
+ ---
526
+
527
+ ## Phase 1: Discovery Findings
528
+
529
+ ### Architecture Pattern
530
+ [Pattern name with evidence]
531
+
532
+ ### Component Structure
533
+ [Components discovered with responsibilities]
534
+
535
+ ### Layer Organization
536
+ [Layers identified with boundaries]
537
+
538
+ ### Technology Stack
539
+ [Key technologies per area]
540
+
541
+ ### Structural Diagram
542
+ [ASCII/markdown diagram of discovered structure]
543
+
544
+ ---
545
+
546
+ ## Phase 2: Deep Dive Findings
547
+
548
+ ### [Discovered Area 1 - e.g., "Onboarding Component"]
549
+ **Scope:** `components/onboarding/`
550
+ **Target Implementation:**
551
+ - Entry point: `path/to/file.ext:line`
552
+ - Flow: [step-by-step with file:line references]
553
+ - Patterns: [patterns observed]
554
+ - Integration: [how it connects to other areas]
555
+
556
+ ### [Discovered Area 2 - e.g., "Transaction Component"]
557
+ **Scope:** `components/transaction/`
558
+ **Target Implementation:**
559
+ - Entry point: `path/to/file.ext:line`
560
+ - Flow: [step-by-step with file:line references]
561
+ - Patterns: [patterns observed]
562
+ - Integration: [how it connects to other areas]
563
+
564
+ [... repeat for each discovered area ...]
565
+
566
+ ---
567
+
568
+ ## Cross-Cutting Insights
569
+
570
+ ### Pattern Consistency
571
+ [Where patterns are consistent across areas]
572
+
573
+ ### Pattern Variations
574
+ [Where implementation differs and why]
575
+
576
+ ### Integration Points
577
+ [How discovered areas interact for target]
578
+
579
+ ### Data Flow
580
+ [How data flows across boundaries]
581
+
582
+ ### Key Design Decisions
583
+ [Architectural choices evident from exploration]
584
+
585
+ ---
586
+
587
+ ## Implementation Guidance
588
+
589
+ ### For Adding New Functionality
590
+ **Where to add code:**
591
+ - In [Component]: `path/to/directory/`
592
+ - In [Layer]: Follow pattern from `example/file.ext:line`
593
+
594
+ **Patterns to follow:**
595
+ - [Pattern 1] as seen in `file.ext:line`
596
+ - [Pattern 2] as seen in `file.ext:line`
597
+
598
+ **Integration requirements:**
599
+ - Connect to [Component A] via [interface]
600
+ - Update [Component B] to handle [scenario]
601
+
602
+ ### For Modifying Existing Functionality
603
+ **Files to change:**
604
+ - Primary: `path/file.ext:line`
605
+ - Secondary impacts: `path/file2.ext:line`
606
+
607
+ **Ripple effects:**
608
+ - Changes in [Component A] require updates in [Component B]
609
+
610
+ ### For Debugging
611
+ **Start investigation in:**
612
+ - [Component/Layer]: `path/file.ext:line`
613
+
614
+ **Data inspection points:**
615
+ - [Layer 1]: `file.ext:line` - [what to check]
616
+ - [Layer 2]: `file.ext:line` - [what to check]
617
+
618
+ **Common failure points:**
619
+ - [Area identified from cross-cutting analysis]
620
+
621
+ ---
622
+
623
+ ## Appendix: Discovery Evidence
624
+
625
+ [File:line references supporting structural discoveries]
626
+ ```
627
+
628
+ **Step 4.3: Validate Synthesis**
629
+
630
+ ✅ **Completeness check:**
631
+ - [ ] Both Phase 1 and Phase 2 integrated
632
+ - [ ] All discovered areas covered in deep dive
633
+ - [ ] Cross-cutting insights identified
634
+ - [ ] Implementation guidance specific and actionable
635
+
636
+ ## Phase 5: Action Recommendations
637
+
638
+ Based on synthesis, provide context-aware next steps:
639
+
640
+ **If user's goal is implementation:**
641
+ ```
642
+ Based on autonomous exploration:
643
+
644
+ **Codebase Structure:**
645
+ - Architecture: [Discovered pattern]
646
+ - Components: [List with responsibilities]
647
+
648
+ **To implement [TARGET]:**
649
+ 1. Add new code in: [Component/Layer] at `path/`
650
+ 2. Follow pattern: [Pattern name] from `file.ext:line`
651
+ 3. Integrate with: [Other components] via [mechanism]
652
+ 4. Test using: [Test pattern discovered]
653
+
654
+ **Critical files to understand:**
655
+ - `file1.ext:line` - [why important]
656
+ - `file2.ext:line` - [why important]
657
+
658
+ Ready to create implementation plan? (Use /ring:write-plan)
659
+ ```
660
+
661
+ **If user's goal is debugging:**
662
+ ```
663
+ Based on autonomous exploration:
664
+
665
+ **Investigation starting points:**
666
+ - [Component A]: `file.ext:line` - [what to check]
667
+ - [Component B]: `file.ext:line` - [what to check]
668
+
669
+ **Data flow for [TARGET]:**
670
+ [Origin] → [Transform 1] → [Validation] → [Destination]
671
+
672
+ **Common failure modes:**
673
+ - [Pattern from cross-cutting analysis]
674
+
675
+ Ready to investigate systematically? (Use systematic-debugging)
676
+ ```
677
+
678
+ **If user's goal is learning:**
679
+ ```
680
+ Based on autonomous exploration:
681
+
682
+ **Codebase organization:**
683
+ - [Discovered architecture pattern]
684
+ - [N components] with [responsibilities]
685
+
686
+ **Reading path for [TARGET]:**
687
+ 1. Start: `file1.ext:line` - [entry point]
688
+ 2. Then: `file2.ext:line` - [core logic]
689
+ 3. Finally: `file3.ext:line` - [persistence/output]
690
+
691
+ **Key patterns to understand:**
692
+ - [Pattern 1]: Explained in `file.ext:line`
693
+ - [Pattern 2]: Explained in `file.ext:line`
694
+
695
+ **Related areas to explore next:**
696
+ - [Connection found during exploration]
697
+ ```
698
+
699
+ ## Discovery Agent Prompts
700
+
701
+ ### Template: Architecture Discovery Agent
702
+
703
+ ```markdown
704
+ **Goal:** Discover the architecture pattern(s) used in this codebase.
705
+
706
+ **Scope:** Entire codebase (focus on [TARGET_AREA if specified])
707
+
708
+ **Task:**
709
+ 1. Examine directory structure at top level
710
+ 2. Identify architectural pattern(s):
711
+ - Hexagonal (Ports & Adapters)?
712
+ - Layered (N-tier)?
713
+ - Microservices?
714
+ - Monolith (modular or big ball)?
715
+ - Clean Architecture?
716
+ - MVC/MVVM?
717
+ - Event-driven?
718
+ - Other or mixed?
719
+ 3. Document evidence for pattern identification:
720
+ - Directory names suggesting layers/boundaries
721
+ - Presence of "adapters", "ports", "domain", "infrastructure"
722
+ - Service separation or monolithic structure
723
+ 4. Note if multiple patterns coexist (e.g., hexagonal within each microservice)
724
+
725
+ **Evidence to collect:**
726
+ - Directory structure (top 2-3 levels)
727
+ - Key directory names that indicate architecture
728
+ - Example file paths showing layer separation
729
+ - README or docs mentioning architecture
730
+
731
+ **Output format:**
732
+ ```
733
+ ## Architecture Discovery
734
+
735
+ ### Primary Pattern: [Pattern Name]
736
+ **Evidence:**
737
+ - Directory structure shows: [what indicates this pattern]
738
+ - Example paths:
739
+ - `path/to/adapter/` - [adapter layer]
740
+ - `path/to/domain/` - [domain layer]
741
+ - `path/to/infrastructure/` - [infrastructure layer]
742
+
743
+ ### Confidence: [High/Medium/Low]
744
+ [Explain confidence level]
745
+
746
+ ### Secondary Patterns: [If any]
747
+ [Any mixed or nested patterns]
748
+
749
+ ### Architectural Diagram:
750
+ ```
751
+ [ASCII diagram of discovered architecture]
752
+ ```
753
+
754
+ ### Key Insights:
755
+ - [Any notable architectural decisions or trade-offs visible]
756
+ ```
757
+ ```
758
+
759
+ ### Template: Component Discovery Agent
760
+
761
+ ```markdown
762
+ **Goal:** Identify all major components/modules/services in the codebase.
763
+
764
+ **Scope:** Entire codebase (focus on [TARGET_AREA if specified])
765
+
766
+ **Task:**
767
+ 1. Identify major components:
768
+ - By directory (e.g., `services/`, `components/`, `modules/`)
769
+ - By responsibility (what each component does)
770
+ - By deployment unit (if microservices)
771
+ 2. For each component, document:
772
+ - Name and location (directory path)
773
+ - Primary responsibility (one sentence)
774
+ - Key technologies used (language, framework)
775
+ - Size/scope (small, medium, large)
776
+ 3. Map dependencies between components:
777
+ - Which components depend on which?
778
+ - Are dependencies clean or tangled?
779
+ 4. Identify shared libraries or common code
780
+
781
+ **Evidence to collect:**
782
+ - List of top-level directories
783
+ - README files describing components
784
+ - Import/dependency patterns
785
+ - Package.json, go.mod, or similar dependency files
786
+
787
+ **Output format:**
788
+ ```
789
+ ## Component Discovery
790
+
791
+ ### Components Identified: [N]
792
+
793
+ #### Component 1: [Name]
794
+ - **Location:** `path/to/component/`
795
+ - **Responsibility:** [One sentence]
796
+ - **Technology:** [Language + framework]
797
+ - **Size:** [Lines of code or file count]
798
+ - **Key entry points:**
799
+ - `file1.ext` - [purpose]
800
+ - `file2.ext` - [purpose]
801
+
802
+ #### Component 2: [Name]
803
+ [... same structure ...]
804
+
805
+ ### Dependency Map:
806
+ ```
807
+ [Component A] ──→ [Component B]
808
+ ──→ [Shared Lib]
809
+ [Component B] ──→ [Shared Lib]
810
+ [Component C] ──→ [Component A]
811
+ ──→ [Shared Lib]
812
+ ```
813
+
814
+ ### Shared Libraries:
815
+ - `lib/common/` - [what it provides]
816
+ - `pkg/utils/` - [what it provides]
817
+
818
+ ### Dependency Health:
819
+ ✅ Clean: [Examples]
820
+ ⚠️ Tangled: [Examples of circular or unclear dependencies]
821
+ ```
822
+ ```
823
+
824
+ ### Template: Layer Discovery Agent
825
+
826
+ ```markdown
827
+ **Goal:** Discover layers/boundaries within components.
828
+
829
+ **Scope:** [Specific component if multi-component, else entire codebase]
830
+
831
+ **Task:**
832
+ 1. Within each component, identify layers:
833
+ - Presentation/API layer (HTTP handlers, controllers, etc.)
834
+ - Business logic layer (use cases, services, domain)
835
+ - Data access layer (repositories, database)
836
+ - Infrastructure layer (external integrations)
837
+ 2. Document how layers are separated:
838
+ - By directory?
839
+ - By naming convention?
840
+ - By file organization?
841
+ 3. Check for layer violations:
842
+ - Does presentation layer directly access database?
843
+ - Does business logic depend on infrastructure?
844
+ 4. Identify patterns used for layer communication:
845
+ - Dependency injection?
846
+ - Interfaces/abstractions?
847
+ - Direct coupling?
848
+
849
+ **Evidence to collect:**
850
+ - Directory structure showing layer separation
851
+ - File naming conventions indicating layer
852
+ - Import patterns (what imports what)
853
+ - Interface/abstraction usage
854
+
855
+ **Output format:**
856
+ ```
857
+ ## Layer Discovery
858
+
859
+ ### Component: [Name]
860
+
861
+ #### Layers Identified:
862
+
863
+ ##### Layer 1: [Name - e.g., "HTTP/API Layer"]
864
+ - **Location:** `path/to/layer/`
865
+ - **Responsibility:** [What it does]
866
+ - **Key files:**
867
+ - `file1.ext` - [purpose]
868
+ - `file2.ext` - [purpose]
869
+ - **Dependencies:** [What it depends on]
870
+
871
+ ##### Layer 2: [Name - e.g., "Business Logic"]
872
+ [... same structure ...]
873
+
874
+ ##### Layer 3: [Name - e.g., "Data Access"]
875
+ [... same structure ...]
876
+
877
+ ### Layer Communication Pattern:
878
+ [How layers interact - interfaces, DI, direct calls, etc.]
879
+
880
+ ### Layer Diagram:
881
+ ```
882
+ ┌─────────────────────┐
883
+ │ HTTP/API Layer │
884
+ └─────────┬───────────┘
885
+
886
+ ┌─────────▼───────────┐
887
+ │ Business Logic │
888
+ └─────────┬───────────┘
889
+
890
+ ┌─────────▼───────────┐
891
+ │ Data Access │
892
+ └─────────────────────┘
893
+ ```
894
+
895
+ ### Layer Health:
896
+ ✅ Clean separation: [Evidence]
897
+ ⚠️ Violations found: [Examples with file:line]
898
+
899
+ ### Repeat for other components if multi-component system
900
+ ```
901
+ ```
902
+
903
+ ### Template: Organization Discovery Agent
904
+
905
+ ```markdown
906
+ **Goal:** Understand the organizing principle of this codebase.
907
+
908
+ **Scope:** Entire codebase
909
+
910
+ **Task:**
911
+ 1. Identify primary organization principle:
912
+ - By layer (all controllers together, all models together)
913
+ - By feature (each feature has its own directory with all layers)
914
+ - By domain (organized around business domains)
915
+ - By component type (frontend, backend, shared)
916
+ - Mixed or unclear
917
+ 2. Document file naming conventions:
918
+ - kebab-case, snake_case, camelCase?
919
+ - Suffixes or prefixes? (e.g., `UserController`, `user.controller.ts`)
920
+ 3. Identify test organization:
921
+ - Co-located with source?
922
+ - Separate test directory?
923
+ - Naming convention for tests?
924
+ 4. Note configuration and build setup:
925
+ - Where are config files?
926
+ - Build tool used?
927
+ - Environment-specific configs?
928
+
929
+ **Evidence to collect:**
930
+ - Directory structure examples
931
+ - File naming examples
932
+ - Test file locations
933
+ - Config file locations
934
+
935
+ **Output format:**
936
+ ```
937
+ ## Organization Discovery
938
+
939
+ ### Primary Organization: [Principle Name]
940
+ **Evidence:**
941
+ - Feature X has all its files in: `path/to/feature/`
942
+ - OR: Controllers are all in: `path/controllers/`, Models in: `path/models/`
943
+
944
+ **Example structure:**
945
+ ```
946
+ [Show representative directory tree]
947
+ ```
948
+
949
+ ### File Naming Convention:
950
+ - **Style:** [kebab-case, snake_case, camelCase, etc.]
951
+ - **Pattern:** [Describe pattern]
952
+ - **Examples:**
953
+ - `example-file-1.ext`
954
+ - `example-file-2.ext`
955
+
956
+ ### Test Organization:
957
+ - **Location:** [Co-located or separate]
958
+ - **Pattern:** `*.test.ext`, `*_test.ext`, `test/*`, etc.
959
+ - **Examples:**
960
+ - Source: `src/service.ts`
961
+ - Test: `src/service.test.ts`
962
+
963
+ ### Configuration:
964
+ - **Location:** `path/to/configs/`
965
+ - **Environment handling:** [How envs are managed]
966
+ - **Build tool:** [Make, npm, cargo, etc.]
967
+
968
+ ### Key Insights:
969
+ - [Notable organizational choices]
970
+ - [Any inconsistencies or legacy patterns]
971
+ ```
972
+ ```
973
+
974
+ ## Deep Dive Agent Prompts
975
+
976
+ ### Template: Adaptive Deep Dive Agent
977
+
978
+ ```markdown
979
+ **Goal:** Explore [TARGET] within [DISCOVERED_PERSPECTIVE].
980
+
981
+ **Context from Discovery Phase:**
982
+ - **Architecture:** [Discovered pattern]
983
+ - **This area is:** [Component/Layer/Module name]
984
+ - **Responsibility:** [What this area handles]
985
+ - **Location:** [Directory paths]
986
+ - **Technologies:** [Stack for this area]
987
+ - **Related areas:** [Dependencies/connections]
988
+
989
+ **Task:**
990
+ 1. **Find [TARGET] in this area:**
991
+ - Search for relevant files containing [TARGET] implementation
992
+ - Identify entry points (APIs, handlers, functions)
993
+ - Document with file:line references
994
+
995
+ 2. **Trace execution flow:**
996
+ - Follow [TARGET] through this area's layers/components
997
+ - Document each step with file:line
998
+ - Note data transformations
999
+ - Identify validation/error handling
1000
+
1001
+ 3. **Document patterns:**
1002
+ - What patterns are used in this area for [TARGET]?
1003
+ - Error handling approach
1004
+ - Testing approach
1005
+ - Integration approach with other areas
1006
+
1007
+ 4. **Identify integration points:**
1008
+ - How does this area connect to others for [TARGET]?
1009
+ - What interfaces/APIs are used?
1010
+ - What data is passed between areas?
1011
+
1012
+ **Boundaries:**
1013
+ - **Stay within:** [Directory scope for this perspective]
1014
+ - **Maximum depth:** [Based on layer - don't trace into frameworks]
1015
+ - **Focus:** [TARGET] specifically (don't document unrelated code)
1016
+
1017
+ **Output Format:**
1018
+ ```
1019
+ ## Deep Dive: [TARGET] in [PERSPECTIVE_NAME]
1020
+
1021
+ ### Overview
1022
+ [2-3 sentences about how [TARGET] works in this area]
1023
+
1024
+ ### Entry Points
1025
+ **File:** `path/to/file.ext:line`
1026
+ **Function/Handler:** `functionName`
1027
+ **Triggered by:** [API call, event, function call, etc.]
1028
+
1029
+ ### Execution Flow
1030
+
1031
+ #### Step 1: [Layer/Stage Name]
1032
+ - **File:** `path/to/file.ext:line`
1033
+ - **What happens:** [Description]
1034
+ - **Key code:**
1035
+ ```[language]
1036
+ [Relevant snippet if helpful]
1037
+ ```
1038
+
1039
+ #### Step 2: [Next Layer/Stage]
1040
+ [... same structure ...]
1041
+
1042
+ [... repeat for all steps ...]
1043
+
1044
+ ### Data Transformations
1045
+ - **Input format:** [Describe]
1046
+ - **Transform 1:** At `file.ext:line` - [what changes]
1047
+ - **Transform 2:** At `file.ext:line` - [what changes]
1048
+ - **Output format:** [Describe]
1049
+
1050
+ ### Patterns Observed
1051
+ - **Error handling:** [Approach with example]
1052
+ - **Validation:** [Where and how]
1053
+ - **Testing:** [Test patterns if visible]
1054
+ - **Integration:** [How it connects to other areas]
1055
+
1056
+ ### Integration Points
1057
+
1058
+ #### Outbound: Calls to Other Areas
1059
+ - **To [Area X]:** Via `interface/api` at `file.ext:line`
1060
+ - Purpose: [Why]
1061
+ - Data passed: [What]
1062
+
1063
+ #### Inbound: Called by Other Areas
1064
+ - **From [Area Y]:** Via `interface/api` at `file.ext:line`
1065
+ - Purpose: [Why]
1066
+ - Data received: [What]
1067
+
1068
+ ### Key Files for [TARGET]
1069
+ 1. `path/file1.ext:line` - [Primary implementation]
1070
+ 2. `path/file2.ext:line` - [Secondary/helper]
1071
+ 3. `path/file3.ext:line` - [Integration point]
1072
+
1073
+ ### Notes
1074
+ - [Any discoveries not fitting above categories]
1075
+ - [Gaps: "Could not find X in this area"]
1076
+ - [Surprises: "Unexpected implementation choice"]
1077
+ ```
1078
+ ```
1079
+
1080
+ ## Common Mistakes
1081
+
1082
+ | ❌ Bad | ✅ Good |
1083
+ |--------|---------|
1084
+ | Skip discovery, assume structure | Always run Phase 1 discovery first |
1085
+ | Use same deep dive agents for all codebases | Adapt Phase 2 agents based on Phase 1 |
1086
+ | Accept vague discoveries | Require file:line evidence |
1087
+ | Run explorers sequentially | Dispatch all in parallel (per phase) |
1088
+ | Skip synthesis step | Always integrate discovery + deep dive |
1089
+ | Provide raw dumps | Synthesize into actionable guidance |
1090
+ | Use for single file lookup | Use Read/Grep instead |
1091
+
1092
+ ## Integration with Other Skills
1093
+
1094
+ | Skill | When to use together |
1095
+ |-------|----------------------|
1096
+ | **ring:brainstorming** | Use ring:exploring-codebase in Phase 1 (Understanding) to gather context |
1097
+ | **ring:writing-plans** | Use ring:exploring-codebase before creating implementation plans |
1098
+ | **ring:executing-plans** | Use ring:exploring-codebase if plan execution reveals gaps |
1099
+ | **ring:systematic-debugging** | Use ring:exploring-codebase to understand system before debugging |
1100
+ | **ring:dispatching-parallel-agents** | This skill is built on that pattern (twice!) |
1101
+
1102
+ ## Output Format
1103
+
1104
+ When skill completes, provide:
1105
+
1106
+ ### 1. Synthesis Document
1107
+ [As defined in Phase 4.2 - includes both discovery and deep dive]
1108
+
1109
+ ### 2. Structural Insights
1110
+ ```
1111
+ **Discovered Architecture:**
1112
+ - Pattern: [Name]
1113
+ - Components: [List]
1114
+ - Layers: [List]
1115
+ - Organization: [Principle]
1116
+
1117
+ **[TARGET] Implementation:**
1118
+ - Present in: [N components/layers]
1119
+ - Entry points: [List with file:line]
1120
+ - Integration: [How areas connect]
1121
+ - Patterns: [Consistent patterns observed]
1122
+ ```
1123
+
1124
+ ### 3. Next Step Recommendations
1125
+ [As defined in Phase 5 - context-aware based on user goal]
1126
+
1127
+ ## Verification
1128
+
1129
+ After completing exploration:
1130
+
1131
+ ✅ **Phase 1 (Discovery) completeness:**
1132
+ - [ ] Architecture pattern identified with evidence
1133
+ - [ ] All major components/modules enumerated
1134
+ - [ ] Layers/boundaries documented
1135
+ - [ ] Organization principle clear
1136
+ - [ ] File:line references for structural elements
1137
+
1138
+ ✅ **Phase 2 (Deep Dive) completeness:**
1139
+ - [ ] All discovered perspectives explored
1140
+ - [ ] [TARGET] found and documented in each area
1141
+ - [ ] Execution flows traced with file:line
1142
+ - [ ] Integration points identified
1143
+ - [ ] Patterns documented per area
1144
+
1145
+ ✅ **Synthesis quality:**
1146
+ - [ ] Discovery and deep dive integrated
1147
+ - [ ] Cross-cutting insights identified
1148
+ - [ ] Inconsistencies explained
1149
+ - [ ] Implementation guidance specific
1150
+ - [ ] Next steps clear and actionable
1151
+
1152
+ ## Adaptive Examples
1153
+
1154
+ ### Example 1: Microservices Architecture
1155
+
1156
+ **Phase 1 Discovery finds:**
1157
+ - 5 microservices (Auth, User, Order, Payment, Notification)
1158
+ - Each service is independent
1159
+ - Event-driven communication via message bus
1160
+
1161
+ **Phase 2 adapts:**
1162
+ - Launch 5 deep dive agents (one per service)
1163
+ - Each explores target within their service
1164
+ - Focus on event publishing/subscribing for integration
1165
+
1166
+ ### Example 2: Monolithic Hexagonal Architecture
1167
+
1168
+ **Phase 1 Discovery finds:**
1169
+ - Single application
1170
+ - Hexagonal architecture (adapters + domain)
1171
+ - 4 layers: HTTP → Application → Domain → Infrastructure
1172
+
1173
+ **Phase 2 adapts:**
1174
+ - Launch 4 deep dive agents (one per layer)
1175
+ - Each explores target within their layer
1176
+ - Focus on dependency inversion at boundaries
1177
+
1178
+ ### Example 3: Feature-Organized Monolith
1179
+
1180
+ **Phase 1 Discovery finds:**
1181
+ - Features organized in separate directories
1182
+ - Each feature has its own layers
1183
+ - 6 major features identified
1184
+
1185
+ **Phase 2 adapts:**
1186
+ - Launch 6 deep dive agents (one per feature)
1187
+ - Each explores target within their feature
1188
+ - Focus on shared code and cross-feature integration
1189
+
1190
+ ## Key Principles
1191
+
1192
+ | Principle | Application |
1193
+ |-----------|-------------|
1194
+ | **Discover, then dive** | Phase 1 discovery informs Phase 2 exploration |
1195
+ | **Adaptive parallelization** | Number and type of agents matches structure |
1196
+ | **Evidence-based** | All discoveries backed by file:line references |
1197
+ | **Autonomous** | Codebase reveals its own structure |
1198
+ | **Synthesis required** | Raw outputs must be integrated |
1199
+ | **Action-oriented** | Always end with next steps |
1200
+ | **Quality gates** | Verify each phase before proceeding |
1201
+
1202
+ ## Required Patterns
1203
+
1204
+ This skill uses these universal patterns:
1205
+ - **State Tracking:** See `skills/shared-patterns/state-tracking.md`
1206
+ - **Failure Recovery:** See `skills/shared-patterns/failure-recovery.md`
1207
+ - **TodoWrite:** See `skills/shared-patterns/todowrite-integration.md`
1208
+
1209
+ Apply ALL patterns when using this skill.
1210
+
1211
+ ## Notes
1212
+
1213
+ - **Performance:** Two phases complete faster than naive sequential exploration
1214
+ - **Cost:** Uses `haiku` model (cost-effective for exploration)
1215
+ - **Adaptability:** Works for any architecture (hexagonal, microservices, MVC, etc.)
1216
+ - **Scalability:** Handles codebases from small (2-3 components) to large (10+ services)
1217
+ - **Reusability:** Synthesis documents serve as permanent reference