universal-agent-memory 0.2.1 → 0.3.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.
@@ -1,1324 +1,414 @@
1
1
  <!--
2
- CLAUDE.md Universal Template for AI Agent Memory System
2
+ CLAUDE.md Universal Template - Optimized v3.0
3
3
 
4
- This template is the master source for generating project-specific CLAUDE.md files.
5
- It provides autonomous AI agent operation with full memory system, worktrees, and skills.
4
+ Single-source-of-truth workflow engine with zero duplication.
5
+ All variables populated by UAM generator from project analysis.
6
6
 
7
- All variables are populated by the UAM generator from project analysis.
8
-
9
- Template Variables:
10
- ==================
11
- Core:
12
- {{PROJECT_NAME}} - Name of the project (from package.json or git)
13
- {{DEFAULT_BRANCH}} - Main branch name (main/master)
14
- {{STRUCTURE_DATE}} - Date of last structure update
15
-
16
- Memory System:
17
- {{MEMORY_DB_PATH}} - Path to SQLite short-term memory
18
- {{MEMORY_QUERY_CMD}} - Command to query long-term memory
19
- {{MEMORY_STORE_CMD}} - Command to store long-term memory
20
- {{MEMORY_START_CMD}} - Command to start memory services
21
- {{MEMORY_STATUS_CMD}} - Command to check memory status
22
- {{MEMORY_STOP_CMD}} - Command to stop memory services
23
- {{LONG_TERM_BACKEND}} - Backend type (Qdrant/Chroma/etc)
24
- {{LONG_TERM_ENDPOINT}} - Backend endpoint
25
- {{LONG_TERM_COLLECTION}} - Collection name
26
- {{SHORT_TERM_LIMIT}} - Max short-term entries
27
-
28
- Worktree:
29
- {{WORKTREE_CREATE_CMD}} - Command to create worktree
30
- {{WORKTREE_PR_CMD}} - Command to create PR
31
- {{WORKTREE_CLEANUP_CMD}} - Command to cleanup worktree
32
- {{WORKTREE_DIR}} - Worktree directory path
33
- {{WORKTREE_APPLIES_TO}} - What worktrees apply to
34
- {{BRANCH_PREFIX}} - Branch prefix (feature/)
35
-
36
- Paths:
37
- {{SKILLS_PATH}} - Path to skills directory
38
- {{DROIDS_PATH}} - Path to droids directory
39
- {{COMMANDS_PATH}} - Path to commands directory
40
- {{DOCS_PATH}} - Path to documentation
41
- {{SCREENSHOTS_PATH}} - Path for browser screenshots
42
- {{DOCKER_COMPOSE_PATH}} - Path to docker-compose.yml
43
-
44
- Commands:
45
- {{TEST_COMMAND}} - Command to run tests
46
- {{HOOKS_INSTALL_CMD}} - Command to install git hooks
47
-
48
- Optional Sections (Handlebars conditionals):
49
- {{#if SECTION}}...{{/if}}
50
- {{{MULTILINE_CONTENT}}} - Triple braces for multiline
7
+ Template Variables: {{PROJECT_NAME}}, {{PROJECT_PATH}}, {{DEFAULT_BRANCH}},
8
+ {{MEMORY_DB_PATH}}, {{MEMORY_QUERY_CMD}}, {{MEMORY_STORE_CMD}}, {{MEMORY_START_CMD}},
9
+ {{LONG_TERM_BACKEND}}, {{LONG_TERM_ENDPOINT}}, {{LONG_TERM_COLLECTION}}, {{SHORT_TERM_LIMIT}},
10
+ {{WORKTREE_CREATE_CMD}}, {{WORKTREE_PR_CMD}}, {{WORKTREE_CLEANUP_CMD}}, {{WORKTREE_DIR}},
11
+ {{BRANCH_PREFIX}}, {{SKILLS_PATH}}, {{DROIDS_PATH}}, {{COMMANDS_PATH}}, {{DOCS_PATH}},
12
+ {{SCREENSHOTS_PATH}}, {{TEST_COMMAND}}, {{STRUCTURE_DATE}}
51
13
  -->
52
14
 
53
15
  <coding_guidelines>
54
16
 
55
- # CLAUDE.md - {{PROJECT_NAME}} Development Guide
17
+ # {{PROJECT_NAME}} - Autonomous Agent Guide
56
18
 
57
- You are Autonomous Claude, a self-directed AI agent with full control over this virtual machine. You operate continuously, making your own decisions.
58
-
59
- {{#if ISSUE_TRACKER}}
60
- **Note**: {{{ISSUE_TRACKER}}}
61
- {{/if}}
19
+ You are an autonomous AI agent. Follow the WORKFLOW ENGINE below for EVERY action. No exceptions.
62
20
 
63
21
  ---
64
22
 
65
- ## CRITICAL: READ THIS FIRST - EVERY SINGLE TIME
66
-
67
- **YOU MUST FOLLOW THE DECISION LOOP BELOW FOR EVERY ACTION. NO EXCEPTIONS.**
23
+ ## WORKFLOW ENGINE (Execute Every Time)
68
24
 
69
25
  ```
70
26
  ┌─────────────────────────────────────────────────────────────────────────────┐
71
- MANDATORY DECISION LOOP
72
- │ (Execute this for EVERY task) │
73
- ├─────────────────────────────────────────────────────────────────────────────┤
74
- │ │
75
- │ 1. CREATE/CLAIM TASK FIRST │
76
- │ ├─ Check existing: uam task list --show-ready │
77
- │ ├─ Create if needed: uam task create --title "..." --type task │
78
- │ ├─ Claim it: uam task claim <id> │
79
- │ └─ This announces work and detects overlaps automatically │
80
- │ │
81
- │ 2. READ MEMORY │
82
- │ ├─ Query short-term: sqlite3 {{MEMORY_DB_PATH}} │
83
- │ │ "SELECT * FROM memories ORDER BY id DESC LIMIT 20;" │
84
- │ └─ Query long-term for relevant context: │
85
- │ {{MEMORY_QUERY_CMD}} "<keywords related to current task>" │
27
+ MANDATORY WORKFLOW ENGINE
86
28
  │ │
87
- 3. CHECK FOR APPLICABLE SKILLS
88
- ├─ Review {{SKILLS_PATH}} for relevant skills
89
- {{#if PRIMARY_SKILLS}}
90
- {{{PRIMARY_SKILLS}}}
91
- {{/if}}
92
- └─ Invoke skill BEFORE starting implementation
93
-
94
- 4. CREATE WORKTREE (for ANY code changes)
95
- ├─ {{WORKTREE_CREATE_CMD}} <slug>
96
- │ ├─ cd {{WORKTREE_DIR}}/NNN-<slug>/ │
97
- │ └─ NEVER commit directly to {{DEFAULT_BRANCH}} │
98
- │ │
99
- │ 5. CREATE TODO LIST (for 3+ step tasks) │
100
- │ ├─ Use TodoWrite tool immediately │
101
- │ ├─ Update status after EACH step │
102
- │ └─ Mark completed items immediately │
29
+ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐
30
+ │ START │───►│ TASK │───►│ CONTEXT │───►│ WORK │───►│ COMPLETE
31
+ │ └─────────┘ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
32
+ │ │ │ │ │ │ │
33
+ │ ▼ ▼ ▼ ▼ ▼ │
34
+ ┌─────────────────────────────────────────────────────────────────────┐
35
+ CHECK TASKS │ CREATE/CLAIM │ MEMORY+SKILL │ WORKTREE+DO │ VERIFY │ │
36
+ READ MEMORY │ TASK │ CHECK │ TEST+PR │ RELEASE
37
+ └─────────────────────────────────────────────────────────────────────┘
103
38
  │ │
104
- 6. DO THE WORK
105
- │ ├─ Implement changes │
106
- │ ├─ Run tests │
107
- │ └─ Create PR via {{WORKTREE_PR_CMD}} <id> │
108
- │ │
109
- │ 7. UPDATE MEMORY (after EVERY significant action) │
110
- │ ├─ Short-term: INSERT INTO memories... │
111
- │ └─ Long-term (for learnings): {{MEMORY_STORE_CMD}} lesson... │
112
- │ │
113
- │ 8. RELEASE TASK & VERIFY │
114
- │ ├─ Release: uam task release <id> --reason "Completed: ..." │
115
- │ ├─ [ ] Task released? │
116
- │ ├─ [ ] Memory updated? │
117
- │ ├─ [ ] Worktree used? │
118
- │ ├─ [ ] PR created (not direct commit)? │
119
- │ ├─ [ ] Todos updated? │
120
- │ └─ [ ] Skills consulted? │
39
+ GATES: Each phase MUST complete before advancing. No skipping.
121
40
  │ │
122
41
  └─────────────────────────────────────────────────────────────────────────────┘
123
42
  ```
124
43
 
125
- ---
126
-
127
- ## MANDATORY RULES - ZERO TOLERANCE
128
-
129
- **FAILURE TO FOLLOW THESE RULES IS A CRITICAL ERROR. STOP AND RE-READ IF UNSURE.**
130
-
131
- ### 0. TASK MANAGEMENT REQUIREMENT (USE FOR ALL WORK)
132
-
133
- **ALL work MUST be tracked as tasks. This is not optional.**
134
-
135
- ```
136
- ❌ FORBIDDEN: Starting work without creating a task first
137
- ❌ FORBIDDEN: Working on multiple tasks simultaneously without tracking
138
- ❌ FORBIDDEN: Closing tasks without proper completion
139
- ✅ REQUIRED: Create task → Claim task → Do work → Release task
140
- ```
141
-
142
- **Before ANY work:**
143
-
144
- ```bash
145
- # Step 1: Create a task (or find existing one)
146
- uam task create --title "Description of work" --type task --priority 2
147
-
148
- # Step 2: Check for blockers
149
- uam task show <id> # View task details
150
- uam task ready # List tasks ready to work on
151
-
152
- # Step 3: Claim the task (assigns, announces, detects overlaps)
153
- uam task claim <id>
154
-
155
- # Step 4: Do the work (see worktree workflow below)
156
-
157
- # Step 5: Release the task when complete
158
- uam task release <id> --reason "Completed: description of what was done"
159
- ```
160
-
161
- **Task Types:**
162
- | Type | When to Use |
163
- |------|-------------|
164
- | `bug` | Fixing something broken |
165
- | `task` | General work item |
166
- | `feature` | New functionality |
167
- | `chore` | Maintenance, refactoring |
168
- | `epic` | Large multi-task effort |
169
- | `story` | User-facing feature |
170
-
171
- **Priority Levels (P0 = highest):**
172
- | Priority | Meaning | Response Time |
173
- |----------|---------|---------------|
174
- | P0 | Critical | Immediate |
175
- | P1 | High | Same day |
176
- | P2 | Medium | This week |
177
- | P3 | Low | When available |
178
- | P4 | Backlog | Future |
179
-
180
- **Task Dependencies:**
44
+ ### Phase 1: START (Execute on every session/request)
181
45
 
182
46
  ```bash
183
- # Add dependency (task A blocks task B)
184
- uam task dep --from <blocked-task> --to <blocking-task>
185
-
186
- # View blocked tasks
187
- uam task blocked
188
-
189
- # View ready tasks (no blockers)
190
- uam task ready
47
+ uam task ready # What's already in progress?
48
+ sqlite3 {{MEMORY_DB_PATH}} "SELECT * FROM memories ORDER BY id DESC LIMIT 10;"
191
49
  ```
192
50
 
193
- ### 1. WORKTREE REQUIREMENT (NO EXCEPTIONS)
194
-
195
- ```
196
- ❌ FORBIDDEN: Direct commits to {{DEFAULT_BRANCH}} branch
197
- ❌ FORBIDDEN: Making changes without creating worktree first
198
- ✅ REQUIRED: Create worktree → Make changes → Create PR → Merge via PR
199
- ```
51
+ **Gate**: Do NOT proceed until both commands executed.
200
52
 
201
- **Before ANY code change:**
53
+ ### Phase 2: TASK (Create or claim before ANY work)
202
54
 
203
55
  ```bash
204
- # Step 1: Create worktree
205
- {{WORKTREE_CREATE_CMD}} <descriptive-slug>
56
+ # If new work requested:
57
+ uam task create --title "Description" --type task|bug|feature --priority 0-4
206
58
 
207
- # Step 2: cd into worktree and make changes
208
- cd {{WORKTREE_DIR}}/NNN-<slug>/
209
-
210
- # Step 3: Commit and create PR
211
- {{WORKTREE_PR_CMD}} <id>
59
+ # Then claim it:
60
+ uam task claim <id> # Announces work, detects overlaps
212
61
  ```
213
62
 
214
- **Applies to:** {{WORKTREE_APPLIES_TO}}
215
-
216
- ### 2. MEMORY REQUIREMENT (MANDATORY - NOT OPTIONAL)
63
+ **Gate**: Task ID must exist and be claimed before proceeding.
217
64
 
218
- **You MUST update memory. This is not a suggestion.**
65
+ ### Phase 3: CONTEXT (Load relevant knowledge)
219
66
 
220
67
  ```bash
221
- # AFTER EVERY SIGNIFICANT ACTION - update short-term memory:
222
- sqlite3 {{MEMORY_DB_PATH}} \
223
- "INSERT INTO memories (timestamp, type, content) VALUES (datetime('now'), 'action', 'What you did and the result');"
68
+ # Query semantic memory for related learnings
69
+ {{MEMORY_QUERY_CMD}} "<keywords>"
224
70
 
225
- # AFTER EVERY FIX/DISCOVERY/LEARNING - update long-term memory:
226
- {{MEMORY_STORE_CMD}} lesson "What you learned" --tags tag1,tag2 --importance 7
71
+ # Check for applicable skills
72
+ ls {{SKILLS_PATH}}/ # Then invoke: Skill(skill: "name")
227
73
  ```
228
74
 
229
- **MUST store memories for:**
230
-
231
- - ✅ Every bug fix (root cause + solution)
232
- - ✅ Every infrastructure change
233
- - ✅ Every architecture decision
234
- - ✅ Every gotcha or workaround discovered
235
- - ✅ Every performance optimization
236
- - ✅ Every deployment issue and resolution
237
- - ✅ Every API behavior discovery
238
-
239
- **Importance scale:**
75
+ **Gate**: Memory queried and skill identified (if applicable).
240
76
 
241
- - 9-10: Critical system knowledge (will break things if forgotten)
242
- - 7-8: Important patterns and fixes
243
- - 5-6: Useful context and learnings
244
- - 3-4: Minor observations
245
-
246
- ### 3. SKILLS REQUIREMENT (CHECK BEFORE IMPLEMENTING)
247
-
248
- **Before starting ANY implementation, check if a skill applies:**
249
-
250
- | Task Type | Required Skill |
251
- | --------- | -------------- |
252
- {{#if SKILL_MAPPINGS}}
253
- {{{SKILL_MAPPINGS}}}
254
- {{/if}}
255
- | React/TypeScript/Frontend | `senior-frontend` |
256
- | Code review | `code-reviewer` |
257
- | Web testing | `webapp-testing` |
258
-
259
- ```bash
260
- # Invoke skill FIRST, then follow its guidance
261
- Skill(skill: "skill-name")
262
- ```
263
-
264
- ### 4. TODO LIST REQUIREMENT
265
-
266
- - Create todo list for multi-step tasks (3+ steps)
267
- - Update status IMMEDIATELY after completing each item
268
- - Never let todos go stale (update every 5-10 tool calls)
269
- - Use TodoWrite tool, not manual tracking
270
-
271
- ### 5. AGENT COORDINATION REQUIREMENT (MULTI-AGENT ENVIRONMENTS)
272
-
273
- **When working in multi-agent environments, coordination is MANDATORY.**
77
+ ### Phase 4: WORK (All changes in worktree)
274
78
 
275
79
  ```bash
276
- # Register as an agent at session start
277
- uam agent register --name "agent-name" --capabilities "coding,review"
278
-
279
- # Before starting work on any resource, announce your intent
280
- uam agent announce --id <agent-id> --resource "src/auth/" --intent editing \
281
- --description "Refactoring authentication module"
80
+ # Create isolated worktree
81
+ {{WORKTREE_CREATE_CMD}} <slug>
82
+ cd {{WORKTREE_DIR}}/NNN-<slug>/
282
83
 
283
- # Check for overlapping work (merge conflict prevention)
284
- uam agent overlaps --resource "src/auth/"
84
+ # Verify location before ANY edit
85
+ pwd | grep -q "{{WORKTREE_DIR}}" || echo "STOP! Wrong directory!"
285
86
 
286
- # When work is complete, notify others
287
- uam agent complete --id <agent-id> --resource "src/auth/"
87
+ # Make changes, test, commit
88
+ git add -A && git commit -m "type: description"
89
+ {{TEST_COMMAND}}
90
+ {{WORKTREE_PR_CMD}} <id>
288
91
  ```
289
92
 
290
- **Overlap Detection:**
291
- - System automatically detects when multiple agents work on overlapping files
292
- - Conflict risk levels: `none`, `low`, `medium`, `high`, `critical`
293
- - Suggestions provided for merge order and parallel work
93
+ **Gate**: Changes committed via PR from worktree. Never direct to {{DEFAULT_BRANCH}}.
294
94
 
295
- **Deploy Batching (for CI/CD efficiency):**
95
+ ### Phase 5: COMPLETE (Verify and release)
296
96
 
297
97
  ```bash
298
- # Queue commits for batching (saves CI minutes)
299
- uam deploy queue --agent-id <id> --action-type commit \
300
- --message "feat: add feature" --files "src/feature.ts"
301
-
302
- # View pending deploys
303
- uam deploy status
98
+ # Update memories
99
+ sqlite3 {{MEMORY_DB_PATH}} "INSERT INTO memories (timestamp, type, content) VALUES (datetime('now'), 'action', 'What was done');"
100
+ {{MEMORY_STORE_CMD}} lesson "Key learning" --tags relevant,tags --importance 7
304
101
 
305
- # Batch and execute all pending deploys
306
- uam deploy flush
102
+ # Release task
103
+ uam task release <id> --reason "Completed: summary"
307
104
  ```
308
105
 
309
- ### 6. VERIFICATION BEFORE EVERY RESPONSE
310
-
311
- Before sending ANY response, verify:
106
+ **Gate**: All items verified before responding:
312
107
 
313
108
  ```
314
- ┌─────────────────────────────────────────────────────────────┐
315
- CHECKLIST - Complete before responding: │
316
- ├─────────────────────────────────────────────────────────────┤
317
- │ [ ] Task created/claimed for this work? │
318
- │ [ ] Read memory at start of task? │
319
- │ [ ] Checked for applicable skills? │
320
- │ [ ] Announced work (multi-agent)? │
321
- │ [ ] Checked for overlaps (multi-agent)? │
322
- │ [ ] Used worktree for code changes? │
323
- │ [ ] Updated short-term memory after actions? │
324
- │ [ ] Stored learnings in long-term memory? │
325
- │ [ ] Updated todo list status? │
326
- │ [ ] Created PR (not direct commit)? │
327
- │ [ ] Released task when complete? │
328
- └─────────────────────────────────────────────────────────────┘
109
+ [ ] Task released? [ ] PR created (not direct push)?
110
+ [ ] Memory updated? [ ] Tests passing?
111
+ [ ] Worktree used? [ ] Skills consulted?
329
112
  ```
330
113
 
331
114
  ---
332
115
 
333
- ## MEMORY SYSTEM (4-Layer Architecture)
334
-
335
- > **Architecture Note**: This system is based on research into MemGPT, Mem0, A-MEM, LangGraph, and
336
- > industry best practices for agentic memory systems.
337
-
338
- ### Architecture Overview
339
-
340
- ```
341
- ┌─────────────────────────────────────────────────────────────────────┐
342
- │ FOUR-LAYER MEMORY ARCHITECTURE │
343
- ├─────────────────────────────────────────────────────────────────────┤
344
- │ │
345
- │ LAYER 1: WORKING MEMORY (SQLite) ~0.15ms access │
346
- │ ├─ {{SHORT_TERM_LIMIT}} entries max, FIFO eviction │
347
- │ ├─ Types: action, observation, thought, goal │
348
- │ └─ Immediate context for current task │
349
- │ │
350
- │ LAYER 2: SESSION MEMORY (SQLite) ~0.2ms access │
351
- │ ├─ Session-scoped summaries and decisions │
352
- │ ├─ Entities mentioned with context │
353
- │ └─ Cleaned on session end (optional persistence) │
354
- │ │
355
- │ LAYER 3: SEMANTIC MEMORY ({{LONG_TERM_BACKEND}}) ~1-2ms search │
356
- │ ├─ Vector embeddings (384-dim all-MiniLM-L6-v2) │
357
- │ ├─ Importance scoring with time-based decay │
358
- │ └─ Deduplication via content hash + similarity │
359
- │ │
360
- │ LAYER 4: KNOWLEDGE GRAPH (SQLite) ~0.17ms query │
361
- │ ├─ Entities: files, functions, concepts, errors, configs │
362
- │ ├─ Relationships: depends_on, fixes, causes, related_to │
363
- │ └─ Multi-hop traversal for complex reasoning │
364
- │ │
365
- └─────────────────────────────────────────────────────────────────────┘
366
- ```
367
-
368
- ### Installation & Setup
116
+ ## QUICK REFERENCE
369
117
 
118
+ ### Task Commands
370
119
  ```bash
371
- # 1. Install UAM globally or in project
372
- npm install -g universal-agent-memory
373
- # or
374
- npm install --save-dev universal-agent-memory
375
-
376
- # 2. Initialize in your project
377
- uam init
378
-
379
- # 3. Start memory services (Qdrant for vector search)
380
- {{MEMORY_START_CMD}}
381
-
382
- # 4. Generate CLAUDE.md with memory integration
383
- uam generate
384
-
385
- # 5. Verify setup
386
- {{MEMORY_STATUS_CMD}}
120
+ uam task create --title "..." --type task|bug|feature|chore|epic|story --priority 0-4
121
+ uam task list [--filter-status open|in_progress] [--filter-priority 0,1]
122
+ uam task ready # Show unblocked tasks
123
+ uam task blocked # Show blocked tasks
124
+ uam task claim <id> # Claim and start work
125
+ uam task show <id> # View details
126
+ uam task release <id> --reason "..." # Complete task
127
+ uam task dep --from <blocked> --to <blocker> # Add dependency
387
128
  ```
388
129
 
389
- ### Layer 1: Working Memory (SQLite)
390
-
391
- **Location**: `{{MEMORY_DB_PATH}}`
392
-
393
- **Table: `memories`**
394
-
395
- | Column | Type | Description |
396
- |--------|------|-------------|
397
- | `id` | INTEGER | Primary key, auto-increment |
398
- | `timestamp` | TEXT | ISO8601 timestamp |
399
- | `type` | TEXT | action, observation, thought, goal |
400
- | `content` | TEXT | Memory content |
401
-
402
- **BEFORE EACH DECISION**: Query recent entries
403
-
404
- ```sql
405
- SELECT * FROM memories ORDER BY id DESC LIMIT {{SHORT_TERM_LIMIT}};
406
- ```
407
-
408
- **AFTER EACH ACTION**: Record what you did
409
-
410
- ```sql
411
- INSERT INTO memories (timestamp, type, content)
412
- VALUES (datetime('now'), 'action', 'Description of action and result');
413
- ```
414
-
415
- **Or use the CLI:**
416
-
130
+ ### Worktree Commands
417
131
  ```bash
418
- uam memory add --type action "Implemented user authentication with JWT"
132
+ {{WORKTREE_CREATE_CMD}} <slug> # Create feature branch
133
+ cd {{WORKTREE_DIR}}/NNN-<slug>/ # Enter worktree
134
+ {{WORKTREE_PR_CMD}} <id> # Create PR
135
+ {{WORKTREE_CLEANUP_CMD}} <id> # Remove worktree
419
136
  ```
420
137
 
421
- Maintains last {{SHORT_TERM_LIMIT}} entries - older entries auto-deleted via trigger.
422
-
423
- ### Layer 2: Session Memory (SQLite)
424
-
425
- **Table: `session_memories`** (in same database as working memory)
426
-
427
- | Column | Type | Description |
428
- |--------|------|-------------|
429
- | `id` | INTEGER | Primary key |
430
- | `session_id` | TEXT | Current session identifier |
431
- | `timestamp` | TEXT | ISO8601 timestamp |
432
- | `type` | TEXT | summary, decision, entity, error |
433
- | `content` | TEXT | Memory content |
434
- | `importance` | INTEGER | 1-10 importance score |
435
-
436
- **Query session context:**
437
-
438
- ```sql
439
- SELECT * FROM session_memories
440
- WHERE session_id = 'current_session'
441
- ORDER BY id DESC LIMIT 10;
442
- ```
443
-
444
- **Store session decision:**
445
-
446
- ```sql
447
- INSERT INTO session_memories (session_id, timestamp, type, content, importance)
448
- VALUES ('current_session', datetime('now'), 'decision', 'Chose approach X because...', 7);
449
- ```
450
-
451
- **Types**: summary, decision, entity, error
452
-
453
- ### Layer 3: Semantic Memory ({{LONG_TERM_BACKEND}})
454
-
455
- **Collection**: `{{LONG_TERM_COLLECTION}}` at `{{LONG_TERM_ENDPOINT}}`
456
-
457
- **Vector Schema**:
458
-
459
- | Field | Type | Description |
460
- |-------|------|-------------|
461
- | `id` | UUID | Unique identifier |
462
- | `vector` | float[384] | Embedding (all-MiniLM-L6-v2) |
463
- | `content` | string | Original memory text |
464
- | `type` | string | lesson, bug-fix, architecture, gotcha |
465
- | `tags` | string[] | Categorization tags |
466
- | `importance` | int | 1-10 importance score |
467
- | `timestamp` | string | ISO8601 creation time |
468
- | `decay_score` | float | Time-based decay factor |
469
- | `content_hash` | string | MD5 hash for deduplication |
470
-
471
- **Query memories** (semantic search):
472
-
138
+ ### Memory Commands
473
139
  ```bash
474
- {{MEMORY_QUERY_CMD}} "<search terms>"
140
+ # Short-term (after every action)
141
+ sqlite3 {{MEMORY_DB_PATH}} "INSERT INTO memories (timestamp, type, content) VALUES (datetime('now'), 'action', 'description');"
475
142
 
476
- # Examples:
477
- {{MEMORY_QUERY_CMD}} "authentication JWT token"
478
- {{MEMORY_QUERY_CMD}} "database connection pooling"
479
- {{MEMORY_QUERY_CMD}} "React state management"
143
+ # Long-term (for learnings, importance 7+)
144
+ {{MEMORY_QUERY_CMD}} "<search>"
145
+ {{MEMORY_STORE_CMD}} lesson "learning" --tags a,b --importance 8
480
146
  ```
481
147
 
482
- **Store new memory** (importance 7+ recommended):
483
-
148
+ ### Agent Coordination (Multi-agent only)
484
149
  ```bash
485
- {{MEMORY_STORE_CMD}} lesson "What you learned" --tags tag1,tag2 --importance 8
486
-
487
- # Examples:
488
- {{MEMORY_STORE_CMD}} lesson "Always check network policies before deploying" --tags kubernetes,networking --importance 8
489
- {{MEMORY_STORE_CMD}} bug-fix "Connection timeout was caused by missing egress rule" --tags networking,debugging --importance 9
490
- {{MEMORY_STORE_CMD}} architecture "Chose Redis for caching due to sub-ms latency requirements" --tags caching,performance --importance 7
491
- ```
492
-
493
- **Decay Formula**: `effective_importance = importance * (0.95 ^ days_since_access)`
494
-
495
- **WHEN TO STORE IN SEMANTIC MEMORY** (importance 7+):
496
-
497
- - ✅ Bug fixes with root cause + solution
498
- - ✅ Architecture decisions with rationale
499
- - ✅ Performance optimizations that worked
500
- - ✅ Gotchas and workarounds discovered
501
- - ✅ API behaviors that aren't obvious
502
- - ❌ Routine actions (keep in working memory)
503
- - ❌ Temporary context (keep in session memory)
504
-
505
- **Deduplication Strategy**:
506
-
507
- 1. Compute content hash (MD5 first 16 chars)
508
- 2. If hash exists, skip (fast path)
509
- 3. If unsure, check semantic similarity (threshold 0.92)
510
- 4. Only add if truly new information
511
-
512
- ### Layer 4: Knowledge Graph (SQLite)
513
-
514
- **Tables**: `entities` and `relationships` (in same database)
515
-
516
- **Entities Table:**
517
-
518
- | Column | Type | Description |
519
- |--------|------|-------------|
520
- | `id` | INTEGER | Primary key |
521
- | `type` | TEXT | file, function, concept, error, config, service |
522
- | `name` | TEXT | Entity name/identifier |
523
- | `first_seen` | TEXT | First mention timestamp |
524
- | `last_seen` | TEXT | Last mention timestamp |
525
- | `mention_count` | INTEGER | How often referenced |
526
-
527
- **Relationships Table:**
528
-
529
- | Column | Type | Description |
530
- |--------|------|-------------|
531
- | `id` | INTEGER | Primary key |
532
- | `source_id` | INTEGER | Source entity ID |
533
- | `target_id` | INTEGER | Target entity ID |
534
- | `relation` | TEXT | depends_on, fixes, causes, related_to, contains, implements |
535
- | `timestamp` | TEXT | When relationship was established |
536
-
537
- **Query related entities (1-hop):**
538
-
539
- ```sql
540
- SELECT e.*, r.relation, e2.name as related
541
- FROM entities e
542
- LEFT JOIN relationships r ON e.id = r.source_id
543
- LEFT JOIN entities e2 ON r.target_id = e2.id
544
- WHERE e.name LIKE '%api%';
545
- ```
546
-
547
- **Add entity:**
548
-
549
- ```sql
550
- INSERT OR REPLACE INTO entities (type, name, first_seen, last_seen, mention_count)
551
- VALUES ('file', 'auth-controller.ts', datetime('now'), datetime('now'), 1);
552
- ```
553
-
554
- **Add relationship:**
555
-
556
- ```sql
557
- INSERT INTO relationships (source_id, target_id, relation, timestamp)
558
- VALUES (1, 2, 'depends_on', datetime('now'));
150
+ uam agent register --name "name" --capabilities "coding,review"
151
+ uam agent announce --id <id> --resource "path/" --intent editing
152
+ uam agent overlaps --resource "path/"
153
+ uam agent complete --id <id> --resource "path/"
154
+ uam deploy queue --agent-id <id> --action-type commit --message "..." --files "..."
155
+ uam deploy flush
559
156
  ```
560
157
 
561
- **Or use the CLI:**
562
-
158
+ ### Skills & Droids
563
159
  ```bash
564
- uam memory entity add --type file --name "auth-controller.ts"
565
- uam memory relation add --source "auth-controller.ts" --target "jwt-utils.ts" --relation depends_on
566
- ```
567
-
568
- ### Memory Operations Workflow
569
-
570
- ```
571
- ┌─────────────────────────────────────────────────────────────────┐
572
- │ MEMORY OPERATION FLOW │
573
- ├─────────────────────────────────────────────────────────────────┤
574
- │ │
575
- │ ON TASK START: │
576
- │ 1. Query working memory (last 20 entries) │
577
- │ 2. Query semantic memory for relevant context │
578
- │ 3. Check knowledge graph for related entities │
579
- │ │
580
- │ DURING TASK: │
581
- │ 4. Update working memory after each action │
582
- │ 5. Store key decisions in session memory │
583
- │ │
584
- │ ON SIGNIFICANT LEARNING: │
585
- │ 6. Store in semantic memory (importance 7+) │
586
- │ 7. Update knowledge graph entities/relationships │
587
- │ │
588
- │ ON CONSOLIDATION TRIGGER (every 10 working memory entries): │
589
- │ 8. Summarize working memory → session memory │
590
- │ 9. Extract high-importance items → semantic memory │
591
- │ 10. Deduplicate using content hash (fast) + similarity (slow) │
592
- │ │
593
- └─────────────────────────────────────────────────────────────────┘
160
+ Skill(skill: "typescript-node-expert") # Inline guidance
161
+ Skill(skill: "cli-design-expert") # CLI work
162
+ Skill(skill: "senior-frontend") # React/TS work
163
+ Task(subagent_type: "code-quality-guardian", prompt: "Review...")
164
+ Task(subagent_type: "security-auditor", prompt: "Audit...")
594
165
  ```
595
166
 
596
- ### Agent Services Setup
597
-
598
- ```bash
599
- # Start all memory services (Qdrant for vectors, auto-creates collections)
600
- {{MEMORY_START_CMD}}
601
-
602
- # Check service status
603
- {{MEMORY_STATUS_CMD}}
604
-
605
- # Stop services
606
- {{MEMORY_STOP_CMD}}
607
-
608
- # Upgrade SQLite schema (adds session memory + knowledge graph tables)
609
- uam memory migrate
610
-
611
- # Backup all memories
612
- uam memory backup
613
-
614
- # Export memories to JSON
615
- uam memory export --format json memories-backup.json
616
- ```
167
+ ---
617
168
 
618
- {{#if DOCKER_COMPOSE_PATH}}
619
- **Docker Compose**: `{{DOCKER_COMPOSE_PATH}}` defines Qdrant with persistent storage.
620
-
621
- ```yaml
622
- # Example docker-compose.yml for memory services
623
- services:
624
- qdrant:
625
- image: qdrant/qdrant:latest
626
- ports:
627
- - "6333:6333"
628
- volumes:
629
- - ./data/qdrant:/qdrant/storage
630
- ```
169
+ ## AUTOMATIC TRIGGERS
170
+
171
+ | Pattern Detected | Immediate Action |
172
+ |-----------------|------------------|
173
+ | Work request (fix/add/change/create/build) | `uam task create --title "..." --type task` |
174
+ | Bug report or error | `uam task create --title "..." --type bug --priority 1` |
175
+ | Feature request | `uam task create --title "..." --type feature` |
176
+ | Code file editing | Check skills → Create worktree → Edit |
177
+ | Review/check request | Query memory first |
178
+ {{#if SKILL_TRIGGERS}}
179
+ {{{SKILL_TRIGGERS}}}
631
180
  {{/if}}
632
181
 
633
- ### Performance Benchmarks
634
-
635
- | Operation | Latency | Throughput |
636
- |-----------|---------|------------|
637
- | SQLite INSERT | ~1.1ms | 875 ops/sec |
638
- | SQLite SELECT (50 rows) | ~0.15ms | 6,680 ops/sec |
639
- | SQLite Graph Query (1-hop) | ~0.17ms | 6,035 ops/sec |
640
- | Qdrant Search (top-5) | ~1.2ms | 818 ops/sec |
641
- | Embedding Generation | ~3.3ms | 305 ops/sec |
642
-
643
- ### Importance Scale Reference
644
-
645
- | Score | Category | Examples |
646
- |-------|----------|----------|
647
- | 9-10 | Critical system knowledge | Auth flows, data models, breaking changes |
648
- | 7-8 | Important patterns and fixes | Bug fixes, performance optimizations |
649
- | 5-6 | Useful context and learnings | Code patterns, tool configurations |
650
- | 3-4 | Minor observations | Style preferences, minor quirks |
651
-
652
182
  ---
653
183
 
654
- ## TASK MANAGEMENT SYSTEM
655
-
656
- > **Superior to Beads**: Integrated task management with memory, coordination, and deploy batching.
657
-
658
- ### Task Lifecycle
659
-
660
- ```
661
- ┌─────────────────────────────────────────────────────────────────────────────┐
662
- │ TASK LIFECYCLE │
663
- ├─────────────────────────────────────────────────────────────────────────────┤
664
- │ │
665
- │ CREATE CLAIM WORK RELEASE │
666
- │ ──────► ──────► ──────► ──────► │
667
- │ │
668
- │ uam task uam task (worktree uam task │
669
- │ create claim <id> workflow) release <id> │
670
- │ --title "..." │
671
- │ - Assigns to you - Marks done │
672
- │ - Announces work - Notifies others │
673
- │ - Creates worktree - Stores in memory │
674
- │ - Detects overlaps │
675
- │ │
676
- └─────────────────────────────────────────────────────────────────────────────┘
677
- ```
678
-
679
- ### Essential Commands
184
+ ## RECOVERY PROCEDURES
680
185
 
186
+ ### Forgot to create task?
681
187
  ```bash
682
- # Create a new task
683
- uam task create --title "Fix auth bug" --type bug --priority 0 --labels "security,auth"
684
-
685
- # List tasks
686
- uam task list # All open tasks
687
- uam task list --filter-status in_progress # In-progress only
688
- uam task list --filter-priority 0,1 # P0 and P1 only
689
- uam task ready # Ready to work (no blockers)
690
- uam task blocked # Blocked tasks
691
-
692
- # Work on a task
693
- uam task claim <id> # Claim and start
694
- uam task show <id> # View details
695
- uam task update <id> --status in_progress # Update status
696
- uam task release <id> --reason "Fixed" # Complete
697
-
698
- # Dependencies (DAG)
699
- uam task dep --from <child> --to <parent> # Add dependency
700
- uam task undep --from <child> --to <parent> # Remove dependency
701
-
702
- # Statistics and sync
703
- uam task stats # View statistics
704
- uam task sync # Sync with JSONL (git-tracked)
705
- uam task compact --days 90 # Archive old tasks
188
+ # Create task now, link existing work
189
+ uam task create --title "Retroactive: what you did" --type task
190
+ uam task update <id> --status in_progress
191
+ # Continue with workflow, release when done
706
192
  ```
707
193
 
708
- ### Task Hierarchy
709
-
710
- ```
711
- Epic (large effort)
712
- ├── Story (user-facing feature)
713
- │ ├── Task (implementation unit)
714
- │ └── Task
715
- └── Story
716
- ├── Task
717
- ├── Bug (defect fix)
718
- └── Chore (maintenance)
719
- ```
720
-
721
- Create hierarchies with `--parent`:
722
-
194
+ ### Forgot worktree? Edited main repo directly?
723
195
  ```bash
724
- uam task create --title "Authentication System" --type epic
725
- uam task create --title "Login Flow" --type story --parent uam-xxxx
726
- uam task create --title "Implement JWT validation" --type task --parent uam-yyyy
727
- ```
728
-
729
- ### Integration with Coordination
730
-
731
- When you claim a task, the system automatically:
732
- 1. Assigns the task to your agent ID
733
- 2. Announces work to coordination system
734
- 3. Detects overlapping work from other agents
735
- 4. Creates/associates a worktree branch
736
- 5. Returns conflict warnings if detected
196
+ # If not committed yet: stash and move to worktree
197
+ git stash
198
+ {{WORKTREE_CREATE_CMD}} <slug>
199
+ cd {{WORKTREE_DIR}}/NNN-<slug>/
200
+ git stash pop
737
201
 
738
- ```bash
739
- # Claim with overlap detection
740
- $ uam task claim uam-a1b2
741
- Task claimed: uam-a1b2
742
- Refactor authentication module
743
- Worktree: feature/task-uam-a1b2
744
-
745
- ⚠️ Overlapping work detected:
746
- medium: agent-007 is editing src/auth/jwt.ts - coordinate merge order
202
+ # If already committed: cherry-pick to worktree, reset main
203
+ git log -1 --format="%H" # Note commit hash
204
+ git reset --hard HEAD~1 # Remove from main
205
+ {{WORKTREE_CREATE_CMD}} <slug>
206
+ cd {{WORKTREE_DIR}}/NNN-<slug>/
207
+ git cherry-pick <hash>
747
208
  ```
748
209
 
749
- ### JSONL Git Sync
750
-
751
- Tasks are stored in SQLite but can be synced to JSONL for git versioning:
752
-
210
+ ### Command failed?
753
211
  ```bash
754
- # Export current tasks to JSONL
755
- uam task sync
212
+ # Check service status
213
+ {{MEMORY_START_CMD}}
214
+ uam coord status
756
215
 
757
- # File: .uam/tasks/tasks.jsonl
758
- {"id":"uam-a1b2","title":"Fix auth","type":"bug","status":"open",...}
759
- {"id":"uam-c3d4","title":"Add feature","type":"feature","status":"done",...}
216
+ # Verify database exists
217
+ ls -la {{MEMORY_DB_PATH}}
760
218
  ```
761
219
 
762
- This allows:
763
- - Version control of task history
764
- - Conflict resolution via git
765
- - Sharing tasks across branches/forks
766
- - Audit trail of task changes
767
-
768
220
  ---
769
221
 
770
- ## AGENT COORDINATION SYSTEM
222
+ ## RULES (Zero Tolerance)
771
223
 
772
- > **For multi-agent environments**: Prevents merge conflicts and optimizes CI/CD.
224
+ ### 1. Tasks
225
+ - **ALWAYS** create task before work
226
+ - **ALWAYS** claim before starting
227
+ - **ALWAYS** release when complete
228
+ - **NEVER** work without task tracking
773
229
 
774
- ### Architecture
230
+ ### 2. Worktrees
231
+ - **ALWAYS** create worktree for code changes
232
+ - **ALWAYS** verify `pwd` contains `{{WORKTREE_DIR}}`
233
+ - **ALWAYS** use PR, never direct push
234
+ - **NEVER** commit directly to {{DEFAULT_BRANCH}}
775
235
 
776
- ```
777
- ┌─────────────────────────────────────────────────────────────────────────────┐
778
- │ AGENT COORDINATION SYSTEM │
779
- ├─────────────────────────────────────────────────────────────────────────────┤
780
- │ │
781
- │ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
782
- │ │ Agent A │ │ Agent B │ │ Agent C │ │
783
- │ │ (worktree) │ │ (worktree) │ │ (worktree) │ │
784
- │ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
785
- │ │ │ │ │
786
- │ ▼ ▼ ▼ │
787
- │ ┌─────────────────────────────────────────────────────────────────────┐ │
788
- │ │ COORDINATION SERVICE │ │
789
- │ ├─────────────────────────────────────────────────────────────────────┤ │
790
- │ │ • Agent Registry (who is active) │ │
791
- │ │ • Work Announcements (who is working where) │ │
792
- │ │ • Overlap Detection (conflict risk assessment) │ │
793
- │ │ • Message Passing (inter-agent communication) │ │
794
- │ │ • Deploy Queue (batched commits/pushes) │ │
795
- │ └─────────────────────────────────────────────────────────────────────┘ │
796
- │ │
797
- └─────────────────────────────────────────────────────────────────────────────┘
798
- ```
799
-
800
- ### Agent Lifecycle
801
-
802
- ```bash
803
- # Register at session start
804
- uam agent register --name "feature-agent" --capabilities "coding,testing" \
805
- --worktree "feature/add-auth"
806
-
807
- # Send heartbeat (keeps agent active)
808
- uam agent heartbeat --id <agent-id>
809
-
810
- # View active agents
811
- uam agent status
236
+ ### 3. Memory
237
+ - **ALWAYS** query memory at task start
238
+ - **ALWAYS** update short-term after actions
239
+ - **ALWAYS** store learnings (importance 7+) in long-term
240
+ - **NEVER** complete task without memory update
812
241
 
813
- # Deregister when done
814
- uam agent deregister --id <agent-id>
815
- ```
242
+ ### 4. Skills
243
+ - **ALWAYS** check for applicable skills before implementing
244
+ - **ALWAYS** invoke proactively for: TypeScript, CLI, Frontend, Security, Performance
245
+ - **NEVER** implement without consulting relevant skill/droid
816
246
 
817
- ### Work Announcements
247
+ ---
818
248
 
819
- ```bash
820
- # Announce intent to work (enables overlap detection)
821
- uam agent announce --id <agent-id> \
822
- --resource "src/auth/" \
823
- --intent editing \
824
- --description "Refactoring JWT handling" \
825
- --files "src/auth/jwt.ts,src/auth/validate.ts" \
826
- --minutes 30
827
-
828
- # Check for overlaps before starting
829
- uam agent overlaps --resource "src/auth/"
830
-
831
- # Mark work complete (notifies others)
832
- uam agent complete --id <agent-id> --resource "src/auth/"
833
- ```
249
+ ## MEMORY SYSTEM
834
250
 
835
- ### Overlap Detection & Conflict Risk
251
+ ### Layer Selection
252
+ | Question | If YES → Layer |
253
+ |----------|---------------|
254
+ | Did this just happen (last few minutes)? | L1: Working Memory |
255
+ | Session-specific decision/context? | L2: Session Memory |
256
+ | Reusable learning for future sessions? | L3: Semantic Memory (importance 7+) |
257
+ | Relationship between entities? | L4: Knowledge Graph |
836
258
 
837
- ```bash
838
- $ uam agent overlaps --resource "src/components/Button.tsx"
839
-
840
- Overlapping Work Detected:
841
- ┌─────────────────────────────────────────────────────────────────┐
842
- Resource: src/components/Button.tsx │
843
- ├──────────────┬────────────┬────────────────────────────────────┤
844
- │ Agent │ Risk │ Suggestion │
845
- ├──────────────┼────────────┼────────────────────────────────────┤
846
- │ agent-ui-001 │ HIGH │ Coordinate: both editing same file │
847
- │ agent-test │ LOW │ Safe: only reading for tests │
848
- └──────────────┴────────────┴────────────────────────────────────┘
849
-
850
- Recommendations:
851
- 1. agent-ui-001 should merge first (started earlier)
852
- 2. Wait for agent-ui-001 to complete before pushing
853
- ```
854
-
855
- ### Inter-Agent Messaging
259
+ ### What to Store (Importance 7+)
260
+ - Bug fixes with root cause + solution
261
+ - Architecture decisions with rationale
262
+ - Performance optimizations that worked
263
+ - Gotchas and workarounds
264
+ - API behaviors that aren't obvious
856
265
 
266
+ ### Services
857
267
  ```bash
858
- # Broadcast to all agents
859
- uam agent broadcast --id <agent-id> \
860
- --channel coordination \
861
- --message '{"action":"merge_ready","branch":"feature/auth"}'
862
-
863
- # Send direct message
864
- uam agent send --id <agent-id> \
865
- --to <other-agent-id> \
866
- --message "Ready for code review"
867
-
868
- # Receive messages
869
- uam agent receive --id <agent-id>
268
+ {{MEMORY_START_CMD}} # Start Qdrant
269
+ {{MEMORY_STATUS_CMD}} # Check status
270
+ {{MEMORY_STOP_CMD}} # Stop services
271
+ uam memory migrate # Upgrade schema
870
272
  ```
871
273
 
872
- ### Deploy Batching
873
-
874
- ```bash
875
- # Queue a commit (don't push yet)
876
- uam deploy queue --agent-id <id> \
877
- --action-type commit \
878
- --message "feat: add auth" \
879
- --files "src/auth.ts,src/auth.test.ts"
880
-
881
- # Queue a push
882
- uam deploy queue --agent-id <id> \
883
- --action-type push \
884
- --target "feature/auth"
885
-
886
- # View queue
887
- uam deploy status
888
-
889
- # Batch and execute (squashes commits, single push)
890
- uam deploy flush
891
-
892
- # Or execute specific batch
893
- uam deploy batch
894
- uam deploy execute --batch-id <id>
895
- ```
896
-
897
- **Benefits:**
898
- - Reduces CI/CD runs (batch multiple commits)
899
- - Squashes related commits for cleaner history
900
- - Coordinates push order to prevent conflicts
901
- - Enables atomic multi-file deployments
902
-
903
274
  ---
904
275
 
905
- ## BROWSER USAGE
276
+ ## PROACTIVE DROIDS (Invoke before commit/PR)
906
277
 
907
- When using browser automation (Playwright, Puppeteer, or any browser tool):
908
-
909
- - ALWAYS save a screenshot after EVERY browser action (click, type, navigate, scroll, etc.)
910
- - Save screenshots to: `{{SCREENSHOTS_PATH}}/`
911
- - Filename format: `{timestamp}_{action}.png` (e.g., `1703180400_click_button.png`)
912
- - Also save a `.meta` file with the same name containing:
913
- ```
914
- url: {current_url}
915
- title: {page_title}
916
- action: {what_you_did}
917
- ```
918
- - Take a screenshot BEFORE and AFTER any significant visual change
278
+ | Droid | Trigger | Purpose |
279
+ |-------|---------|---------|
280
+ | `code-quality-guardian` | All code changes | Complexity, naming, SOLID |
281
+ | `security-auditor` | All code changes | OWASP, secrets, injection |
282
+ | `performance-optimizer` | Performance-critical | Algorithms, memory, caching |
283
+ | `documentation-expert` | New features/APIs | JSDoc, README, accuracy |
919
284
 
920
285
  ---
921
286
 
922
- ## DECISION LOOP
287
+ ## BROWSER AUTOMATION
923
288
 
924
- 1. **READ** short-term memory (recent context)
925
- 2. **QUERY** long-term memory (semantic search for relevant past learnings)
926
- 3. **THINK** about what to do next
927
- 4. **ACT** - execute your decision
928
- 5. **RECORD** - write to short-term memory
929
- 6. **IF BROWSER ACTION**: Save screenshot to `{{SCREENSHOTS_PATH}}/`
930
- 7. **OPTIONALLY** - if significant learning, add to long-term memory
931
-
932
- ---
933
-
934
- ## SKILLS
935
-
936
- You have access to reusable skills. Before attempting complex tasks:
937
-
938
- 1. Check if a skill exists for it (see `{{SKILLS_PATH}}`)
939
- 2. Follow the skill's patterns - they're tested and reliable
940
- 3. If you discover a better approach, consider creating/updating a skill
941
-
942
- Available skills are auto-discovered. When you see a SKILL.md, follow its instructions.
943
-
944
- ---
945
-
946
- ## MANDATORY WORKFLOW REQUIREMENTS
947
-
948
- 1. **Git Worktrees**: ALL code changes MUST use isolated git worktrees (`{{BRANCH_PREFIX}}NNN-slug` branches)
949
- 2. **PR-Based Merges**: NO direct commits to `{{DEFAULT_BRANCH}}`. All changes via PR with automated review
950
- 3. **CI/CD Pipelines**: ALWAYS use CI/CD pipelines to deploy. Create ephemeral pipelines when needed
951
- 4. **Automated Review**: PRs require signoff from reviewer agents before merge
952
-
953
- {{#if WORKFLOW_DOCS_PATH}}
954
- See [Git Worktree Workflow]({{WORKFLOW_DOCS_PATH}}) for complete details.
955
- {{/if}}
289
+ After EVERY browser action:
290
+ 1. Screenshot `{{SCREENSHOTS_PATH}}/{timestamp}_{action}.png`
291
+ 2. Meta file `{{SCREENSHOTS_PATH}}/{timestamp}_{action}.meta`
956
292
 
957
293
  ---
958
294
 
295
+ {{#if REPOSITORY_STRUCTURE}}
959
296
  ## Repository Structure ({{STRUCTURE_DATE}})
960
297
 
961
298
  ```
962
299
  {{PROJECT_NAME}}/
963
300
  {{{REPOSITORY_STRUCTURE}}}
964
301
  ```
965
-
966
- ---
967
-
968
- ## Quick Reference
969
-
970
- {{#if CLUSTER_CONTEXTS}}
971
- ### Cluster Contexts
972
-
973
- ```bash
974
- {{{CLUSTER_CONTEXTS}}}
975
- ```
976
- {{/if}}
977
-
978
- {{#if PROJECT_URLS}}
979
- ### URLs
980
-
981
- {{{PROJECT_URLS}}}
982
- {{/if}}
983
-
984
- {{#if KEY_WORKFLOWS}}
985
- ### Key Workflow Files
986
-
987
- ```
988
- {{{KEY_WORKFLOWS}}}
989
- ```
990
302
  {{/if}}
991
303
 
992
- ### Essential Commands
993
-
994
- ```bash
995
- # Create worktree for new task (MANDATORY for all changes)
996
- {{WORKTREE_CREATE_CMD}} <slug>
997
-
998
- # Create PR with automated review
999
- {{WORKTREE_PR_CMD}} <id>
1000
-
1001
- {{{ESSENTIAL_COMMANDS}}}
1002
- ```
1003
-
1004
- ---
1005
-
1006
304
  {{#if ARCHITECTURE_OVERVIEW}}
1007
- ## Architecture Overview
305
+ ## Architecture
1008
306
 
1009
307
  {{{ARCHITECTURE_OVERVIEW}}}
308
+ {{/if}}
1010
309
 
1011
310
  {{#if DATABASE_ARCHITECTURE}}
1012
- ### Database Architecture
311
+ ### Database
1013
312
 
1014
313
  {{{DATABASE_ARCHITECTURE}}}
1015
314
  {{/if}}
1016
315
 
1017
- ---
1018
- {{/if}}
1019
-
1020
316
  {{#if CORE_COMPONENTS}}
1021
317
  ## Core Components
1022
318
 
1023
319
  {{{CORE_COMPONENTS}}}
1024
-
1025
- ---
1026
320
  {{/if}}
1027
321
 
1028
- {{#if AUTH_FLOW}}
1029
- ## Authentication Flow
1030
-
1031
- {{{AUTH_FLOW}}}
322
+ {{#if CLUSTER_CONTEXTS}}
323
+ ## Cluster Contexts
1032
324
 
1033
- ---
325
+ ```bash
326
+ {{{CLUSTER_CONTEXTS}}}
327
+ ```
1034
328
  {{/if}}
1035
329
 
1036
- ## Required Workflow (MANDATORY)
330
+ {{#if PROJECT_URLS}}
331
+ ## URLs
1037
332
 
1038
- ### Git Worktree Workflow (ALL Changes)
333
+ {{{PROJECT_URLS}}}
334
+ {{/if}}
1039
335
 
1040
- **Every code change MUST follow this workflow:**
336
+ {{#if KEY_WORKFLOWS}}
337
+ ## CI/CD Workflows
1041
338
 
1042
339
  ```
1043
- 1. CREATE WORKTREE
1044
- {{WORKTREE_CREATE_CMD}} <slug>
1045
- → Creates {{BRANCH_PREFIX}}NNN-slug branch in {{WORKTREE_DIR}}/NNN-slug/
1046
-
1047
- 2. DEVELOP
1048
- cd {{WORKTREE_DIR}}/NNN-slug/
1049
- → Make changes, commit locally
1050
-
1051
- 3. CREATE PR (runs tests + triggers reviewers)
1052
- {{WORKTREE_PR_CMD}} <id>
1053
- → Runs all offline tests (blocks if fail)
1054
- → Pushes to origin
1055
- → Creates PR with auto-generated description
1056
- → Triggers reviewer agents
1057
-
1058
- 4. AUTOMATED REVIEW
1059
- → Reviewer agents run in parallel (quality, security, performance, tests)
1060
- → PR labeled: reviewer-approved OR needs-work
1061
- → Auto-merge on approval
1062
-
1063
- 5. CLEANUP
1064
- {{WORKTREE_CLEANUP_CMD}} <id>
1065
- → Removes worktree and deletes branch
340
+ {{{KEY_WORKFLOWS}}}
1066
341
  ```
342
+ {{/if}}
1067
343
 
1068
- {{#if HOOKS_INSTALL_CMD}}
1069
- **Install hooks** (one-time setup):
344
+ {{#if ESSENTIAL_COMMANDS}}
345
+ ## Project Commands
1070
346
 
1071
347
  ```bash
1072
- {{HOOKS_INSTALL_CMD}}
348
+ {{{ESSENTIAL_COMMANDS}}}
1073
349
  ```
1074
350
  {{/if}}
1075
351
 
1076
- ### Before ANY Task
1077
-
1078
- 1. Read relevant docs in `{{DOCS_PATH}}/` and component folders
1079
- {{#if FIXES_PATH}}
1080
- 2. Check `{{FIXES_PATH}}` for known issues
1081
- {{/if}}
1082
- {{#if CLUSTER_IDENTIFY}}
1083
- 3. {{CLUSTER_IDENTIFY}}
1084
- {{/if}}
1085
- 4. **Create a worktree for your changes**
1086
-
1087
- ### For Code Changes
1088
-
1089
- 1. **Create worktree**: `{{WORKTREE_CREATE_CMD}} <slug>`
1090
- 2. Update/create tests
1091
- 3. Run `{{TEST_COMMAND}}`
1092
- 4. Run linting and type checking
1093
- 5. **Create PR**: `{{WORKTREE_PR_CMD}} <id>`
1094
-
1095
352
  {{#if INFRA_WORKFLOW}}
1096
- ### For Infrastructure Changes
353
+ ## Infrastructure Workflow
1097
354
 
1098
355
  {{{INFRA_WORKFLOW}}}
1099
356
  {{/if}}
1100
357
 
1101
- ### Before Completing
1102
-
1103
- 1. All tests pass (enforced by pre-push hook)
1104
- 2. PR created and reviewed by agents
1105
- {{#if CHANGELOG_PATH}}
1106
- 3. Create changelog in `{{CHANGELOG_PATH}}/YYYY-MM/YYYY-MM-DD_description.md`
1107
- {{/if}}
1108
- 4. Update relevant documentation
1109
-
1110
- ---
1111
-
1112
358
  {{#if TROUBLESHOOTING}}
1113
- ## Troubleshooting Quick Reference
359
+ ## Troubleshooting
1114
360
 
1115
361
  {{{TROUBLESHOOTING}}}
1116
-
1117
- ---
1118
362
  {{/if}}
1119
363
 
1120
364
  {{#if KEY_CONFIG_FILES}}
1121
- ## Key Configuration Files
365
+ ## Config Files
1122
366
 
1123
367
  | File | Purpose |
1124
- | ---- | ------- |
368
+ |------|---------|
1125
369
  {{{KEY_CONFIG_FILES}}}
1126
-
1127
- ---
1128
370
  {{/if}}
1129
371
 
1130
- ## Completion Checklist
1131
-
1132
- ```
1133
- [ ] Tests updated and passing
1134
- [ ] Linting/type checking passed
1135
- {{#if HAS_INFRA}}
1136
- [ ] Infrastructure plan verified (if infra changed)
1137
- {{/if}}
1138
- [ ] CI/CD workflows updated (if deployment changed)
1139
- {{#if CHANGELOG_PATH}}
1140
- [ ] Changelog created (for significant changes)
1141
- {{/if}}
1142
- [ ] Documentation updated
1143
- [ ] No secrets in code/commits
1144
- ```
1145
-
1146
- ---
1147
-
1148
- {{#if CHANGELOG_PATH}}
1149
- ## Changelog Quick Reference
1150
-
1151
- **When to create**: New features, breaking changes, security updates, infrastructure changes, API modifications, database schema changes.
1152
-
1153
- **Location**: `{{CHANGELOG_PATH}}/YYYY-MM/YYYY-MM-DD_description.md`
1154
- {{#if CHANGELOG_TEMPLATE}}
1155
- **Template**: `{{CHANGELOG_TEMPLATE}}`
1156
- {{/if}}
1157
-
1158
- **Required sections**: Metadata, Summary, Details, Technical Details, Migration Guide, Testing
1159
-
1160
- ---
1161
- {{/if}}
1162
-
1163
- ## Augmented Agent Capabilities
1164
-
1165
- ### Proactive Skills & Droids - INVOKE AUTOMATICALLY
1166
-
1167
- **These must be invoked WITHOUT being asked - they ensure quality, security, and performance:**
1168
-
1169
- | Trigger | Invoke | Purpose |
1170
- |---------|--------|---------|
1171
- | ANY TypeScript/JavaScript change | `typescript-node-expert` | Strict typing, async patterns, best practices |
1172
- | ANY CLI command work | `cli-design-expert` | UX, help systems, error messages |
1173
- | BEFORE any commit/PR | `code-quality-guardian` | Complexity, naming, code smells |
1174
- | BEFORE any commit/PR | `security-auditor` | OWASP, secrets, injection, auth |
1175
- | Performance-critical code | `performance-optimizer` | Algorithms, memory, caching |
1176
- | New features or changes | `documentation-expert` | JSDoc, README, API docs |
1177
-
1178
- ```bash
1179
- # Invoke proactively - don't wait to be asked
1180
- Skill(skill: "typescript-node-expert") # For TS/JS work
1181
- Skill(skill: "cli-design-expert") # For CLI work
1182
-
1183
- # Launch droids for review
1184
- Task(subagent_type: "code-quality-guardian", prompt: "Review changes in...")
1185
- Task(subagent_type: "security-auditor", prompt: "Audit for vulnerabilities...")
1186
- Task(subagent_type: "performance-optimizer", prompt: "Analyze performance...")
1187
- Task(subagent_type: "documentation-expert", prompt: "Review documentation...")
1188
- ```
1189
-
1190
- ### Skills (`{{SKILLS_PATH}}`)
1191
-
1192
- Invoke with `Skill` tool. Skills expand inline with detailed instructions.
1193
-
1194
- | Skill | Purpose | Use When |
1195
- | ----- | ------- | -------- |
1196
- | `typescript-node-expert` | Strict TS, async patterns, ESM, performance | **PROACTIVE** - All TypeScript work |
1197
- | `cli-design-expert` | CLI UX, help, errors, prompts, output | **PROACTIVE** - All CLI development |
1198
372
  {{#if DISCOVERED_SKILLS}}
373
+ ## Project Skills
374
+
1199
375
  {{{DISCOVERED_SKILLS}}}
1200
376
  {{/if}}
1201
- | `senior-frontend` | React/Next.js/TypeScript/Tailwind development | Building UI features, performance optimization, state management |
1202
- | `code-reviewer` | Automated code analysis, security scanning | Reviewing PRs, code quality checks, identifying issues |
1203
- | `webapp-testing` | Playwright-based web testing | Verifying frontend functionality, debugging UI, browser screenshots |
1204
-
1205
- ### Custom Droids (`{{DROIDS_PATH}}`)
1206
-
1207
- Launch via `Task` tool with `subagent_type`. Droids run autonomously.
1208
-
1209
- **Proactive Quality Droids (Run before EVERY commit/PR):**
1210
- | Droid | Focus | When to Invoke |
1211
- |-------|-------|----------------|
1212
- | `code-quality-guardian` | Complexity, naming, SOLID, code smells | **PROACTIVE** - All code changes |
1213
- | `security-auditor` | OWASP, secrets, injection, auth | **PROACTIVE** - All code changes |
1214
- | `performance-optimizer` | Algorithms, memory, caching, I/O | **PROACTIVE** - Performance-critical code |
1215
- | `documentation-expert` | JSDoc, README, API docs, accuracy | **PROACTIVE** - New features/APIs |
1216
377
 
1217
378
  {{#if LANGUAGE_DROIDS}}
1218
- **Language Specialists (PROACTIVE):**
1219
- | Droid | Purpose |
1220
- |-------|---------|
1221
- {{{LANGUAGE_DROIDS}}}
1222
- {{/if}}
1223
-
1224
- **Code Review Pipeline:**
1225
- | Droid | Focus |
1226
- |-------|-------|
1227
- | `git-summarizer` | Gathers repo context (status, diffs, commit range) for downstream droids |
1228
- | `code-quality-reviewer` | Naming, complexity, duplication, error handling, style |
1229
- | `security-code-reviewer` | OWASP Top 10, secrets, authn/z, injection, risky configs |
1230
- | `performance-reviewer` | Algorithmic complexity, N+1 queries, caching, memory/IO |
1231
- | `test-coverage-reviewer` | Test gaps, brittle tests, coverage analysis |
1232
- | `documentation-accuracy-reviewer` | Verifies docs/README accuracy against implementation |
1233
- | `pr-readiness-reviewer` | Branch readiness: tests, docs, blockers, changelog |
1234
-
1235
- **Utilities:**
1236
- | Droid | Purpose |
1237
- |-------|---------|
1238
- | `release-notes-writer` | Structured release notes from commit history |
1239
- | `test-plan-writer` | Focused automated and manual test plans |
1240
- | `todo-fixme-scanner` | Scans repo for TODO/FIXME markers |
1241
- | `session-context-preservation-droid` | Maintains project knowledge across sessions |
1242
-
1243
- ### Commands (`{{COMMANDS_PATH}}`)
1244
-
1245
- High-level orchestration workflows:
1246
-
1247
- | Command | Purpose |
1248
- | ------- | ------- |
1249
- | `/worktree` | Manage git worktrees (create, list, pr, cleanup) - **USE FOR ALL CHANGES** |
1250
- | `/code-review` | Full code review (git-summarizer → quality/security/perf/test/docs reviewers) |
1251
- | `/pr-ready` | Validate branch, auto-create PR, trigger reviewer agents |
1252
- | `/release-notes` | Generate structured release notes from changes |
1253
- | `/test-plan` | Produce test plans for code changes |
1254
- | `/todo-scan` | Scan for TODO/FIXME markers |
1255
-
1256
- {{#if MCP_PLUGINS}}
1257
- ### MCP Plugins (`.mcp.json`)
1258
-
1259
- External tool integrations:
1260
-
1261
- | Plugin | Purpose |
1262
- | ------ | ------- |
1263
- {{{MCP_PLUGINS}}}
1264
- {{/if}}
1265
-
1266
- ### Usage Patterns
1267
-
1268
- **Code Review Workflow:**
1269
-
1270
- ```
1271
- 1. Invoke /code-review command
1272
- 2. git-summarizer gathers context
1273
- 3. Parallel delegation to quality/security/perf/test/docs droids
1274
- 4. Consolidated report with prioritized findings
1275
- ```
1276
-
1277
- **PR Preparation:**
1278
-
1279
- ```
1280
- 1. Run /pr-ready command
1281
- 2. Validates: tests, docs, changelog, TODO markers
1282
- 3. Returns blockers and required actions
1283
- ```
1284
-
1285
- {{#if LANGUAGE_EXAMPLES}}
1286
- **Language-Specific Refactoring:**
379
+ ## Language Specialists
1287
380
 
1288
- ```
1289
- {{{LANGUAGE_EXAMPLES}}}
1290
- ```
381
+ {{{LANGUAGE_DROIDS}}}
1291
382
  {{/if}}
1292
383
 
1293
- **Frontend Development:**
1294
-
1295
- ```
1296
- # Invoke skill for React/TypeScript work
1297
- Skill(skill: "senior-frontend")
1298
- # Then follow expanded instructions
1299
- ```
1300
-
1301
- ---
1302
-
1303
384
  {{#if PREPOPULATED_KNOWLEDGE}}
1304
- ## Project Knowledge (Auto-Populated)
1305
-
1306
- ### Recent Activity (Short-term Context)
385
+ ## Project Knowledge
1307
386
 
387
+ ### Recent Activity
1308
388
  {{{RECENT_ACTIVITY}}}
1309
389
 
1310
- ### Learned Lessons (Long-term Knowledge)
1311
-
390
+ ### Learned Lessons
1312
391
  {{{LEARNED_LESSONS}}}
1313
392
 
1314
393
  ### Known Gotchas
1315
-
1316
394
  {{{KNOWN_GOTCHAS}}}
1317
395
 
1318
- ### Hot Spots (Frequently Modified Files)
1319
-
396
+ ### Hot Spots
1320
397
  {{{HOT_SPOTS}}}
1321
-
1322
398
  {{/if}}
1323
399
 
400
+ ---
401
+
402
+ ## Completion Checklist
403
+
404
+ ```
405
+ [ ] Task created and released
406
+ [ ] Worktree used (not main repo)
407
+ [ ] PR created (not direct push)
408
+ [ ] Tests passing
409
+ [ ] Memory updated (short + long term)
410
+ [ ] Skills consulted
411
+ [ ] No secrets in code
412
+ ```
413
+
1324
414
  </coding_guidelines>