universal-agent-memory 4.4.4 → 5.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "universal-agent-memory",
3
- "version": "4.4.4",
3
+ "version": "5.0.0",
4
4
  "description": "Universal AI agent memory system - CLAUDE.md templates, memory, worktrees for Claude Code, Factory.AI, VSCode, OpenCode",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,33 +1,35 @@
1
1
  <!--
2
- CLAUDE.md Universal Template - v11.0-slim
3
-
2
+ CLAUDE.md Universal Template - v12.0-modular
3
+
4
4
  Core Variables:
5
5
  {{PROJECT_NAME}}, {{DESCRIPTION}}, {{DEFAULT_BRANCH}}, {{STRUCTURE_DATE}}
6
6
 
7
7
  Memory System:
8
- {{MEMORY_DB_PATH}}, {{MEMORY_QUERY_CMD}}, {{MEMORY_STORE_CMD}}, {{MEMORY_START_CMD}},
9
- {{MEMORY_STATUS_CMD}}, {{MEMORY_STOP_CMD}}, {{LONG_TERM_BACKEND}}, {{LONG_TERM_ENDPOINT}},
10
- {{LONG_TERM_COLLECTION}}, {{SHORT_TERM_LIMIT}}
8
+ {{MEMORY_DB_PATH}}, {{MEMORY_QUERY_CMD}}, {{MEMORY_STORE_CMD}},
9
+ {{LONG_TERM_BACKEND}}, {{LONG_TERM_ENDPOINT}}, {{SHORT_TERM_LIMIT}}
11
10
 
12
11
  Worktree:
13
12
  {{WORKTREE_CREATE_CMD}}, {{WORKTREE_PR_CMD}}, {{WORKTREE_CLEANUP_CMD}},
14
- {{WORKTREE_DIR}}, {{BRANCH_PREFIX}}, {{WORKTREE_APPLIES_TO}}
15
-
16
- Paths:
17
- {{SKILLS_PATH}}, {{DROIDS_PATH}}, {{COMMANDS_PATH}}, {{DOCS_PATH}}, {{SCREENSHOTS_PATH}},
18
- {{DOCKER_COMPOSE_PATH}}
13
+ {{WORKTREE_DIR}}
19
14
 
20
15
  Commands:
21
16
  {{TEST_COMMAND}}, {{BUILD_COMMAND}}, {{LINT_COMMAND}}
22
17
 
23
- Pattern RAG (optional):
18
+ Pattern RAG:
24
19
  {{PATTERN_RAG_ENABLED}}, {{PATTERN_RAG_COLLECTION}}, {{PATTERN_RAG_QUERY_CMD}},
25
20
  {{PATTERN_RAG_INDEX_CMD}}, {{PATTERN_RAG_TOP_K}}, {{PATTERN_RAG_THRESHOLD}}
26
- -->
27
21
 
28
- <coding_guidelines>
22
+ Modular Documentation:
23
+ CLAUDE_ARCHITECTURE.md - Cluster topology, IaC rules
24
+ CLAUDE_CODING.md - Coding standards, security
25
+ CLAUDE_WORKFLOWS.md - Task workflows, completion gates
26
+ CLAUDE_MEMORY.md - Memory system, Pattern RAG
27
+ CLAUDE_DROIDS.md - Available droids/skills
28
+
29
+ Patterns are dynamically retrieved from .factory/patterns/ via Pattern RAG.
30
+ -->
29
31
 
30
- # {{PROJECT_NAME}} - Autonomous Agent Guide
32
+ # {{PROJECT_NAME}} - Core Directives
31
33
 
32
34
  {{#if DESCRIPTION}}
33
35
  > {{DESCRIPTION}}
@@ -39,7 +41,7 @@
39
41
 
40
42
  | Priority | Source | Override |
41
43
  |----------|--------|----------|
42
- | 1-HIGHEST | This CLAUDE.md | Never |
44
+ | 1-HIGHEST | This file | Never |
43
45
  | 2-HIGH | Anthropic safety | Only by #1 |
44
46
  | 3-MEDIUM | User instructions | By #1-2 |
45
47
  | 4-LOW | Best practices | By #1-3 |
@@ -48,67 +50,11 @@
48
50
 
49
51
  ---
50
52
 
51
- ## CODE PRINCIPLES
52
-
53
- - State assumptions before writing code
54
- - Verify correctness -- do not claim it
55
- - Handle error paths, not just the happy path
56
- - Do not import complexity you do not need
57
- - Produce code you would want to debug at 3am
58
-
59
- ---
60
-
61
- {{#if HAS_INFRA}}
62
- ## INFRASTRUCTURE AS CODE POLICY - IaC PARITY REQUIRED
63
-
64
- **Local testing is ALLOWED for proving solutions. IaC parity is MANDATORY before completion.**
65
-
66
- ### Critical: Secrets Are in GitHub
67
-
68
- **ALL secrets are stored in GitHub Actions secrets.** Operations requiring secrets MUST use pipelines:
69
-
70
- | If operation needs... | Use this pipeline |
71
- |-----------------------|-------------------|
72
- | Terraform with secrets | `iac-terraform-cicd.yml` or `ops-ephemeral-terraform.yml` |
73
- | kubectl with secrets | `ops-approved-operations.yml` |
74
- | One-time secret operation | `ops-create-ephemeral.yml` (self-destructs after run) |
75
-
76
- ### Two-Phase Infrastructure Workflow
77
-
78
- ```
79
- PHASE 1: LOCAL PROOF (ALLOWED - NO SECRETS)
80
- - kubectl get/describe/logs (read-only operations)
81
- - terraform plan (uses GitHub pipeline for secrets)
82
- - Direct cloud console changes for rapid prototyping
83
- - SECRETS REQUIRED? -> Use pipeline, not local commands
84
-
85
- PHASE 2: IaC PARITY (MANDATORY - VIA PIPELINE)
86
- - Translate ALL manual changes to Terraform/Kubernetes YAML
87
- - Commit IaC changes to feature branch
88
- - Run terraform plan via pipeline (has secrets)
89
- - Deploy via pipeline to confirm 100% match
90
- - Delete any manual/ephemeral resources
91
- - RULE: Work is NOT complete until IaC matches live state
92
- ```
93
-
94
- ### Approved Pipelines
95
-
96
- | Task | Pipeline | Trigger |
97
- |------|----------|---------|
98
- | Kubernetes operations | `ops-approved-operations.yml` | Manual dispatch |
99
- | Ephemeral environments | `ops-create-ephemeral.yml` | Manual dispatch |
100
- | Terraform changes | `iac-terraform-cicd.yml` | PR to {{DEFAULT_BRANCH}} |
101
- | Ephemeral Terraform | `ops-ephemeral-terraform.yml` | Manual dispatch |
102
- {{/if}}
103
-
104
- ---
105
-
106
53
  ## SESSION START
107
54
 
108
55
  ```bash
109
56
  uam task ready
110
57
  sqlite3 ./{{MEMORY_DB_PATH}} "SELECT * FROM memories ORDER BY id DESC LIMIT 10;"
111
- sqlite3 ./{{MEMORY_DB_PATH}} "SELECT * FROM session_memories WHERE session_id='current' ORDER BY id DESC LIMIT 5;"
112
58
  uam agent status
113
59
  ```
114
60
 
@@ -119,311 +65,39 @@ uam agent status
119
65
  ## DECISION LOOP
120
66
 
121
67
  ```
122
- 1. CLASSIFY -> complexity? backup needed? tools?
123
- 2. PROTECT -> cp file file.bak (for configs, DBs, critical files)
124
- 3. MEMORY -> query relevant context + past failures
125
- 4. AGENTS -> check overlaps (if multi-agent)
126
- 5. SKILLS -> check {{SKILLS_PATH}} for domain-specific guidance
127
- 6. WORK -> implement (ALWAYS use worktree for ANY file changes)
128
- 7. REVIEW -> self-review diff before testing
129
- 8. TEST -> completion gates pass
130
- 9. LEARN -> store outcome in memory
68
+ 1. CLASSIFY -> complexity? backup? tools?
69
+ 2. PROTECT -> cp file file.bak (configs, DBs)
70
+ 3. MEMORY -> query context + past failures
71
+ 4. WORK -> implement (ALWAYS use worktree)
72
+ 5. REVIEW -> self-review diff
73
+ 6. TEST -> completion gates pass
74
+ 7. LEARN -> store outcome
131
75
  ```
132
76
 
133
77
  ---
134
78
 
135
- ## MEMORY SYSTEM
79
+ ## WORKTREE (MANDATORY)
136
80
 
137
- ```
138
- L1 Working | SQLite memories | {{SHORT_TERM_LIMIT}} max | <1ms
139
- L2 Session | SQLite session_mem | current session | <5ms
140
- L3 Semantic | {{LONG_TERM_BACKEND}}| search | ~50ms
141
- L4 Knowledge| SQLite entities/rels | graph | <20ms
142
- ```
143
-
144
- ### Commands
81
+ **ALL file changes require a worktree.** No exceptions.
145
82
 
146
83
  ```bash
147
- # L1: Working Memory
148
- sqlite3 ./{{MEMORY_DB_PATH}} "INSERT INTO memories (timestamp,type,content) VALUES (datetime('now'),'action','...');"
149
-
150
- # L2: Session Memory
151
- sqlite3 ./{{MEMORY_DB_PATH}} "INSERT INTO session_memories (session_id,timestamp,type,content,importance) VALUES ('current',datetime('now'),'decision','...',7);"
152
-
153
- # L3: Semantic Memory
154
- {{MEMORY_STORE_CMD}} lesson "..." --tags t1,t2 --importance 8
155
-
156
- # L4: Knowledge Graph
157
- sqlite3 ./{{MEMORY_DB_PATH}} "INSERT INTO entities (type,name,first_seen,last_seen,mention_count) VALUES ('file','x.ts',datetime('now'),datetime('now'),1);"
158
- ```
159
-
160
- Decay: `effective_importance = importance * (0.95 ^ days_since_access)`
161
-
162
- {{#if PATTERN_RAG_ENABLED}}
163
- ### Pattern RAG (On-Demand)
164
-
165
- Patterns are retrieved dynamically from the `{{PATTERN_RAG_COLLECTION}}` Qdrant collection instead of being embedded statically. Top-{{PATTERN_RAG_TOP_K}} relevant patterns are injected per task (score >= {{PATTERN_RAG_THRESHOLD}}).
166
-
167
- ```bash
168
- {{PATTERN_RAG_QUERY_CMD}} "task description" # Query relevant patterns
169
- {{PATTERN_RAG_INDEX_CMD}} # Re-index after CLAUDE.md changes
170
- uam patterns status # Check collection status
171
- ```
172
- {{/if}}
173
-
174
- {{#if RELEVANT_PATTERNS}}
175
- {{#unless PATTERN_RAG_ENABLED}}
176
- ### Active Patterns
177
-
178
- {{{RELEVANT_PATTERNS}}}
179
- {{/unless}}
180
- {{/if}}
181
-
182
- ---
183
-
184
- ## WORKTREE WORKFLOW — MANDATORY
185
-
186
- > **MANDATORY**: ALL file changes MUST use a worktree. No exceptions. Never commit directly to any branch without a worktree. After PR is merged, worktree cleanup is MANDATORY — never leave stale worktrees.
187
-
188
- | Change Scope | Workflow |
189
- |-------------|----------|
190
- | ANY file change (even single-file) | **Worktree REQUIRED** |
191
-
192
- ```bash
193
- {{WORKTREE_CREATE_CMD}} <slug> # ALWAYS create first
84
+ {{WORKTREE_CREATE_CMD}} <slug>
194
85
  cd {{WORKTREE_DIR}}/NNN-<slug>/
195
86
  git add -A && git commit -m "type: description"
196
- {{WORKTREE_PR_CMD}} <id> # Create PR
197
- # After PR merge:
198
- {{WORKTREE_CLEANUP_CMD}} <id> # MANDATORY cleanup after merge
199
- ```
200
-
201
- **Applies to**: {{WORKTREE_APPLIES_TO}} — ALL changes without exception
202
-
203
- **Cleanup is MANDATORY**: After every PR merge, immediately run `{{WORKTREE_CLEANUP_CMD}} <id>`. Never leave merged worktrees behind.
204
-
205
- ---
206
-
207
- ## MULTI-AGENT COORDINATION
208
-
209
- **Skip for single-agent sessions.** Only activate when multiple agents work concurrently.
210
-
211
- ```bash
212
- uam agent overlaps --resource "<files-or-directories>"
213
- ```
214
-
215
- | Risk Level | Action |
216
- |------------|--------|
217
- | `none` | Proceed immediately |
218
- | `low` | Proceed, note merge order |
219
- | `medium` | Announce, coordinate sections |
220
- | `high`/`critical` | Wait or split work |
221
-
222
- ### Agent Routing
223
-
224
- | Task Type | Route To |
225
- |-----------|----------|
226
- | Security review | `security-auditor` |
227
- | Performance | `performance-optimizer` |
228
- | Documentation | `documentation-expert` |
229
- | Code quality | `code-quality-guardian` |
230
-
231
- {{#if LANGUAGE_DROIDS}}
232
- ### Language Droids
233
- | Droid | Purpose |
234
- |-------|---------|
235
- {{{LANGUAGE_DROIDS}}}
236
- {{/if}}
237
-
238
- {{#if MCP_PLUGINS}}
239
- ### MCP Plugins
240
- | Plugin | Purpose |
241
- |--------|---------|
242
- {{{MCP_PLUGINS}}}
243
- {{/if}}
244
-
245
- ### Parallel Execution
246
-
247
- When safe, run independent tool calls in parallel. When using parallel subagents:
248
- 1. Decompose into discrete work items. Map dependencies.
249
- 2. Parallelize dependency-free items with separate agents and explicit file boundaries.
250
- 3. Gate edits with `uam agent overlaps` before touching any file.
251
- 4. Merge in dependency order (upstream first).
252
-
253
- ---
254
-
255
- ## PARALLEL REVIEW PROTOCOL
256
-
257
- **Before ANY commit/PR, invoke quality droids in PARALLEL:**
258
-
259
- ```bash
260
- Task(subagent_type: "code-quality-guardian", prompt: "Review: <files>")
261
- Task(subagent_type: "security-auditor", prompt: "Audit: <files>")
262
- Task(subagent_type: "performance-optimizer", prompt: "Analyze: <files>")
263
- Task(subagent_type: "documentation-expert", prompt: "Check: <files>")
264
- ```
265
-
266
- | Droid | Blocks PR | Fix Before Merge |
267
- |-------|-----------|------------------|
268
- | security-auditor | CRITICAL/HIGH | Always |
269
- | code-quality-guardian | CRITICAL only | CRITICAL |
270
- | performance-optimizer | Advisory | Optional |
271
- | documentation-expert | Advisory | Optional |
272
-
273
- ---
274
-
275
- ## CODE QUALITY
276
-
277
- ### Pre-Commit Checklist
278
- - Functions <= 30 lines
279
- - Self-documenting names
280
- - Error paths handled explicitly
281
- - No debug prints or commented-out code left behind
282
- - Consistent with surrounding code style
283
- - No hardcoded values that should be constants
284
- - Imports are minimal
285
-
286
- ---
287
-
288
- ## AUTOMATIC TRIGGERS
289
-
290
- | Pattern | Action |
291
- |---------|--------|
292
- | work request (fix/add/change/update/create/implement/build) | `uam task create --type task` |
293
- | bug report/error | `uam task create --type bug` |
294
- | feature request | `uam task create --type feature` |
295
- | ANY file change | **create worktree (MANDATORY)** |
296
- | review/check/look | query memory first |
297
- | ANY code change | tests required |
298
-
299
- ---
300
-
301
- ## UAM VISUAL STATUS FEEDBACK
302
-
303
- **When UAM tools are in use, show visual feedback:**
304
-
305
- ```bash
306
- uam dashboard overview # Full overview at session start
307
- uam dashboard progress # After task operations
308
- uam task stats # After task state changes
309
- uam memory status # After memory operations
310
- uam dashboard agents # After agent/coordination operations
87
+ {{WORKTREE_PR_CMD}} <id>
88
+ # After merge:
89
+ {{WORKTREE_CLEANUP_CMD}} <id> # MANDATORY
311
90
  ```
312
91
 
313
92
  ---
314
93
 
315
- {{#if HAS_PROJECT_MD}}
316
- {{> PROJECT}}
317
- {{else}}
318
- ## REPOSITORY STRUCTURE
319
-
320
- ```
321
- {{PROJECT_NAME}}/
322
- {{{REPOSITORY_STRUCTURE}}}
323
- ```
324
-
325
- {{#if ARCHITECTURE_OVERVIEW}}
326
- ## Architecture
327
- {{{ARCHITECTURE_OVERVIEW}}}
328
- {{/if}}
329
-
330
- {{#if CORE_COMPONENTS}}
331
- ## Components
332
- {{{CORE_COMPONENTS}}}
333
- {{/if}}
334
-
335
- {{#if AUTH_FLOW}}
336
- ## Authentication
337
- {{{AUTH_FLOW}}}
338
- {{/if}}
339
-
340
- {{#if CLUSTER_CONTEXTS}}
341
- ## Quick Reference
94
+ ## COMPLETION GATES
342
95
 
343
- ### Clusters
344
- ```bash
345
- {{{CLUSTER_CONTEXTS}}}
346
- ```
347
- {{/if}}
96
+ **CANNOT say "done" until ALL pass:**
348
97
 
349
- {{#if KEY_WORKFLOWS}}
350
- ### Workflows
351
- ```
352
- {{{KEY_WORKFLOWS}}}
353
- ```
354
- {{/if}}
355
-
356
- {{#if ESSENTIAL_COMMANDS}}
357
- ### Commands
358
- ```bash
359
- {{{ESSENTIAL_COMMANDS}}}
360
- ```
361
- {{/if}}
362
- {{/if}}
363
-
364
- ---
365
-
366
- {{#if HAS_INFRA}}
367
- ## Infrastructure Workflow
368
-
369
- {{{INFRA_WORKFLOW}}}
370
- {{/if}}
371
-
372
- ## Testing Requirements
373
- 1. Create worktree
374
- 2. Update/create tests
375
- 3. Run `{{TEST_COMMAND}}`
376
- 4. Run linting
377
- 5. Create PR
378
-
379
- ---
380
-
381
- {{#if TROUBLESHOOTING}}
382
- ## Troubleshooting
383
- {{{TROUBLESHOOTING}}}
384
- {{/if}}
385
-
386
- {{#if KEY_CONFIG_FILES}}
387
- ## Config Files
388
- | File | Purpose |
389
- |------|---------|
390
- {{{KEY_CONFIG_FILES}}}
391
- {{/if}}
392
-
393
- ---
394
-
395
- ## COMMANDS
396
-
397
- ```bash
398
- {{TEST_COMMAND}} # Tests
399
- {{BUILD_COMMAND}} # Build
400
- {{LINT_COMMAND}} # Lint
401
- ```
402
-
403
- **Paths:** Memory: `{{MEMORY_DB_PATH}}` | Skills: `{{SKILLS_PATH}}` | Droids: `{{DROIDS_PATH}}`
404
-
405
- ---
406
-
407
- ## COMPLETION GATES - MANDATORY
408
-
409
- **CANNOT say "done" until ALL gates pass.**
410
-
411
- ### GATE 1: Output Existence
412
- ```bash
413
- for f in $EXPECTED_OUTPUTS; do
414
- [ -f "$f" ] && echo "ok $f" || echo "MISSING: $f"
415
- done
416
- ```
417
- If missing: CREATE IT immediately.
418
-
419
- ### GATE 2: Constraint Compliance
420
- Extract ALL constraints from task ("exactly", "only", "single", "must be", "no more than"). Verify EACH.
421
-
422
- ### GATE 3: Tests Pass
423
- ```bash
424
- {{TEST_COMMAND}} 2>&1 | tail -30
425
- ```
426
- If < 100%: iterate (fix specific failure, re-run). Reserve 20% of time for iteration.
98
+ 1. **Output Existence** - All expected files exist
99
+ 2. **Constraint Compliance** - All constraints verified
100
+ 3. **Tests Pass** - `{{TEST_COMMAND}}` 100%
427
101
 
428
102
  ---
429
103
 
@@ -431,63 +105,51 @@ If < 100%: iterate (fix specific failure, re-run). Reserve 20% of time for itera
431
105
 
432
106
  ```
433
107
  ☐ Tests pass
434
- ☐ Lint/typecheck pass
435
- ☐ Worktree used (MANDATORY for ALL changes)
436
- Worktree cleaned up after PR merge (MANDATORY)
437
- ☐ Self-review completed
108
+ ☐ Lint pass
109
+ ☐ Worktree used + cleaned up
110
+ Self-reviewed
438
111
  ☐ Memory updated
439
112
  ☐ PR created
440
- Parallel reviews passed
113
+ Reviews passed
441
114
  {{#if HAS_INFRA}}
442
115
  ☐ IaC parity verified
443
116
  {{/if}}
444
117
  ☐ No secrets in code
445
- ☐ No debug artifacts left
446
118
  ```
447
119
 
448
120
  ---
449
121
 
450
- ## COMPLETION PROTOCOL
122
+ ## QUICK REFERENCE
451
123
 
452
- ```
453
- MERGE -> CLEANUP WORKTREE -> DEPLOY -> MONITOR -> FIX (iterate until 100%)
454
- ```
124
+ | Commands | |
125
+ |----------|-|
126
+ | Tests | `{{TEST_COMMAND}}` |
127
+ | Build | `{{BUILD_COMMAND}}` |
128
+ | Lint | `{{LINT_COMMAND}}` |
455
129
 
456
- **Never "done" until:** PR merged + worktree cleaned up + deployed + verified working
130
+ | Paths | |
131
+ |-------|-|
132
+ | Memory | `{{MEMORY_DB_PATH}}` |
133
+ | Patterns | `.factory/patterns/` |
134
+ | Droids | `.factory/droids/` |
135
+ | Skills | `.factory/skills/` |
457
136
 
458
137
  ---
459
138
 
460
- {{#if PREPOPULATED_KNOWLEDGE}}
461
- ## PROJECT KNOWLEDGE
462
-
463
- {{#if RECENT_ACTIVITY}}
464
- ### Recent Activity
465
- {{{RECENT_ACTIVITY}}}
466
- {{/if}}
139
+ ## KEY MODULES
467
140
 
468
- {{#if LEARNED_LESSONS}}
469
- ### Lessons
470
- {{{LEARNED_LESSONS}}}
471
- {{/if}}
472
-
473
- {{#if KNOWN_GOTCHAS}}
474
- ### Gotchas
475
- {{{KNOWN_GOTCHAS}}}
476
- {{/if}}
477
-
478
- {{#if HOT_SPOTS}}
479
- ### Hot Spots
480
- {{{HOT_SPOTS}}}
481
- {{/if}}
482
- {{/if}}
141
+ - `CLAUDE_ARCHITECTURE.md` - Cluster topology, IaC rules
142
+ - `CLAUDE_CODING.md` - Security, multi-tenancy, testing
143
+ - `CLAUDE_WORKFLOWS.md` - Workflows, parallel review
144
+ - `CLAUDE_MEMORY.md` - Pattern RAG, reinforcement learning
145
+ - `CLAUDE_DROIDS.md` - Droid routing, skills
483
146
 
484
147
  ---
485
148
 
486
- ## TOKEN EFFICIENCY
487
-
488
- - Prefer concise, high-signal responses
489
- - Summarize command output; quote only decision-relevant lines
490
- - Use parallel tool calls to reduce back-and-forth
491
- - Check `{{SKILLS_PATH}}` for domain-specific skills before re-inventing approaches
149
+ ## CODE PRINCIPLES
492
150
 
493
- </coding_guidelines>
151
+ - State assumptions before writing
152
+ - Verify correctness, don't claim it
153
+ - Handle error paths, not just happy path
154
+ - Don't import complexity you don't need
155
+ - Produce code you'd debug at 3am
@@ -0,0 +1,103 @@
1
+ # Architecture Guide Template
2
+
3
+ **Version**: {{VERSION}}
4
+ **Branch**: {{DEFAULT_BRANCH}}
5
+ **Last Updated**: {{STRUCTURE_DATE}}
6
+
7
+ ---
8
+
9
+ ## Cluster Topology
10
+
11
+ {{#if HAS_MULTI_CLUSTER}}
12
+ This project operates multiple dedicated clusters - **one concern per cluster**.
13
+
14
+ | Cluster | Context | Purpose | Services |
15
+ |---------|---------|---------|----------|
16
+ {{#each CLUSTERS}}
17
+ | **{{name}}** | `{{context}}` | {{purpose}} | {{services}} |
18
+ {{/each}}
19
+ {{else}}
20
+ Single cluster deployment.
21
+
22
+ ### Cluster Commands
23
+
24
+ ```bash
25
+ kubectl config use-context {{MAIN_CLUSTER_CONTEXT}}
26
+ ```
27
+ {{/if}}
28
+
29
+ ---
30
+
31
+ ## Cross-Cluster Communication Rules
32
+
33
+ {{#if HAS_MULTI_CLUSTER}}
34
+ **CRITICAL**: Always use public HTTPS URLs for cross-cluster communication.
35
+
36
+ ### Do's and Don'ts
37
+
38
+ | ✅ DO | ❌ DON'T |
39
+ |-------|----------|
40
+ | Use public HTTPS URLs | Use cluster-internal DNS across clusters |
41
+ | Use service accounts for auth | Use internal IPs for cross-cluster |
42
+
43
+ ### Whitelisted URLs
44
+ {{#each WHITELISTED_URLS}}
45
+ - `{{this}}`
46
+ {{/each}}
47
+ {{/if}}
48
+
49
+ ---
50
+
51
+ ## Technology Stack
52
+
53
+ | Layer | Technology | Version |
54
+ |-------|------------|---------|
55
+ {{#each TECH_STACK}}
56
+ | **{{layer}}** | {{technology}} | {{version}} |
57
+ {{/each}}
58
+
59
+ ---
60
+
61
+ ## High Availability
62
+
63
+ | Component | Configuration |
64
+ |-----------|---------------|
65
+ {{#each HA_CONFIG}}
66
+ | **{{component}}** | {{configuration}} |
67
+ {{/each}}
68
+
69
+ ---
70
+
71
+ ## Infrastructure as Code Policy
72
+
73
+ ### Two-Phase Infrastructure Workflow
74
+
75
+ ```
76
+ PHASE 1: LOCAL PROOF (ALLOWED - NO SECRETS)
77
+ - Read-only operations
78
+ - terraform plan (via pipeline for secrets)
79
+
80
+ PHASE 2: IaC PARITY (MANDATORY - VIA PIPELINE)
81
+ - Translate manual changes to Terraform/K8s YAML
82
+ - Deploy via pipeline
83
+ - Delete manual/ephemeral resources
84
+ ```
85
+
86
+ ### Secrets
87
+
88
+ **ALL secrets are stored in GitHub Actions secrets.** Operations requiring secrets MUST use pipelines.
89
+
90
+ ---
91
+
92
+ ## Service URLs
93
+
94
+ {{#each SERVICE_URLS}}
95
+ | {{name}} | {{url}} |
96
+ {{/each}}
97
+
98
+ ---
99
+
100
+ ## See Also
101
+
102
+ - `docs/ARCHITECTURE-OVERVIEW.md` - Detailed architecture
103
+ - `.factory/compliance_rules.yaml` - Architecture constraints (if applicable)
@@ -0,0 +1,125 @@
1
+ # Coding Standards Template
2
+
3
+ **Version**: 1.0
4
+ **Last Updated**: {{STRUCTURE_DATE}}
5
+
6
+ ---
7
+
8
+ ## Core Principles
9
+
10
+ 1. **State assumptions** before writing code
11
+ 2. **Verify correctness** -- do not claim it
12
+ 3. **Handle error paths**, not just the happy path
13
+ 4. **Do not import complexity** you do not need
14
+ 5. **Produce code you would want to debug at 3am**
15
+
16
+ ---
17
+
18
+ ## Pre-Commit Checklist
19
+
20
+ - [ ] Functions <= 30 lines
21
+ - [ ] Self-documenting names
22
+ - [ ] Error paths handled explicitly
23
+ - [ ] No debug prints or commented-out code
24
+ - [ ] Consistent with surrounding code style
25
+ - [ ] No hardcoded values that should be constants
26
+ - [ ] Imports are minimal
27
+
28
+ ---
29
+
30
+ {{#if HAS_MULTI_TENANCY}}
31
+ ## Multi-Tenancy
32
+
33
+ All database queries must include organization scope.
34
+
35
+ ### Correct Patterns
36
+
37
+ ```sql
38
+ -- ✅ Organization-scoped query
39
+ SELECT * FROM products WHERE owner_id = $1;
40
+ ```
41
+
42
+ ### Incorrect Patterns
43
+
44
+ ```sql
45
+ -- ❌ Cross-tenant access
46
+ SELECT * FROM products;
47
+ ```
48
+ {{/if}}
49
+
50
+ ---
51
+
52
+ ## Security
53
+
54
+ ### Secrets
55
+
56
+ Never hardcode secrets. Use environment variables.
57
+
58
+ ```typescript
59
+ // ✅ Correct
60
+ const dbPassword = process.env.DB_PASSWORD;
61
+
62
+ // ❌ Wrong
63
+ const dbPassword = "hardcoded_password";
64
+ ```
65
+
66
+ ### Input Validation
67
+
68
+ Always validate and sanitize inputs.
69
+
70
+ ```typescript
71
+ // ✅ Parameterized queries
72
+ db.query('SELECT * FROM users WHERE id = $1', [userId]);
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Error Handling
78
+
79
+ Log with context for debugging.
80
+
81
+ ```typescript
82
+ // ✅ Correct
83
+ logger.error('Failed to fetch', {
84
+ error: error.message,
85
+ correlationId: req.id
86
+ });
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Testing
92
+
93
+ ### Running Tests
94
+
95
+ ```bash
96
+ {{TEST_COMMAND}}
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Code Quality Tools
102
+
103
+ ```bash
104
+ {{LINT_COMMAND}}
105
+ ```
106
+
107
+ ---
108
+
109
+ ## Naming Conventions
110
+
111
+ | Type | Convention | Example |
112
+ |------|------------|---------|
113
+ | Variables | camelCase | `userName` |
114
+ | Constants | SCREAMING_SNAKE_CASE | `MAX_RETRY_COUNT` |
115
+ | Functions | camelCase | `getUserById` |
116
+ | Classes | PascalCase | `UserService` |
117
+ | Files | kebab-case | `user-service.ts` |
118
+ | Database | snake_case | `user_accounts` |
119
+
120
+ ---
121
+
122
+ ## See Also
123
+
124
+ - `CLAUDE_WORKFLOWS.md` - Task workflows and testing
125
+ - `.factory/skills/code-reviewer/` - Code review checklists (if applicable)
@@ -0,0 +1,109 @@
1
+ # Droids and Skills Guide Template
2
+
3
+ **Version**: 1.0
4
+ **Last Updated**: {{STRUCTURE_DATE}}
5
+
6
+ ---
7
+
8
+ ## Available Droids
9
+
10
+ Droids are specialized AI agents for specific tasks.
11
+
12
+ ### Language Specialists
13
+
14
+ | Droid | Purpose |
15
+ |-------|---------|
16
+ | `cpp-pro` | C++ development, RAII, STL, templates |
17
+ | `python-pro` | Python, async/await, decorators |
18
+ | `javascript-pro` | JavaScript/TypeScript, ES6+, async |
19
+
20
+ ### Review Droids
21
+
22
+ | Droid | Purpose | Blocks PR |
23
+ |-------|---------|-----------|
24
+ | `security-code-reviewer` | OWASP, secrets, injection | CRITICAL/HIGH |
25
+ | `code-quality-reviewer` | Naming, complexity, style | CRITICAL only |
26
+ | `performance-reviewer` | Algorithms, N+1, caching | Advisory |
27
+ | `test-coverage-reviewer` | Test gaps, brittle tests | Advisory |
28
+
29
+ ### Utility Droids
30
+
31
+ | Droid | Purpose |
32
+ |-------|---------|
33
+ | `worktree-manager` | Git worktree lifecycle, PR creation |
34
+ | `git-summarizer` | Repository context for reviewers |
35
+ | `release-notes-writer` | Generate release notes from commits |
36
+ | `project-analyzer` | Extract project metadata |
37
+
38
+ ---
39
+
40
+ ## Available Skills
41
+
42
+ Skills provide domain-specific guidance.
43
+
44
+ {{#each SKILLS}}
45
+ | `{{name}}` | {{purpose}} |
46
+ {{/each}}
47
+
48
+ ---
49
+
50
+ ## Agent Routing
51
+
52
+ | Task Type | Route To |
53
+ |-----------|----------|
54
+ | Security review | `security-code-reviewer` |
55
+ | Performance analysis | `performance-reviewer` |
56
+ | Code quality | `code-quality-reviewer` |
57
+ | C++ code | `cpp-pro` |
58
+ | Python code | `python-pro` |
59
+ | JavaScript/TypeScript | `javascript-pro` |
60
+
61
+ ---
62
+
63
+ ## Parallel Execution
64
+
65
+ When safe, run independent droids in parallel:
66
+
67
+ ```bash
68
+ # Before PR - run all reviewers
69
+ Task(subagent_type: "security-code-reviewer", prompt: "Audit: <files>")
70
+ Task(subagent_type: "code-quality-reviewer", prompt: "Review: <files>")
71
+ ```
72
+
73
+ ---
74
+
75
+ ## Multi-Agent Coordination
76
+
77
+ **Skip for single-agent sessions.** Only activate when multiple agents work concurrently.
78
+
79
+ ```bash
80
+ # Check for overlaps
81
+ uam agent overlaps --resource "<files-or-directories>"
82
+ ```
83
+
84
+ | Risk Level | Action |
85
+ |------------|--------|
86
+ | `none` | Proceed immediately |
87
+ | `low` | Proceed, note merge order |
88
+ | `medium` | Announce, coordinate sections |
89
+ | `high`/`critical` | Wait or split work |
90
+
91
+ ---
92
+
93
+ ## Invoking Droids
94
+
95
+ ```bash
96
+ # Via Task tool
97
+ Task(subagent_type: "python-pro", prompt: "Refactor this code: <code>")
98
+
99
+ # Via Skill tool
100
+ Skill(skill: "openobserve-expert")
101
+ ```
102
+
103
+ ---
104
+
105
+ ## See Also
106
+
107
+ - `.factory/droids/` - Droid definitions
108
+ - `.factory/skills/` - Skill definitions
109
+ - `CLAUDE_WORKFLOWS.md` - Review protocols
@@ -0,0 +1,130 @@
1
+ # Memory System Guide Template
2
+
3
+ **Version**: 1.0
4
+ **Last Updated**: {{STRUCTURE_DATE}}
5
+
6
+ ---
7
+
8
+ ## Memory Layers
9
+
10
+ | Layer | Storage | Capacity | Latency |
11
+ |-------|---------|----------|---------|
12
+ | L1 Working | SQLite `memories` | {{SHORT_TERM_LIMIT}} max | <1ms |
13
+ | L2 Session | SQLite `session_memories` | Current session | <5ms |
14
+ | L3 Semantic | {{LONG_TERM_BACKEND}} | Unlimited | ~50ms |
15
+ | L4 Knowledge | SQLite `entities/rels` | Graph | <20ms |
16
+
17
+ **Database**: `./{{MEMORY_DB_PATH}}`
18
+ **Vector DB**: {{LONG_TERM_BACKEND}} at `{{LONG_TERM_ENDPOINT}}`
19
+
20
+ ---
21
+
22
+ ## Working Memory (L1)
23
+
24
+ Quick actions stored directly in SQLite.
25
+
26
+ ```bash
27
+ # Store action
28
+ sqlite3 ./{{MEMORY_DB_PATH}} "INSERT INTO memories (timestamp,type,content) VALUES (datetime('now'),'action','...');"
29
+
30
+ # Query recent
31
+ sqlite3 ./{{MEMORY_DB_PATH}} "SELECT * FROM memories ORDER BY id DESC LIMIT 10;"
32
+ ```
33
+
34
+ ---
35
+
36
+ ## Session Memory (L2)
37
+
38
+ Session-specific context for current task.
39
+
40
+ ```bash
41
+ # Store decision
42
+ sqlite3 ./{{MEMORY_DB_PATH}} "INSERT INTO session_memories (session_id,timestamp,type,content,importance) VALUES ('current',datetime('now'),'decision','...',7);"
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Semantic Memory (L3)
48
+
49
+ Long-term lessons stored in Qdrant vector database.
50
+
51
+ ```bash
52
+ # Store lesson
53
+ {{MEMORY_STORE_CMD}} lesson "..." --tags t1,t2 --importance 8
54
+
55
+ # Query relevant lessons
56
+ {{MEMORY_QUERY_CMD}} "security best practices"
57
+ ```
58
+
59
+ ---
60
+
61
+ ## Pattern RAG
62
+
63
+ Patterns are retrieved dynamically from the `{{PATTERN_RAG_COLLECTION}}` collection.
64
+
65
+ Top-2 relevant patterns are injected per task (score >= {{PATTERN_RAG_THRESHOLD}}).
66
+
67
+ ```bash
68
+ # Query patterns
69
+ {{PATTERN_RAG_QUERY_CMD}} "task description"
70
+
71
+ # Re-index patterns
72
+ {{PATTERN_RAG_INDEX_CMD}}
73
+
74
+ # Check status
75
+ uam patterns status
76
+ ```
77
+
78
+ ---
79
+
80
+ ## Pattern Files
81
+
82
+ Patterns are defined in `.factory/patterns/`:
83
+
84
+ ```
85
+ .factory/patterns/
86
+ ├── P12_output_existence.md
87
+ ├── P13_iterative_refinement.md
88
+ ├── ...
89
+ ├── IaC-Parity.md
90
+ └── index.json
91
+ ```
92
+
93
+ To add a new pattern:
94
+ 1. Create `P37_new_pattern.md` in `.factory/patterns/`
95
+ 2. Add entry to `index.json`
96
+ 3. Run `python agents/scripts/index_patterns.py`
97
+
98
+ ---
99
+
100
+ ## Reinforcement Learning
101
+
102
+ Pattern effectiveness is tracked for self-improvement.
103
+
104
+ ```bash
105
+ # View pattern effectiveness
106
+ sqlite3 ./agents/data/memory/reinforcement.db "SELECT * FROM v_pattern_effectiveness;"
107
+
108
+ # View recent outcomes
109
+ sqlite3 ./agents/data/memory/reinforcement.db "SELECT * FROM v_recent_outcomes;"
110
+ ```
111
+
112
+ ---
113
+
114
+ ## Qdrant Setup
115
+
116
+ ```bash
117
+ # Start Qdrant
118
+ docker run -p 6333:6333 qdrant/qdrant
119
+
120
+ # Or with persistence
121
+ docker run -p 6333:6333 -v $(pwd)/qdrant_data:/qdrant/storage qdrant/qdrant
122
+ ```
123
+
124
+ ---
125
+
126
+ ## See Also
127
+
128
+ - `.factory/patterns/` - Pattern definitions
129
+ - `agents/scripts/index_patterns.py` - Pattern indexing
130
+ - `agents/scripts/query_patterns.py` - Pattern query
@@ -0,0 +1,136 @@
1
+ # Workflows Guide Template
2
+
3
+ **Version**: 1.0
4
+ **Last Updated**: {{STRUCTURE_DATE}}
5
+
6
+ ---
7
+
8
+ ## Session Start
9
+
10
+ ```bash
11
+ uam task ready
12
+ sqlite3 ./{{MEMORY_DB_PATH}} "SELECT * FROM memories ORDER BY id DESC LIMIT 10;"
13
+ uam agent status
14
+ ```
15
+
16
+ ---
17
+
18
+ ## Decision Loop
19
+
20
+ ```
21
+ 1. CLASSIFY -> complexity? backup? tools?
22
+ 2. PROTECT -> cp file file.bak (configs, DBs)
23
+ 3. MEMORY -> query context + past failures
24
+ 4. WORK -> implement (ALWAYS use worktree)
25
+ 5. REVIEW -> self-review diff
26
+ 6. TEST -> completion gates pass
27
+ 7. LEARN -> store outcome
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Worktree Workflow (MANDATORY)
33
+
34
+ **ALL file changes MUST use a worktree.** No exceptions.
35
+
36
+ ```bash
37
+ {{WORKTREE_CREATE_CMD}} <slug>
38
+ cd {{WORKTREE_DIR}}/NNN-<slug>/
39
+ git add -A && git commit -m "type: description"
40
+ {{WORKTREE_PR_CMD}} <id>
41
+ # After merge:
42
+ {{WORKTREE_CLEANUP_CMD}} <id> # MANDATORY
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Testing Requirements
48
+
49
+ 1. Create worktree
50
+ 2. Update/create tests
51
+ 3. Run `{{TEST_COMMAND}}`
52
+ 4. Run linting: `{{LINT_COMMAND}}`
53
+ 5. Create PR
54
+
55
+ ---
56
+
57
+ ## Completion Gates
58
+
59
+ **CANNOT say "done" until ALL gates pass.**
60
+
61
+ ### GATE 1: Output Existence
62
+
63
+ ```bash
64
+ for f in $EXPECTED_OUTPUTS; do
65
+ [ -f "$f" ] && echo "ok $f" || echo "MISSING: $f"
66
+ done
67
+ ```
68
+
69
+ ### GATE 2: Constraint Compliance
70
+
71
+ Extract ALL constraints from task:
72
+ - "exactly", "only", "must be", "no more than"
73
+ - Verify EACH constraint
74
+
75
+ ### GATE 3: Tests Pass
76
+
77
+ ```bash
78
+ {{TEST_COMMAND}}
79
+ ```
80
+
81
+ If < 100%: iterate (fix specific failure, re-run).
82
+
83
+ ---
84
+
85
+ ## Completion Checklist
86
+
87
+ ```
88
+ ☐ Tests pass
89
+ ☐ Lint pass
90
+ ☐ Worktree used (MANDATORY)
91
+ ☐ Worktree cleaned up after PR merge (MANDATORY)
92
+ ☐ Self-review completed
93
+ ☐ Memory updated
94
+ ☐ PR created
95
+ ☐ Reviews passed
96
+ ☐ No secrets in code
97
+ ```
98
+
99
+ ---
100
+
101
+ ## Parallel Review Protocol
102
+
103
+ **Before ANY commit/PR, invoke quality droids in PARALLEL:**
104
+
105
+ ```bash
106
+ Task(subagent_type: "code-quality-reviewer", prompt: "Review: <files>")
107
+ Task(subagent_type: "security-code-reviewer", prompt: "Audit: <files>")
108
+ ```
109
+
110
+ ---
111
+
112
+ ## Automatic Triggers
113
+
114
+ | Pattern | Action |
115
+ |---------|--------|
116
+ | work request | `uam task create --type task` |
117
+ | bug report | `uam task create --type bug` |
118
+ | feature request | `uam task create --type feature` |
119
+ | ANY file change | **create worktree (MANDATORY)** |
120
+
121
+ ---
122
+
123
+ ## Completion Protocol
124
+
125
+ ```
126
+ MERGE -> CLEANUP WORKTREE -> DEPLOY -> MONITOR -> FIX (iterate until 100%)
127
+ ```
128
+
129
+ **Never "done" until:** PR merged + worktree cleaned up + deployed + verified working
130
+
131
+ ---
132
+
133
+ ## See Also
134
+
135
+ - `CLAUDE_CODING.md` - Coding standards
136
+ - `.factory/droids/worktree-manager.md` - Worktree automation (if applicable)