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