planflow-ai 1.0.7 → 1.1.0

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.
Files changed (184) hide show
  1. package/.claude/commands/brain.md +251 -0
  2. package/.claude/commands/create-contract.md +37 -211
  3. package/.claude/commands/create-plan.md +45 -235
  4. package/.claude/commands/discovery-plan.md +97 -353
  5. package/.claude/commands/execute-plan.md +93 -376
  6. package/.claude/commands/flow.md +55 -20
  7. package/.claude/commands/learn.md +245 -0
  8. package/.claude/commands/review-code.md +51 -279
  9. package/.claude/commands/review-pr.md +45 -475
  10. package/.claude/commands/setup.md +47 -907
  11. package/.claude/commands/write-tests.md +35 -277
  12. package/.claude/resources/core/_index.md +166 -0
  13. package/.claude/resources/core/agent-profiles.md +107 -0
  14. package/.claude/resources/core/audit-trail.md +180 -0
  15. package/.claude/resources/core/autopilot-mode.md +384 -0
  16. package/.claude/resources/core/brain-capture.md +424 -0
  17. package/.claude/{rules → resources}/core/complexity-scoring.md +30 -1
  18. package/.claude/resources/core/orchestration-workflows.md +178 -0
  19. package/.claude/{rules → resources}/core/project-ledger.md +57 -0
  20. package/.claude/resources/core/resource-capture.md +91 -0
  21. package/.claude/resources/core/tech-detection.md +82 -0
  22. package/.claude/resources/languages/_index.md +124 -0
  23. package/.claude/resources/languages/go-patterns.md +337 -0
  24. package/.claude/resources/languages/python-patterns.md +249 -0
  25. package/.claude/resources/languages/rust-patterns.md +363 -0
  26. package/.claude/resources/languages/typescript-patterns.md +220 -0
  27. package/.claude/resources/patterns/_index.md +259 -0
  28. package/.claude/resources/patterns/autopilot-progress-patterns.md +124 -0
  29. package/.claude/resources/patterns/brain-patterns.md +252 -0
  30. package/.claude/{rules → resources}/patterns/discovery-patterns.md +62 -6
  31. package/.claude/{rules → resources}/patterns/discovery-templates.md +14 -0
  32. package/.claude/resources/patterns/handoff-patterns.md +160 -0
  33. package/.claude/resources/patterns/parallel-review-patterns.md +164 -0
  34. package/.claude/{rules → resources}/patterns/plans-patterns.md +28 -9
  35. package/.claude/{rules → resources}/patterns/plans-templates.md +105 -10
  36. package/.claude/{rules → resources}/patterns/review-code-templates.md +23 -4
  37. package/.claude/{rules → resources}/patterns/review-pr-patterns.md +30 -9
  38. package/.claude/resources/patterns/security-scan-patterns.md +137 -0
  39. package/.claude/resources/skills/_index.md +190 -0
  40. package/.claude/resources/skills/brain-skill.md +144 -0
  41. package/.claude/resources/skills/create-contract-skill.md +220 -0
  42. package/.claude/resources/skills/create-plan-skill.md +356 -0
  43. package/.claude/resources/skills/discovery-skill.md +415 -0
  44. package/.claude/resources/skills/execute-plan-skill.md +760 -0
  45. package/.claude/resources/skills/learn-skill.md +140 -0
  46. package/.claude/resources/skills/review-code-skill.md +390 -0
  47. package/.claude/resources/skills/review-pr-skill.md +482 -0
  48. package/.claude/resources/skills/setup-skill.md +990 -0
  49. package/.claude/resources/skills/write-tests-skill.md +312 -0
  50. package/.claude/resources/tools/_index.md +110 -0
  51. package/.claude/{rules → resources}/tools/interactive-questions-tool.md +2 -2
  52. package/.claude/{rules → resources}/tools/plan-mode-tool.md +2 -2
  53. package/.claude/{rules → resources}/tools/reference-expansion-tool.md +36 -36
  54. package/README.md +3 -2
  55. package/dist/cli/commands/init.d.ts.map +1 -1
  56. package/dist/cli/commands/init.js +27 -4
  57. package/dist/cli/commands/init.js.map +1 -1
  58. package/dist/cli/commands/sessions.d.ts +34 -0
  59. package/dist/cli/commands/sessions.d.ts.map +1 -0
  60. package/dist/cli/commands/sessions.js +128 -0
  61. package/dist/cli/commands/sessions.js.map +1 -0
  62. package/dist/cli/commands/update.d.ts +17 -0
  63. package/dist/cli/commands/update.d.ts.map +1 -0
  64. package/dist/cli/commands/update.js +84 -0
  65. package/dist/cli/commands/update.js.map +1 -0
  66. package/dist/cli/commands/validate.d.ts +31 -0
  67. package/dist/cli/commands/validate.d.ts.map +1 -0
  68. package/dist/cli/commands/validate.js +213 -0
  69. package/dist/cli/commands/validate.js.map +1 -0
  70. package/dist/cli/handlers/claude.d.ts +2 -2
  71. package/dist/cli/handlers/claude.d.ts.map +1 -1
  72. package/dist/cli/handlers/claude.js +116 -4
  73. package/dist/cli/handlers/claude.js.map +1 -1
  74. package/dist/cli/handlers/clawhub.d.ts +9 -0
  75. package/dist/cli/handlers/clawhub.d.ts.map +1 -0
  76. package/dist/cli/handlers/clawhub.js +67 -0
  77. package/dist/cli/handlers/clawhub.js.map +1 -0
  78. package/dist/cli/handlers/codex.d.ts.map +1 -1
  79. package/dist/cli/handlers/codex.js +11 -0
  80. package/dist/cli/handlers/codex.js.map +1 -1
  81. package/dist/cli/handlers/cursor.d.ts +1 -1
  82. package/dist/cli/handlers/cursor.d.ts.map +1 -1
  83. package/dist/cli/handlers/cursor.js +28 -2
  84. package/dist/cli/handlers/cursor.js.map +1 -1
  85. package/dist/cli/handlers/shared.d.ts +19 -0
  86. package/dist/cli/handlers/shared.d.ts.map +1 -1
  87. package/dist/cli/handlers/shared.js +1343 -4
  88. package/dist/cli/handlers/shared.js.map +1 -1
  89. package/dist/cli/index.js +87 -0
  90. package/dist/cli/index.js.map +1 -1
  91. package/dist/cli/types.d.ts +3 -1
  92. package/dist/cli/types.d.ts.map +1 -1
  93. package/dist/cli/utils/detect-stack.d.ts +39 -0
  94. package/dist/cli/utils/detect-stack.d.ts.map +1 -0
  95. package/dist/cli/utils/detect-stack.js +239 -0
  96. package/dist/cli/utils/detect-stack.js.map +1 -0
  97. package/dist/cli/utils/files.d.ts +35 -0
  98. package/dist/cli/utils/files.d.ts.map +1 -1
  99. package/dist/cli/utils/files.js +104 -2
  100. package/dist/cli/utils/files.js.map +1 -1
  101. package/dist/cli/utils/hooks.d.ts +42 -0
  102. package/dist/cli/utils/hooks.d.ts.map +1 -0
  103. package/dist/cli/utils/hooks.js +98 -0
  104. package/dist/cli/utils/hooks.js.map +1 -0
  105. package/dist/cli/utils/ledger.d.ts +38 -0
  106. package/dist/cli/utils/ledger.d.ts.map +1 -0
  107. package/dist/cli/utils/ledger.js +148 -0
  108. package/dist/cli/utils/ledger.js.map +1 -0
  109. package/dist/cli/utils/phase-hooks.d.ts +53 -0
  110. package/dist/cli/utils/phase-hooks.d.ts.map +1 -0
  111. package/dist/cli/utils/phase-hooks.js +122 -0
  112. package/dist/cli/utils/phase-hooks.js.map +1 -0
  113. package/dist/cli/utils/platform-hooks.d.ts +31 -0
  114. package/dist/cli/utils/platform-hooks.d.ts.map +1 -0
  115. package/dist/cli/utils/platform-hooks.js +101 -0
  116. package/dist/cli/utils/platform-hooks.js.map +1 -0
  117. package/dist/cli/utils/prompts.d.ts +5 -0
  118. package/dist/cli/utils/prompts.d.ts.map +1 -1
  119. package/dist/cli/utils/prompts.js +42 -6
  120. package/dist/cli/utils/prompts.js.map +1 -1
  121. package/dist/cli/utils/sessions.d.ts +82 -0
  122. package/dist/cli/utils/sessions.d.ts.map +1 -0
  123. package/dist/cli/utils/sessions.js +203 -0
  124. package/dist/cli/utils/sessions.js.map +1 -0
  125. package/dist/test/setup.js +1 -1
  126. package/dist/test/setup.js.map +1 -1
  127. package/package.json +5 -2
  128. package/rules/core/_index.mdc +57 -5
  129. package/rules/core/agent-profiles.mdc +111 -0
  130. package/rules/core/audit-trail.mdc +114 -0
  131. package/rules/core/autopilot-mode.mdc +255 -91
  132. package/rules/core/brain-capture.mdc +112 -0
  133. package/rules/core/orchestration-workflows.mdc +139 -0
  134. package/rules/core/project-ledger.mdc +2 -2
  135. package/rules/core/resource-capture.mdc +90 -0
  136. package/rules/patterns/_index.mdc +70 -0
  137. package/rules/patterns/autopilot-progress-patterns.mdc +124 -0
  138. package/rules/patterns/brain-patterns.mdc +79 -0
  139. package/rules/patterns/discovery-patterns.mdc +152 -6
  140. package/rules/patterns/discovery-templates.mdc +2 -0
  141. package/rules/patterns/handoff-patterns.mdc +164 -0
  142. package/rules/patterns/parallel-review-patterns.mdc +168 -0
  143. package/rules/patterns/plans-patterns.mdc +28 -9
  144. package/rules/patterns/plans-templates.mdc +59 -0
  145. package/rules/patterns/review-code-templates.mdc +2 -0
  146. package/rules/patterns/security-scan-patterns.mdc +141 -0
  147. package/rules/skills/_index.mdc +12 -1
  148. package/rules/skills/brain-skill.mdc +71 -0
  149. package/rules/skills/create-contract-skill.mdc +15 -30
  150. package/rules/skills/create-plan-skill.mdc +115 -30
  151. package/rules/skills/discovery-skill.mdc +154 -34
  152. package/rules/skills/execute-plan-skill.mdc +264 -3
  153. package/rules/skills/learn-skill.mdc +92 -0
  154. package/rules/skills/review-code-skill.mdc +123 -39
  155. package/rules/skills/review-pr-skill.mdc +82 -93
  156. package/rules/skills/setup-skill.mdc +91 -0
  157. package/rules/skills/write-tests-skill.mdc +18 -0
  158. package/scripts/hooks/pre-compact.cjs +85 -0
  159. package/scripts/hooks/session-end.cjs +284 -0
  160. package/scripts/hooks/session-start.cjs +145 -0
  161. package/skills/plan-flow/SKILL.md +16 -2
  162. package/skills/plan-flow/brain/SKILL.md +64 -0
  163. package/skills/plan-flow/create-contract/SKILL.md +11 -0
  164. package/skills/plan-flow/create-plan/SKILL.md +12 -0
  165. package/skills/plan-flow/discovery/SKILL.md +12 -0
  166. package/skills/plan-flow/execute-plan/SKILL.md +10 -0
  167. package/skills/plan-flow/learn/SKILL.md +49 -0
  168. package/skills/plan-flow/review-code/SKILL.md +12 -0
  169. package/skills/plan-flow/review-pr/SKILL.md +12 -0
  170. package/skills/plan-flow/setup/SKILL.md +10 -0
  171. package/skills/plan-flow/write-tests/SKILL.md +10 -0
  172. package/templates/shared/AGENTS.md.template +11 -0
  173. package/templates/shared/CLAUDE.md.template +24 -5
  174. package/templates/shared/hooks.json.example +7 -0
  175. package/templates/shared/session-hooks-instructions.md +29 -0
  176. package/.claude/rules/core/autopilot-mode.md +0 -188
  177. package/.claude/rules/languages/python-patterns.md +0 -6
  178. package/.claude/rules/languages/typescript-patterns.md +0 -7
  179. /package/.claude/{rules → resources}/patterns/contract-patterns.md +0 -0
  180. /package/.claude/{rules → resources}/patterns/jest-patterns.md +0 -0
  181. /package/.claude/{rules → resources}/patterns/pytest-patterns.md +0 -0
  182. /package/.claude/{rules → resources}/tools/auth-pr-tool.md +0 -0
  183. /package/.claude/{rules → resources}/tools/jest-testing-tool.md +0 -0
  184. /package/.claude/{rules → resources}/tools/pytest-testing-tool.md +0 -0
@@ -0,0 +1,251 @@
1
+ ---
2
+ description: Manual brain entry - capture meeting notes, ideas, brainstorms, and insights into the project brain
3
+ ---
4
+
5
+ # Brain: Manual Knowledge Capture
6
+
7
+ ## Command Description
8
+
9
+ This command allows manual brain entries for capturing meeting notes, brainstorms, ad-hoc ideas, and insights that don't come from automatic skill execution. Supports two modes: free-text (default) and guided prompts.
10
+
11
+ **Output**: Brain entries in `flow/brain/` with `[[wiki-links]]` for Obsidian compatibility.
12
+
13
+ ---
14
+
15
+
16
+ ## Help
17
+
18
+ **If the user invokes this command with `-help`, display only this section and stop:**
19
+
20
+ ```
21
+ /brain - Manual Brain Entry
22
+
23
+ DESCRIPTION:
24
+ Capture meeting notes, brainstorms, ideas, and insights into the
25
+ project brain. Creates Obsidian-compatible markdown with [[wiki-links]].
26
+
27
+ USAGE:
28
+ /brain <free text> Free-text mode (default)
29
+ /brain -guided Guided mode with structured questions
30
+ /brain -help Show this help
31
+
32
+ ARGUMENTS:
33
+ free text Unstructured text to parse and categorize
34
+ -guided Triggers structured question mode
35
+
36
+ EXAMPLES:
37
+ /brain Had a call with the team about auth flow. Decision: use JWT with refresh tokens.
38
+ /brain Discovered that the API rate limits at 100 req/min. Need to add throttling.
39
+ /brain -guided
40
+
41
+ OUTPUT:
42
+ - Writes to appropriate flow/brain/ subdirectory
43
+ - Creates [[wiki-links]] to related entries
44
+ - Updates flow/brain/index.md if needed
45
+
46
+ MODES:
47
+ Free-text: Parses input, extracts entities, categorizes, writes entry
48
+ Guided: Asks structured questions about work, insights, meetings, decisions
49
+
50
+ BRAIN STRUCTURE:
51
+ flow/brain/
52
+ ├── index.md # Brain index (always loaded at session start)
53
+ ├── features/ # Feature history and context
54
+ ├── errors/ # Reusable error patterns
55
+ ├── decisions/ # Decision records
56
+ └── sessions/ # Daily activity logs
57
+
58
+ RELATED COMMANDS:
59
+ /setup Creates brain directory structure
60
+ /discovery-plan Auto-captures to brain after completion
61
+ /execute-plan Auto-captures to brain after completion
62
+ ```
63
+
64
+ ---
65
+
66
+ > **AGENT_PROFILE: write-restricted**
67
+ > See `.claude/resources/core/agent-profiles.md` for tool access rules.
68
+
69
+ ## Critical Rules
70
+
71
+ | Rule | Description |
72
+ | ------------------------ | -------------------------------------------------------- |
73
+ | **Brain Only** | ONLY write to `flow/brain/` - no source code, no config |
74
+ | **Wiki-Links** | All cross-references use `[[kebab-case-name]]` format |
75
+ | **Index Caps** | Max 5 errors, 3 decisions, 3 cross-project in index |
76
+ | **No Code** | Brain is for knowledge capture, never write source code |
77
+ | **Complete and Stop** | After writing entry, STOP and wait for user |
78
+
79
+ ---
80
+
81
+ ## Instructions
82
+
83
+ ### Step 1: Validate Inputs
84
+
85
+ | Input | Required | Description |
86
+ | ----------- | -------- | ---------------------------------------------- |
87
+ | `content` | Yes | Free-text or triggered by `-guided` flag |
88
+ | `-guided` | Optional | Triggers structured question mode |
89
+
90
+ If no content and no `-guided` flag, ask:
91
+
92
+ ```markdown
93
+ What would you like to capture? You can:
94
+ 1. Type free text and I'll categorize it automatically
95
+ 2. Use `/brain -guided` for structured prompts
96
+ ```
97
+
98
+ ---
99
+
100
+ ### Step 2: Ensure Brain Directory Exists
101
+
102
+ Check if `flow/brain/` exists. If not, create:
103
+
104
+ ```bash
105
+ mkdir -p flow/brain/features flow/brain/errors flow/brain/decisions flow/brain/sessions
106
+ ```
107
+
108
+ Check if `flow/brain/index.md` exists. If not, create initial index:
109
+
110
+ ```markdown
111
+ # Project Brain
112
+
113
+ ## Active Features
114
+ _No features tracked yet._
115
+
116
+ ## Recent Errors
117
+ _No errors captured yet._
118
+
119
+ ## Recent Decisions
120
+ _No decisions recorded yet._
121
+
122
+ ## Cross-Project Patterns
123
+ _No cross-project patterns yet._
124
+ ```
125
+
126
+ ---
127
+
128
+ ### Step 3: Invoke Brain Skill
129
+
130
+ The skill will handle:
131
+
132
+ **Free-text mode**:
133
+ 1. Parse input text
134
+ 2. Extract entities (features, technologies, people, errors, decisions)
135
+ 3. Categorize into appropriate brain subdirectory
136
+ 4. Create/update brain files with `[[wiki-links]]`
137
+ 5. Update `flow/brain/index.md` if needed
138
+
139
+ **Guided mode** (`-guided`):
140
+ 1. Ask structured questions via `AskUserQuestion`
141
+ 2. Gather responses and follow-up text
142
+ 3. Generate properly formatted brain files
143
+ 4. Link everything with `[[wiki-links]]`
144
+ 5. Update `flow/brain/index.md`
145
+
146
+ See: `.claude/resources/skills/brain-skill.md`
147
+
148
+ ---
149
+
150
+ ### Step 4: Present Results
151
+
152
+ After the skill completes:
153
+
154
+ **Free-text result**:
155
+
156
+ ```markdown
157
+ Brain entry captured!
158
+
159
+ **Written to**: flow/brain/[subdirectory]/[file].md
160
+ **Links created**: [[feature-1]], [[error-name]]
161
+ **Index updated**: Yes/No
162
+ ```
163
+
164
+ **Guided result**:
165
+
166
+ ```markdown
167
+ Brain entry captured!
168
+
169
+ **Topics covered**:
170
+ - Feature: [[feature-name]] - summary
171
+ - Decision: [[decision-name]] - choice
172
+ - Meeting notes added to [[YYYY-MM-DD]]
173
+
174
+ **Index updated**: Yes
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Flow Diagram
180
+
181
+ ```
182
+ +------------------------------------------+
183
+ | /brain COMMAND |
184
+ +------------------------------------------+
185
+ |
186
+ v
187
+ +------------------------------------------+
188
+ | Step 1: Validate Inputs |
189
+ | - Check for content or -guided flag |
190
+ +------------------------------------------+
191
+ |
192
+ v
193
+ +------------------------------------------+
194
+ | Step 2: Ensure Brain Directory |
195
+ | - Create flow/brain/ if needed |
196
+ | - Create index.md if needed |
197
+ +------------------------------------------+
198
+ |
199
+ v
200
+ +------------------------------------------+
201
+ | Step 3: Invoke Brain Skill |
202
+ | - Free-text: parse, extract, categorize |
203
+ | - Guided: structured questions |
204
+ | - See brain-skill.md |
205
+ +------------------------------------------+
206
+ |
207
+ v
208
+ +------------------------------------------+
209
+ | Step 4: Present Results |
210
+ | - Show files written |
211
+ | - Show links created |
212
+ | - Show index update status |
213
+ +------------------------------------------+
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Context Optimization
219
+
220
+ ### Recommended Loading Order
221
+
222
+ 1. **Always load first**: This command file (`commands/brain.md`)
223
+ 2. **Load indexes**: Load `_index.md` files for relevant folders
224
+ 3. **Expand on-demand**: Use reference codes to load specific sections when needed
225
+
226
+ ### Reference Codes for Brain
227
+
228
+ | Code | Description | When to Expand |
229
+ |------|-------------|----------------|
230
+ | SKL-BR-1 | Brain skill restrictions | Understanding allowed actions |
231
+ | SKL-BR-2 | Brain skill workflow | Processing entries |
232
+ | SKL-BR-3 | Output format and validation | Formatting output |
233
+ | PTN-BR-1 | Directory structure and naming | Creating brain files |
234
+ | PTN-BR-2 | Wiki-link patterns | Creating cross-references |
235
+ | PTN-BR-3 | Feature status lifecycle | Updating feature entries |
236
+ | COR-BR-1 | Session start behavior | Understanding brain loading |
237
+ | COR-BR-2 | File templates | Creating new brain files |
238
+ | COR-BR-3 | Index management caps | Enforcing index limits |
239
+
240
+ ---
241
+
242
+ ## Related Resources
243
+
244
+ | Resource | Purpose |
245
+ | --------------------------- | --------------------------------- |
246
+ | `resources/skills/_index.md` | Index of skills with reference codes |
247
+ | `resources/patterns/_index.md` | Index of patterns with reference codes |
248
+ | `resources/core/_index.md` | Index of core rules with reference codes |
249
+ | `brain-skill.md` | Skill that processes brain entries |
250
+ | `brain-patterns.md` | File naming and link conventions |
251
+ | `brain-capture.md` | Processing rules and templates |
@@ -55,6 +55,13 @@ RELATED COMMANDS:
55
55
 
56
56
  ---
57
57
 
58
+ > **MODE: Research**
59
+ > Explore before concluding. Read 3x more than you write. Prefer Read/Grep/Glob/WebSearch tools.
60
+ > Ask clarifying questions when uncertain. Don't jump to implementation.
61
+
62
+ > **AGENT_PROFILE: read-only**
63
+ > See `.claude/resources/core/agent-profiles.md` for tool access rules.
64
+
58
65
  ## Critical Rules
59
66
 
60
67
  | Rule | Description |
@@ -111,7 +118,7 @@ The skill will:
111
118
  3. Ask clarifying questions via Interactive Questions Tool
112
119
  4. Generate contract document
113
120
 
114
- See: `.claude/rules/skills/create-contract-skill.md`
121
+ See: `.claude/resources/skills/create-contract-skill.md`
115
122
 
116
123
  ---
117
124
 
@@ -204,9 +211,9 @@ This command uses hierarchical context loading to reduce context consumption. In
204
211
 
205
212
  | Index | When to Load |
206
213
  |-------|--------------|
207
- | `rules/patterns/_index.md` | To find contract patterns |
208
- | `rules/skills/_index.md` | To understand skill workflow |
209
- | `rules/tools/_index.md` | When using interactive questions |
214
+ | `resources/patterns/_index.md` | To find contract patterns |
215
+ | `resources/skills/_index.md` | To understand skill workflow |
216
+ | `resources/tools/_index.md` | When using interactive questions |
210
217
 
211
218
  ### Reference Codes for Contract Creation
212
219
 
@@ -222,7 +229,7 @@ This command uses hierarchical context loading to reduce context consumption. In
222
229
 
223
230
  When executing this command:
224
231
 
225
- 1. **Start with indexes**: Read `rules/patterns/_index.md` and `rules/skills/_index.md`
232
+ 1. **Start with indexes**: Read `resources/patterns/_index.md` and `resources/skills/_index.md`
226
233
  2. **Identify needed codes**: Based on current step, identify which codes are relevant
227
234
  3. **Expand as needed**: Use the Read tool with specific line ranges from the index
228
235
  4. **Don't expand everything**: Only load content required for the current step
@@ -233,9 +240,9 @@ When executing this command:
233
240
 
234
241
  | Resource | Purpose |
235
242
  | ------------------------------ | -------------------------------------- |
236
- | `rules/skills/_index.md` | Index of skills with reference codes |
237
- | `rules/patterns/_index.md` | Index of patterns with reference codes |
238
- | `rules/tools/_index.md` | Index of tools with reference codes |
243
+ | `resources/skills/_index.md` | Index of skills with reference codes |
244
+ | `resources/patterns/_index.md` | Index of patterns with reference codes |
245
+ | `resources/tools/_index.md` | Index of tools with reference codes |
239
246
  | `create-contract-skill.md` | Skill that creates the contract |
240
247
  | `contract-patterns.md` | Rules and patterns for contracts |
241
248
  | `interactive-questions-tool.md` | Interactive Questions UI workflow |
@@ -244,225 +251,44 @@ When executing this command:
244
251
 
245
252
  ---
246
253
 
247
- # Implementation Details
248
-
249
-
250
- ## Restrictions - CONTRACT CREATION ONLY
251
-
252
- This skill is **strictly for creating contract documents**. The process:
253
-
254
- 1. **Fetches** information from the source URL
255
- 2. **Analyzes** the API structure and schemas
256
- 3. **Asks** clarifying questions via Interactive Questions Tool
257
- 4. **Generates** a contract markdown file
258
-
259
- **No code, no implementation, no source file modifications.**
260
-
261
- ### NEVER Do These Actions
262
-
263
- | Forbidden Action | Reason |
264
- | -------------------------------------- | ----------------------------------- |
265
- | Create/edit source code files | Contract creation only |
266
- | Write implementation code | Contracts describe, not implement |
267
- | Modify configuration files | No codebase changes |
268
- | Run build or test commands | No execution commands |
269
- | Create files outside `flow/contracts/` | Only write contract documents |
270
-
271
- ### Allowed Actions
272
-
273
- | Allowed Action | Purpose |
274
- | -------------------------------------- | ------------------------------------ |
275
- | Use Web Search tool | Fetch documentation from URLs |
276
- | Read repository files | Analyze API structure |
277
- | Use Interactive Questions Tool | Gather requirements from user |
278
- | Write to `flow/contracts/` | Save contract document |
279
- | Read project rule files | Understand patterns to follow |
280
-
281
- > **Important**: The ONLY writable location is `flow/contracts/`. No source code or other files should be modified.
282
-
283
- ---
284
-
285
- ## Inputs
286
-
287
- | Input | Required | Description |
288
- | ------------- | -------- | ---------------------------------------------------- |
289
- | `source_url` | Yes | Documentation URL or repository URL |
290
- | `description` | Yes | What the user wants to integrate on the frontend |
291
-
292
- ---
293
-
294
- ## Workflow
254
+ ## Compaction Suggestion
295
255
 
296
- ### Step 1: Detect Source Type
256
+ After contract creation completes, suggest context cleanup if the contract was complex (> 5 endpoints):
297
257
 
298
- Analyze the provided URL to determine the source type:
258
+ > Contract created. Consider running `/compact` to free context before the next task.
299
259
 
300
- | Source Type | Detection |
301
- | ---------------- | ---------------------------------------------- |
302
- | Documentation | Contains `/docs`, `/api`, swagger, openapi |
303
- | Repository | Contains github.com, gitlab.com, bitbucket.org |
304
- | OpenAPI Spec | Ends with `.json`, `.yaml`, `/swagger` |
260
+ Skip if autopilot is ON.
305
261
 
306
262
  ---
307
263
 
308
- ### Step 2A: Handle Documentation URL
309
-
310
- If the source is a documentation URL:
311
-
312
- 1. Use Web Search tool to fetch documentation content
313
- 2. Extract key information:
314
- - API endpoints
315
- - Request/response schemas
316
- - Authentication methods
317
- - Error formats
318
- - Rate limits
319
-
320
- ---
321
-
322
- ### Step 2B: Handle Repository URL
323
-
324
- If the source is a repository URL:
325
-
326
- 1. Analyze repository structure
327
- 2. Identify relevant files:
328
- - API route definitions
329
- - Type definitions
330
- - Schema files
331
- - README/docs
332
- 3. Read and extract key information
333
-
334
- ---
335
-
336
- ### Step 3: Ask Clarifying Questions
337
-
338
- **Use Interactive Questions Tool** to gather requirements.
264
+ ## Brain Capture
339
265
 
340
- Follow `.claude/rules/tools/interactive-questions-tool.md`:
266
+ After contract creation completes, append a brain-capture block. See `.claude/resources/core/brain-capture.md` for processing rules.
341
267
 
342
- 1. Call `SwitchMode` tool to enter Plan mode
343
- 2. Call `Ask the user directly in conversation` tool for each question about:
344
- - **Scope**: Which specific endpoints/features are needed?
345
- - **Authentication**: How will the FE authenticate?
346
- - **Error Handling**: How should the FE handle errors?
347
- - **Caching**: Any caching requirements?
348
- 3. Wait for all responses
349
- 4. Call `SwitchMode` tool to return to Agent mode
350
- 5. Document answers for use in the contract document
268
+ **Capture the following**:
351
269
 
352
- ---
353
-
354
- ### Step 4: Generate Contract Document
355
-
356
- Create the contract with all gathered information:
357
-
358
- **Location**: `flow/contracts/<service_name>_contract.md`
359
-
360
- **Required Sections**:
361
-
362
- 1. Overview
363
- 2. Authentication
364
- 3. Endpoints (with request/response schemas)
365
- 4. Error Handling
366
- 5. Integration Notes
367
- 6. Usage Examples
368
-
369
- ---
370
-
371
- ## Output Format
372
-
373
- ### Contract Template
374
-
375
- ```markdown
376
- # Integration Contract: [Service Name]
377
-
378
- ## Overview
379
-
380
- **Source**: [URL]
381
- **Description**: [What this integration provides]
382
- **Version**: [API version if applicable]
383
-
384
- ## Authentication
385
-
386
- **Method**: [Bearer token, API key, OAuth, etc.]
387
- **Header**: [Authorization header format]
388
- **Token Source**: [Where FE gets the token]
389
-
390
- ## Endpoints
391
-
392
- ### [Endpoint Name]
393
-
394
- **Method**: [GET/POST/PUT/DELETE]
395
- **URL**: [Endpoint URL]
396
- **Description**: [What this endpoint does]
397
-
398
- **Request**:
399
- ```typescript
400
- interface RequestBody {
401
- // Request schema
402
- }
403
- ```
404
-
405
- **Response**:
406
- ```typescript
407
- interface Response {
408
- // Response schema
409
- }
410
270
  ```
411
-
412
- **Example**:
413
- ```bash
414
- curl -X POST /api/endpoint \
415
- -H "Authorization: Bearer token" \
416
- -d '{"field": "value"}'
271
+ <!-- brain-capture
272
+ skill: create-contract
273
+ feature: [service name]
274
+ status: completed
275
+ data:
276
+ service_name: [API/service name]
277
+ endpoints_documented: [count]
278
+ auth_type: [detected auth type]
279
+ contract_doc: [path to contract document]
280
+ -->
417
281
  ```
418
282
 
419
- ## Error Handling
420
-
421
- | Status Code | Meaning | FE Action |
422
- | ----------- | -------------------- | ------------------------- |
423
- | 400 | Bad Request | Show validation error |
424
- | 401 | Unauthorized | Redirect to login |
425
- | 404 | Not Found | Show not found message |
426
- | 500 | Server Error | Show generic error |
427
-
428
- ## Integration Notes
429
-
430
- ### Rate Limits
431
- [Any rate limiting information]
432
-
433
- ### Caching
434
- [Caching recommendations]
435
-
436
- ### Pagination
437
- [Pagination format if applicable]
438
-
439
- ## Usage Examples
440
-
441
- ### [Use Case 1]
442
- [Code example or description]
443
- ```
283
+ Update `flow/brain/features/[service-name].md` with contract context and update `flow/brain/index.md`.
444
284
 
445
285
  ---
446
286
 
447
- ## Validation Checklist
287
+ ## Resource Capture
448
288
 
449
- Before completing the contract, verify:
289
+ During this skill's execution, watch for valuable reference materials worth preserving. See `.claude/resources/core/resource-capture.md` for capture rules, file format, and naming conventions.
450
290
 
451
- - [ ] Contract is saved in `flow/contracts/` folder
452
- - [ ] File uses naming: `<service_name>_contract.md`
453
- - [ ] All requested endpoints are documented
454
- - [ ] Authentication method is clear
455
- - [ ] Request/response schemas are defined
456
- - [ ] Error handling is documented
457
- - [ ] **NO implementation code is included**
458
- - [ ] **NO source files were created or modified**
459
-
460
- ---
291
+ At natural break points, if you encounter information that could be useful for future development (API specs, architecture notes, config references, domain knowledge, etc.), ask the user: "I found something that could be useful for future reference: _{brief description}_. Should I save it to `flow/resources/`?"
461
292
 
462
- ## Related Files
293
+ Only save if the user approves. Do not re-ask if declined.
463
294
 
464
- | File | Purpose |
465
- | -------------------------------------------------- | --------------------------------- |
466
- | `.claude/rules/patterns/contract-patterns.md` | Rules and patterns for contracts |
467
- | `.claude/rules/tools/interactive-questions-tool.md` | Interactive Questions workflow |
468
- | `flow/contracts/` | Output folder for contracts |