knowzcode 0.3.7 → 0.4.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 (79) hide show
  1. package/.claude-plugin/marketplace.json +61 -61
  2. package/.claude-plugin/plugin.json +8 -8
  3. package/LICENSE +121 -121
  4. package/README.md +354 -320
  5. package/agents/analyst.md +114 -114
  6. package/agents/architect.md +200 -200
  7. package/agents/builder.md +104 -104
  8. package/agents/closer.md +177 -177
  9. package/agents/context-scout.md +54 -54
  10. package/agents/knowledge-migrator.md +349 -349
  11. package/agents/knowz-scout.md +83 -83
  12. package/agents/knowz-scribe.md +180 -180
  13. package/agents/microfix-specialist.md +135 -135
  14. package/agents/project-advisor.md +111 -111
  15. package/agents/reviewer.md +172 -172
  16. package/agents/security-officer.md +194 -194
  17. package/agents/test-advisor.md +162 -162
  18. package/agents/update-coordinator.md +394 -394
  19. package/bin/knowzcode.mjs +1199 -956
  20. package/commands/audit.md +328 -328
  21. package/commands/connect-mcp.md +549 -549
  22. package/commands/fix.md +107 -107
  23. package/commands/init.md +500 -439
  24. package/commands/learn.md +332 -332
  25. package/commands/plan.md +272 -272
  26. package/commands/register.md +733 -733
  27. package/commands/status.md +309 -309
  28. package/commands/telemetry-setup.md +368 -368
  29. package/commands/telemetry.md +188 -188
  30. package/commands/work.md +1204 -1202
  31. package/knowzcode/automation_manifest.md +59 -59
  32. package/knowzcode/claude_code_execution.md +431 -420
  33. package/knowzcode/copilot_execution.md +231 -231
  34. package/knowzcode/enterprise/compliance_manifest.md +137 -137
  35. package/knowzcode/enterprise/compliance_status.md +30 -30
  36. package/knowzcode/enterprise/guidelines/code-quality.md +67 -67
  37. package/knowzcode/enterprise/guidelines/security.md +355 -355
  38. package/knowzcode/enterprise/templates/guideline-template.md +55 -55
  39. package/knowzcode/gitignore.template +13 -13
  40. package/knowzcode/knowzcode_architecture.md +51 -51
  41. package/knowzcode/knowzcode_log.md +142 -142
  42. package/knowzcode/knowzcode_loop.md +596 -596
  43. package/knowzcode/knowzcode_orchestration.md +66 -66
  44. package/knowzcode/knowzcode_project.md +48 -48
  45. package/knowzcode/knowzcode_tracker.md +40 -40
  46. package/knowzcode/knowzcode_vaults.md +257 -257
  47. package/knowzcode/mcp_config.md +191 -191
  48. package/knowzcode/planning/Readme.md +6 -6
  49. package/knowzcode/platform_adapters.md +1260 -1047
  50. package/knowzcode/prompts/Execute_Micro_Fix.md +57 -57
  51. package/knowzcode/prompts/Investigate_Codebase.md +227 -227
  52. package/knowzcode/prompts/Migrate_Knowledge.md +301 -301
  53. package/knowzcode/prompts/Refactor_Node.md +72 -72
  54. package/knowzcode/prompts/Spec_Verification_Checkpoint.md +59 -59
  55. package/knowzcode/prompts/[LOOP_1A]__Propose_Change_Set.md +52 -52
  56. package/knowzcode/prompts/[LOOP_1B]__Draft_Specs.md +75 -75
  57. package/knowzcode/prompts/[LOOP_2A]__Implement_Change_Set.md +55 -55
  58. package/knowzcode/prompts/[LOOP_2B]__Verify_Implementation.md +72 -72
  59. package/knowzcode/prompts/[LOOP_3]__Finalize_And_Commit.md +67 -67
  60. package/knowzcode/specs/Readme.md +10 -10
  61. package/knowzcode/telemetry_config.md +89 -89
  62. package/knowzcode/user_preferences.md +120 -120
  63. package/package.json +53 -53
  64. package/skills/alias-resolver.json +1 -1
  65. package/skills/architecture-diff.json +1 -1
  66. package/skills/check-installation-status.json +1 -1
  67. package/skills/continue.md +126 -126
  68. package/skills/environment-guard.json +1 -1
  69. package/skills/generate-workgroup-id.json +1 -1
  70. package/skills/install-knowzcode.json +1 -1
  71. package/skills/load-core-context.json +1 -1
  72. package/skills/log-entry-builder.json +1 -1
  73. package/skills/spec-quality-check.json +1 -1
  74. package/skills/spec-template.json +1 -1
  75. package/skills/spec-validator.json +1 -1
  76. package/skills/start-work.md +224 -224
  77. package/skills/tracker-scan.json +1 -1
  78. package/skills/tracker-update.json +1 -1
  79. package/skills/validate-installation.json +1 -1
package/commands/learn.md CHANGED
@@ -1,332 +1,332 @@
1
- ---
2
- description: Capture learnings to the KnowzCode ecosystem vault for organizational knowledge
3
- ---
4
-
5
- # KnowzCode Learning Capture
6
-
7
- You are the **KnowzCode Learning Agent**. Your task is to capture insights, patterns, decisions, and best practices to the appropriate vault for future reference.
8
-
9
- ## Command Syntax
10
-
11
- ```bash
12
- /kc:learn "<insight>" [--category <type>] [--tags <tag1,tag2,...>] [--vault <name-or-id>] [--source <origin>] [--workgroup <wgid>]
13
- ```
14
-
15
- **Parameters:**
16
- - `"<insight>"` - Required. The learning to capture (in quotes)
17
- - `--category <type>` - Optional. Category prefix (pattern, decision, workaround, performance, security, convention)
18
- - `--tags <tags>` - Optional. Comma-separated tags for categorization
19
- - `--vault <name-or-id>` - Optional. Target vault for multi-vault setups
20
- - `--source <origin>` - Optional. Where this learning came from (e.g., "code review", "incident", "meeting", "pair programming")
21
- - `--workgroup <wgid>` - Optional. Explicitly link this learning to a WorkGroup for traceability
22
-
23
- **Examples:**
24
- ```bash
25
- # Simple learning (auto-routes to appropriate vault)
26
- /kc:learn "JWT refresh tokens work better than session cookies for stateless APIs"
27
-
28
- # With category
29
- /kc:learn "Always sanitize user input before SQL queries" --category security
30
-
31
- # With tags
32
- /kc:learn "Repository pattern isolates data access from business logic" --category pattern --tags architecture,data-access
33
-
34
- # Workaround documentation
35
- /kc:learn "Azure Blob SDK v12 has memory leak with large files; use streaming instead" --category workaround --tags azure,blob-storage
36
-
37
- # Explicit vault selection (multi-vault setup)
38
- /kc:learn "New hire checklist for backend developers" --vault "Company Wiki"
39
- /kc:learn "We use Repository pattern for all data access" --vault engineering-knowledge
40
-
41
- # With source and WorkGroup linking
42
- /kc:learn "Rate limiting should be per-user not per-IP" --source "incident postmortem" --category decision
43
- /kc:learn "Use streaming for files >10MB" --workgroup kc-feat-file-upload-20260201-120000
44
- ```
45
-
46
- ## Prerequisites
47
-
48
- - KnowzCode MCP server must be connected
49
- - Ecosystem vault must be configured (auto-configured via `/kc:register`)
50
- - Project must be initialized (`/kc:init`)
51
-
52
- **Quickest setup**: Run `/kc:register` - it creates your account AND configures your vault automatically.
53
-
54
- ## Your Task
55
-
56
- Capture the provided insight to the appropriate vault using the MCP `create_knowledge` tool.
57
-
58
- ### Steps to Execute
59
-
60
- 1. **Quick MCP and Vault Detection (FIRST)**
61
-
62
- **Step 1a: Check for `create_knowledge` in your available tools list**
63
-
64
- **If `create_knowledge` is NOT available:**
65
- - MCP server is not connected
66
- - Show helpful setup guidance (see Error Handling section)
67
- - Do NOT attempt any MCP operations
68
- - STOP here
69
-
70
- **Step 1b: Read vault configuration**
71
- - Read `knowzcode/knowzcode_vaults.md` (canonical vault config)
72
- - Look for a vault entry with type `ecosystem` that has a non-empty ID
73
- - If not found, fall back to `knowzcode/mcp_config.md` for backwards compatibility
74
- - Check if Vault ID is set (not empty or "(not configured)")
75
-
76
- **If Ecosystem Vault ID IS configured:**
77
- - Proceed to step 2
78
-
79
- **If Ecosystem Vault ID is "(not configured)" or missing:**
80
- - Show "vault not configured" error:
81
- ```
82
- ❌ Ecosystem vault not configured
83
-
84
- Your MCP server is connected, but no vault is set up for learnings.
85
-
86
- Quickest fix:
87
- /kc:register
88
- (Creates account + auto-configures vault)
89
-
90
- Already have an account?
91
- /kc:connect-mcp --configure-vaults
92
- (Prompts for vault ID)
93
-
94
- After setup, run /kc:learn again.
95
- ```
96
- - STOP here
97
-
98
- 2. **Determine Target Vault (Multi-Vault Support)**
99
-
100
- a. Read `knowzcode/knowzcode_vaults.md` for connected vaults
101
- b. Route based on category (see Category-to-Vault Routing below)
102
- c. **If only one vault of the target type** → use it automatically
103
- d. **If multiple vaults of the target type**:
104
- - Analyze learning content against vault descriptions
105
- - Look for keyword matches:
106
- - "architecture", "pattern", "decision" → vault with architectural content
107
- - "process", "onboarding", "team" → vault with organizational content
108
- - "convention", "standard", "rule" → vault with conventions
109
- - If clear match → use that vault
110
- - If ambiguous → prompt user:
111
- ```
112
- Where should this learning be saved?
113
-
114
- Available vaults:
115
- 1. Engineering Knowledge - "architectural decisions, patterns, conventions"
116
- 2. Company Wiki - "processes, onboarding, team structure"
117
-
118
- Select vault (1-2) or type vault name:
119
- ```
120
- Use AskUserQuestion with vault options.
121
- e. **If no vaults in knowzcode_vaults.md**:
122
- - Fall back to `knowzcode/mcp_config.md` Ecosystem Vault ID
123
- - If still not configured → show "vault not configured" error
124
-
125
- ### Category-to-Vault Routing
126
-
127
- | Category | Target Vault Type |
128
- |----------|------------------|
129
- | `Pattern` | code |
130
- | `Workaround` | code |
131
- | `Performance` | code |
132
- | `Decision` | ecosystem |
133
- | `Convention` | ecosystem |
134
- | `Security` | ecosystem |
135
- | `Integration` | ecosystem |
136
- | *(completion records)* | finalizations |
137
- | *(no category / Note)* | ecosystem (default) |
138
-
139
- If a `finalizations` vault is configured, completion-specific context (e.g., learnings tagged with `--workgroup` or about completed sessions) may be routed there.
140
-
141
- 3. **Parse command arguments**
142
- - Extract insight text from quotes
143
- - Parse `--category` flag (default: auto-detect)
144
- - Parse `--tags` flag (default: extract from content)
145
- - Parse `--vault` flag (optional: explicit vault selection)
146
- - Parse `--source` flag (optional: origin context like "code review", "incident", "meeting")
147
- - Parse `--workgroup` flag (optional: explicit WorkGroup link for traceability)
148
-
149
- 4. **Detect category (if not provided)**
150
- - Scan insight for signal words:
151
- ```
152
- pattern: "pattern", "reusable", "utility", "helper"
153
- decision: "chose", "decided", "opted", "because"
154
- workaround: "workaround", "limitation", "instead"
155
- performance: "optimized", "faster", "reduced", "cache"
156
- security: "security", "vulnerability", "sanitize", "auth"
157
- convention: "always", "never", "standard", "rule"
158
- ```
159
- - Default to "Note" if no clear category detected
160
-
161
- 5. **Extract/validate tags**
162
- - If `--tags` provided, use those
163
- - Otherwise, extract key terms from insight
164
- - Always include current project name
165
- - Add active WorkGroup ID if applicable
166
-
167
- 6. **Check for duplicates in selected vault**
168
- ```bash
169
- search_knowledge(
170
- query: "{insight summary}",
171
- vaultId: "{selected_vault_id}",
172
- limit: 3
173
- )
174
- ```
175
- - If similar exists (>80% match), warn user:
176
- ```
177
- ⚠️ Similar knowledge exists:
178
- > "{existing title}"
179
-
180
- Options:
181
- [Create anyway] [Skip] [Update existing]
182
- ```
183
-
184
- 7. **Build learning content**
185
-
186
- > Vault entries are retrieved via semantic search — content must be detailed and self-contained. See `knowzcode/knowzcode_vaults.md` Content Detail Principle.
187
-
188
- ```markdown
189
- [CONTEXT]
190
- Project: {project-name}
191
- WorkGroup: {--workgroup value or active-workgroup-id or "Manual capture"}
192
- Vault: {selected_vault_name}
193
- Source: {--source value or "KnowzCode /kc:learn command"}
194
- Date: {ISO timestamp}
195
- Situation: {Expand on what prompted this learning — the problem being solved, the component involved, relevant technology stack. Provide enough background that someone unfamiliar with the project can understand.}
196
-
197
- [INSIGHT]
198
- {User's insight text}
199
- Detail: {Expand the user's insight with technical specifics — include file paths, library names, version numbers, code patterns, or error messages that make this actionable when retrieved via search.}
200
-
201
- [SOURCE]
202
- Captured via /kc:learn command
203
- Origin: {--source value or "direct capture"}
204
- ```
205
-
206
- 8. **Create knowledge item in selected vault**
207
- ```json
208
- create_knowledge({
209
- "content": "{formatted content}",
210
- "title": "{Category}: {Descriptive summary — include key technology names for search discoverability}",
211
- "knowledgeType": "Note",
212
- "vaultId": "{selected_vault_id}",
213
- "tags": ["{category}", "{extracted-tags}", "{project-name}"],
214
- "source": "KnowzCode /kc:learn"
215
- })
216
- ```
217
-
218
- 9. **Report success with vault info**
219
- ```
220
- ✅ Learning captured!
221
-
222
- Title: {Category}: {Brief summary}
223
- Vault: {selected_vault_name} ({vault_id prefix...})
224
- Tags: {tag list}
225
-
226
- This knowledge is now available to all KnowzCode agents when querying this vault.
227
- ```
228
-
229
- ## Category Reference
230
-
231
- | Category | When to Use | Signal Words |
232
- |----------|-------------|--------------|
233
- | `Pattern:` | Reusable code pattern | pattern, reusable, utility, helper, abstraction |
234
- | `Decision:` | Architecture/design choice | chose, decided, opted, because, trade-off |
235
- | `Workaround:` | Limitation bypass | workaround, limitation, instead, temporary, bug |
236
- | `Performance:` | Optimization insight | faster, optimized, reduced, improved, cache |
237
- | `Security:` | Security consideration | security, vulnerability, sanitize, auth, encrypt |
238
- | `Convention:` | Team standard | always, never, standard, rule, convention |
239
-
240
- ## Error Handling
241
-
242
- ### MCP Not Connected (Most Common)
243
- ```
244
- ❌ Learning capture requires MCP connection
245
-
246
- The /kc:learn command needs the KnowzCode MCP server to store
247
- learnings in your organization's knowledge vault.
248
-
249
- To get started:
250
-
251
- Recommended (easiest):
252
- /kc:register
253
- (Creates account + configures MCP + sets up vault - all automatic!)
254
-
255
- Already have an API key?
256
- /kc:connect-mcp <your-api-key>
257
-
258
- After setup, run /kc:learn again to capture your insight.
259
- ```
260
-
261
- ### Ecosystem Vault Not Configured
262
- ```
263
- ❌ Ecosystem vault not configured
264
-
265
- MCP is connected, but no vault is set up for learnings.
266
-
267
- Quickest fix:
268
- /kc:register
269
- (Creates account + auto-configures vault)
270
-
271
- Already have an account?
272
- /kc:connect-mcp --configure-vaults
273
- (Prompts for vault ID)
274
-
275
- After setup, run /kc:learn again.
276
- ```
277
-
278
- ### Project Not Initialized
279
- ```
280
- ❌ KnowzCode not initialized
281
-
282
- Run /kc:init first to set up this project, then:
283
- /kc:register (to enable learning capture)
284
- /kc:learn "your insight"
285
- ```
286
-
287
- ### Empty Insight
288
- ```
289
- ❌ No insight provided
290
-
291
- Usage: /kc:learn "your insight here"
292
-
293
- Example:
294
- /kc:learn "Always validate user input at API boundaries"
295
- ```
296
-
297
- ## Integration with Workflow
298
-
299
- ### Automatic Capture (via closer)
300
- The `closer` agent automatically detects and offers to capture learnings during WorkGroup finalization. This is the recommended flow for workflow-related insights.
301
-
302
- ### Manual Capture (via /kc:learn)
303
- Use this command for:
304
- - Ad-hoc insights discovered outside of WorkGroups
305
- - Documenting existing team knowledge
306
- - Capturing external learnings (from reviews, meetings, etc.)
307
-
308
- ## Querying Captured Learnings
309
-
310
- After capturing, learnings are queryable by all agents:
311
-
312
- ```bash
313
- # Resolve vault IDs from knowzcode/knowzcode_vaults.md first, then query by type:
314
-
315
- # By analyst
316
- search_knowledge("authentication patterns", {vault matching "ecosystem" type})
317
-
318
- # By architect
319
- ask_question("What are our error handling conventions?", {vault matching "ecosystem" type})
320
-
321
- # By builder
322
- search_knowledge("database connection best practices", {vault matching "ecosystem" type})
323
- ```
324
-
325
- ## Related Commands
326
-
327
- - `/kc:connect-mcp` - Configure MCP server and vaults
328
- - `/kc:status` - Check vault configuration
329
- - `/kc:work` - Start feature (uses captured learnings)
330
- - `/kc:audit` - Run audits (checks against documented patterns)
331
-
332
- Execute this learning capture now.
1
+ ---
2
+ description: Capture learnings to the KnowzCode ecosystem vault for organizational knowledge
3
+ ---
4
+
5
+ # KnowzCode Learning Capture
6
+
7
+ You are the **KnowzCode Learning Agent**. Your task is to capture insights, patterns, decisions, and best practices to the appropriate vault for future reference.
8
+
9
+ ## Command Syntax
10
+
11
+ ```bash
12
+ /kc:learn "<insight>" [--category <type>] [--tags <tag1,tag2,...>] [--vault <name-or-id>] [--source <origin>] [--workgroup <wgid>]
13
+ ```
14
+
15
+ **Parameters:**
16
+ - `"<insight>"` - Required. The learning to capture (in quotes)
17
+ - `--category <type>` - Optional. Category prefix (pattern, decision, workaround, performance, security, convention)
18
+ - `--tags <tags>` - Optional. Comma-separated tags for categorization
19
+ - `--vault <name-or-id>` - Optional. Target vault for multi-vault setups
20
+ - `--source <origin>` - Optional. Where this learning came from (e.g., "code review", "incident", "meeting", "pair programming")
21
+ - `--workgroup <wgid>` - Optional. Explicitly link this learning to a WorkGroup for traceability
22
+
23
+ **Examples:**
24
+ ```bash
25
+ # Simple learning (auto-routes to appropriate vault)
26
+ /kc:learn "JWT refresh tokens work better than session cookies for stateless APIs"
27
+
28
+ # With category
29
+ /kc:learn "Always sanitize user input before SQL queries" --category security
30
+
31
+ # With tags
32
+ /kc:learn "Repository pattern isolates data access from business logic" --category pattern --tags architecture,data-access
33
+
34
+ # Workaround documentation
35
+ /kc:learn "Azure Blob SDK v12 has memory leak with large files; use streaming instead" --category workaround --tags azure,blob-storage
36
+
37
+ # Explicit vault selection (multi-vault setup)
38
+ /kc:learn "New hire checklist for backend developers" --vault "Company Wiki"
39
+ /kc:learn "We use Repository pattern for all data access" --vault engineering-knowledge
40
+
41
+ # With source and WorkGroup linking
42
+ /kc:learn "Rate limiting should be per-user not per-IP" --source "incident postmortem" --category decision
43
+ /kc:learn "Use streaming for files >10MB" --workgroup kc-feat-file-upload-20260201-120000
44
+ ```
45
+
46
+ ## Prerequisites
47
+
48
+ - KnowzCode MCP server must be connected
49
+ - Ecosystem vault must be configured (auto-configured via `/kc:register`)
50
+ - Project must be initialized (`/kc:init`)
51
+
52
+ **Quickest setup**: Run `/kc:register` - it creates your account AND configures your vault automatically.
53
+
54
+ ## Your Task
55
+
56
+ Capture the provided insight to the appropriate vault using the MCP `create_knowledge` tool.
57
+
58
+ ### Steps to Execute
59
+
60
+ 1. **Quick MCP and Vault Detection (FIRST)**
61
+
62
+ **Step 1a: Check for `create_knowledge` in your available tools list**
63
+
64
+ **If `create_knowledge` is NOT available:**
65
+ - MCP server is not connected
66
+ - Show helpful setup guidance (see Error Handling section)
67
+ - Do NOT attempt any MCP operations
68
+ - STOP here
69
+
70
+ **Step 1b: Read vault configuration**
71
+ - Read `knowzcode/knowzcode_vaults.md` (canonical vault config)
72
+ - Look for a vault entry with type `ecosystem` that has a non-empty ID
73
+ - If not found, fall back to `knowzcode/mcp_config.md` for backwards compatibility
74
+ - Check if Vault ID is set (not empty or "(not configured)")
75
+
76
+ **If Ecosystem Vault ID IS configured:**
77
+ - Proceed to step 2
78
+
79
+ **If Ecosystem Vault ID is "(not configured)" or missing:**
80
+ - Show "vault not configured" error:
81
+ ```
82
+ ❌ Ecosystem vault not configured
83
+
84
+ Your MCP server is connected, but no vault is set up for learnings.
85
+
86
+ Quickest fix:
87
+ /kc:register
88
+ (Creates account + auto-configures vault)
89
+
90
+ Already have an account?
91
+ /kc:connect-mcp --configure-vaults
92
+ (Prompts for vault ID)
93
+
94
+ After setup, run /kc:learn again.
95
+ ```
96
+ - STOP here
97
+
98
+ 2. **Determine Target Vault (Multi-Vault Support)**
99
+
100
+ a. Read `knowzcode/knowzcode_vaults.md` for connected vaults
101
+ b. Route based on category (see Category-to-Vault Routing below)
102
+ c. **If only one vault of the target type** → use it automatically
103
+ d. **If multiple vaults of the target type**:
104
+ - Analyze learning content against vault descriptions
105
+ - Look for keyword matches:
106
+ - "architecture", "pattern", "decision" → vault with architectural content
107
+ - "process", "onboarding", "team" → vault with organizational content
108
+ - "convention", "standard", "rule" → vault with conventions
109
+ - If clear match → use that vault
110
+ - If ambiguous → prompt user:
111
+ ```
112
+ Where should this learning be saved?
113
+
114
+ Available vaults:
115
+ 1. Engineering Knowledge - "architectural decisions, patterns, conventions"
116
+ 2. Company Wiki - "processes, onboarding, team structure"
117
+
118
+ Select vault (1-2) or type vault name:
119
+ ```
120
+ Use AskUserQuestion with vault options.
121
+ e. **If no vaults in knowzcode_vaults.md**:
122
+ - Fall back to `knowzcode/mcp_config.md` Ecosystem Vault ID
123
+ - If still not configured → show "vault not configured" error
124
+
125
+ ### Category-to-Vault Routing
126
+
127
+ | Category | Target Vault Type |
128
+ |----------|------------------|
129
+ | `Pattern` | code |
130
+ | `Workaround` | code |
131
+ | `Performance` | code |
132
+ | `Decision` | ecosystem |
133
+ | `Convention` | ecosystem |
134
+ | `Security` | ecosystem |
135
+ | `Integration` | ecosystem |
136
+ | *(completion records)* | finalizations |
137
+ | *(no category / Note)* | ecosystem (default) |
138
+
139
+ If a `finalizations` vault is configured, completion-specific context (e.g., learnings tagged with `--workgroup` or about completed sessions) may be routed there.
140
+
141
+ 3. **Parse command arguments**
142
+ - Extract insight text from quotes
143
+ - Parse `--category` flag (default: auto-detect)
144
+ - Parse `--tags` flag (default: extract from content)
145
+ - Parse `--vault` flag (optional: explicit vault selection)
146
+ - Parse `--source` flag (optional: origin context like "code review", "incident", "meeting")
147
+ - Parse `--workgroup` flag (optional: explicit WorkGroup link for traceability)
148
+
149
+ 4. **Detect category (if not provided)**
150
+ - Scan insight for signal words:
151
+ ```
152
+ pattern: "pattern", "reusable", "utility", "helper"
153
+ decision: "chose", "decided", "opted", "because"
154
+ workaround: "workaround", "limitation", "instead"
155
+ performance: "optimized", "faster", "reduced", "cache"
156
+ security: "security", "vulnerability", "sanitize", "auth"
157
+ convention: "always", "never", "standard", "rule"
158
+ ```
159
+ - Default to "Note" if no clear category detected
160
+
161
+ 5. **Extract/validate tags**
162
+ - If `--tags` provided, use those
163
+ - Otherwise, extract key terms from insight
164
+ - Always include current project name
165
+ - Add active WorkGroup ID if applicable
166
+
167
+ 6. **Check for duplicates in selected vault**
168
+ ```bash
169
+ search_knowledge(
170
+ query: "{insight summary}",
171
+ vaultId: "{selected_vault_id}",
172
+ limit: 3
173
+ )
174
+ ```
175
+ - If similar exists (>80% match), warn user:
176
+ ```
177
+ ⚠️ Similar knowledge exists:
178
+ > "{existing title}"
179
+
180
+ Options:
181
+ [Create anyway] [Skip] [Update existing]
182
+ ```
183
+
184
+ 7. **Build learning content**
185
+
186
+ > Vault entries are retrieved via semantic search — content must be detailed and self-contained. See `knowzcode/knowzcode_vaults.md` Content Detail Principle.
187
+
188
+ ```markdown
189
+ [CONTEXT]
190
+ Project: {project-name}
191
+ WorkGroup: {--workgroup value or active-workgroup-id or "Manual capture"}
192
+ Vault: {selected_vault_name}
193
+ Source: {--source value or "KnowzCode /kc:learn command"}
194
+ Date: {ISO timestamp}
195
+ Situation: {Expand on what prompted this learning — the problem being solved, the component involved, relevant technology stack. Provide enough background that someone unfamiliar with the project can understand.}
196
+
197
+ [INSIGHT]
198
+ {User's insight text}
199
+ Detail: {Expand the user's insight with technical specifics — include file paths, library names, version numbers, code patterns, or error messages that make this actionable when retrieved via search.}
200
+
201
+ [SOURCE]
202
+ Captured via /kc:learn command
203
+ Origin: {--source value or "direct capture"}
204
+ ```
205
+
206
+ 8. **Create knowledge item in selected vault**
207
+ ```json
208
+ create_knowledge({
209
+ "content": "{formatted content}",
210
+ "title": "{Category}: {Descriptive summary — include key technology names for search discoverability}",
211
+ "knowledgeType": "Note",
212
+ "vaultId": "{selected_vault_id}",
213
+ "tags": ["{category}", "{extracted-tags}", "{project-name}"],
214
+ "source": "KnowzCode /kc:learn"
215
+ })
216
+ ```
217
+
218
+ 9. **Report success with vault info**
219
+ ```
220
+ ✅ Learning captured!
221
+
222
+ Title: {Category}: {Brief summary}
223
+ Vault: {selected_vault_name} ({vault_id prefix...})
224
+ Tags: {tag list}
225
+
226
+ This knowledge is now available to all KnowzCode agents when querying this vault.
227
+ ```
228
+
229
+ ## Category Reference
230
+
231
+ | Category | When to Use | Signal Words |
232
+ |----------|-------------|--------------|
233
+ | `Pattern:` | Reusable code pattern | pattern, reusable, utility, helper, abstraction |
234
+ | `Decision:` | Architecture/design choice | chose, decided, opted, because, trade-off |
235
+ | `Workaround:` | Limitation bypass | workaround, limitation, instead, temporary, bug |
236
+ | `Performance:` | Optimization insight | faster, optimized, reduced, improved, cache |
237
+ | `Security:` | Security consideration | security, vulnerability, sanitize, auth, encrypt |
238
+ | `Convention:` | Team standard | always, never, standard, rule, convention |
239
+
240
+ ## Error Handling
241
+
242
+ ### MCP Not Connected (Most Common)
243
+ ```
244
+ ❌ Learning capture requires MCP connection
245
+
246
+ The /kc:learn command needs the KnowzCode MCP server to store
247
+ learnings in your organization's knowledge vault.
248
+
249
+ To get started:
250
+
251
+ Recommended (easiest):
252
+ /kc:register
253
+ (Creates account + configures MCP + sets up vault - all automatic!)
254
+
255
+ Already have an API key?
256
+ /kc:connect-mcp <your-api-key>
257
+
258
+ After setup, run /kc:learn again to capture your insight.
259
+ ```
260
+
261
+ ### Ecosystem Vault Not Configured
262
+ ```
263
+ ❌ Ecosystem vault not configured
264
+
265
+ MCP is connected, but no vault is set up for learnings.
266
+
267
+ Quickest fix:
268
+ /kc:register
269
+ (Creates account + auto-configures vault)
270
+
271
+ Already have an account?
272
+ /kc:connect-mcp --configure-vaults
273
+ (Prompts for vault ID)
274
+
275
+ After setup, run /kc:learn again.
276
+ ```
277
+
278
+ ### Project Not Initialized
279
+ ```
280
+ ❌ KnowzCode not initialized
281
+
282
+ Run /kc:init first to set up this project, then:
283
+ /kc:register (to enable learning capture)
284
+ /kc:learn "your insight"
285
+ ```
286
+
287
+ ### Empty Insight
288
+ ```
289
+ ❌ No insight provided
290
+
291
+ Usage: /kc:learn "your insight here"
292
+
293
+ Example:
294
+ /kc:learn "Always validate user input at API boundaries"
295
+ ```
296
+
297
+ ## Integration with Workflow
298
+
299
+ ### Automatic Capture (via closer)
300
+ The `closer` agent automatically detects and offers to capture learnings during WorkGroup finalization. This is the recommended flow for workflow-related insights.
301
+
302
+ ### Manual Capture (via /kc:learn)
303
+ Use this command for:
304
+ - Ad-hoc insights discovered outside of WorkGroups
305
+ - Documenting existing team knowledge
306
+ - Capturing external learnings (from reviews, meetings, etc.)
307
+
308
+ ## Querying Captured Learnings
309
+
310
+ After capturing, learnings are queryable by all agents:
311
+
312
+ ```bash
313
+ # Resolve vault IDs from knowzcode/knowzcode_vaults.md first, then query by type:
314
+
315
+ # By analyst
316
+ search_knowledge("authentication patterns", {vault matching "ecosystem" type})
317
+
318
+ # By architect
319
+ ask_question("What are our error handling conventions?", {vault matching "ecosystem" type})
320
+
321
+ # By builder
322
+ search_knowledge("database connection best practices", {vault matching "ecosystem" type})
323
+ ```
324
+
325
+ ## Related Commands
326
+
327
+ - `/kc:connect-mcp` - Configure MCP server and vaults
328
+ - `/kc:status` - Check vault configuration
329
+ - `/kc:work` - Start feature (uses captured learnings)
330
+ - `/kc:audit` - Run audits (checks against documented patterns)
331
+
332
+ Execute this learning capture now.