@zik000/archai 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,9 +4,7 @@
4
4
 
5
5
  Archai scaffolds a multi-agent system that plans before it codes, validates before it implements, and tests before it ships. One command sets it up. Claude Code does the rest.
6
6
 
7
- ```
8
- Plan → Implement → Finalize
9
- ```
7
+ ![Three-Phase Architecture](diagram.jpg)
10
8
 
11
9
  [Join our Discord](https://discord.gg/J3wgDb4YJv)
12
10
 
@@ -20,6 +18,8 @@ Without structure, AI assistants jump straight to code — skipping analysis, mi
20
18
  2. **Implementation Loop** — Code, test, review (only after you approve the plan)
21
19
  3. **Finalization** — Quality checks, cleanup, commit, push, CI verification
22
20
 
21
+ Agents **learn across sessions** through a persistent knowledge base — decisions, constraints, patterns, and gotchas are recorded and searched before every new task.
22
+
23
23
  You stay in control with approval gates between phases. Or use **critical review mode** to let a separate AI session review the plan automatically.
24
24
 
25
25
  ## Quick Start
@@ -62,21 +62,30 @@ archai generate # Generate project-specific specialist agents
62
62
 
63
63
  ## How to Use
64
64
 
65
- ### The Main Workflow
65
+ ### Step 1: Define Your Task
66
66
 
67
- For any non-trivial task, use `iteration-controller`. It orchestrates the entire three-phase workflow:
67
+ Write a clear description of what you want done. Drop it into a task file:
68
68
 
69
69
  ```
70
- > Use iteration-controller for: [describe your task]
70
+ .tasks/inbox/add-user-auth.md
71
71
  ```
72
72
 
73
- **What happens:**
74
- 1. `deep-analyst` analyzes your codebase and creates an implementation plan
75
- 2. `plan-validator` challenges the plan and finds gaps
76
- 3. `tdd-designer` designs tests before any code is written
77
- 4. **You review and approve the plan** (or request revisions)
78
- 5. `implementation-agent` builds it, `code-reviewer` verifies it
79
- 6. `finalization-agent` runs quality checks, commits, and pushes
73
+ Or just describe it directly in Claude Code. The more specific you are, the better the agents perform.
74
+
75
+ ### Step 2: Feed It to the Agent System
76
+
77
+ Open Claude Code and hand the task to `iteration-controller`:
78
+
79
+ ```
80
+ > Use iteration-controller for: add user authentication with JWT
81
+ ```
82
+
83
+ That's it. The agent system takes over:
84
+
85
+ 1. **Planning** — `deep-analyst` studies your codebase, `plan-validator` challenges the plan, `tdd-designer` writes tests first. This iterates 2-4 times until the plan is solid.
86
+ 2. **Your approval** — The workflow stops and presents the plan. You APPROVE, REVISE, or REJECT.
87
+ 3. **Implementation** — `implementation-agent` builds it, `code-reviewer` verifies it. Iterates until tests pass.
88
+ 4. **Finalization** — `finalization-agent` runs quality checks, cleans up, commits, and pushes.
80
89
 
81
90
  ### Critical Review Mode
82
91
 
@@ -103,15 +112,15 @@ For small, obvious changes (typos, renames, config tweaks, 1-3 files):
103
112
 
104
113
  No planning docs, no approval gates. If the change turns out to be bigger than expected, it tells you to use `iteration-controller` instead.
105
114
 
106
- ### Task Management
115
+ ### Batch Tasks
107
116
 
108
- For managing multiple tasks across an epic:
117
+ For managing multiple tasks across an epic, drop them all into `.tasks/inbox/` and run:
109
118
 
110
119
  ```
111
120
  > Use task-orchestrator for: work through the tasks in .tasks/inbox/
112
121
  ```
113
122
 
114
- It claims tasks, creates branches, spawns the workflow, and tracks progress.
123
+ It claims tasks one by one, creates branches, spawns the full workflow for each, and tracks progress.
115
124
 
116
125
  ### Standalone Agents
117
126
 
@@ -186,7 +195,7 @@ your-project/
186
195
  │ ├── plans/ # Approved implementation plans
187
196
  │ ├── state/ # Working state (gitignored)
188
197
  │ └── version.json # Version tracking for smart updates
189
- ├── .knowledge/ # Project context, decisions, learnings
198
+ ├── .knowledge/ # Persistent knowledge base (decisions, constraints, patterns, learnings)
190
199
  ├── .tasks/ # Task inbox, epics, review, done
191
200
  ├── archai.config.md # Project configuration
192
201
  ├── CLAUDE.md # Agentic behavior guidelines (auto-generated)
@@ -15,8 +15,8 @@ const FOLDERS = [
15
15
  '.knowledge/context',
16
16
  '.knowledge/decisions',
17
17
  '.knowledge/learnings',
18
- '.knowledge/planning',
19
- '.knowledge/status',
18
+ '.knowledge/constraints',
19
+ '.knowledge/patterns',
20
20
  // Task management
21
21
  '.tasks/inbox',
22
22
  '.tasks/done',
@@ -1 +1 @@
1
- {"version":3,"file":"create-structure.js","sourceRoot":"","sources":["../../src/scaffold/create-structure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,OAAO,GAAG;IACd,sBAAsB;IACtB,gBAAgB;IAChB,eAAe;IACf,wBAAwB;IACxB,eAAe;IACf,wBAAwB;IACxB,mBAAmB;IAEnB,iBAAiB;IACjB,oBAAoB;IACpB,sBAAsB;IACtB,sBAAsB;IACtB,qBAAqB;IACrB,mBAAmB;IAEnB,kBAAkB;IAClB,cAAc;IACd,aAAa;IACb,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,kBAAkB;IAElB,4BAA4B;IAC5B,aAAa;IAEb,sBAAsB;IACtB,eAAe;IACf,iBAAiB;IACjB,kBAAkB;CACnB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,qBAAqB;IACrB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;QAC7B,MAAM,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAC3B,yCAAyC;QACzC,MAAM,EAAE,CAAC,SAAS,CAAC,GAAG,MAAM,WAAW,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IAED,0BAA0B;IAC1B,MAAM,EAAE,CAAC,SAAS,CAAC,4BAA4B,EAAE,2CAA2C,CAAC,CAAC;IAC9F,MAAM,EAAE,CAAC,SAAS,CAAC,4BAA4B,EAAE,0CAA0C,CA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,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;CAa5B,CAAC;IAEA,MAAM,aAAa,GAAG,YAAY,CAAC;IACnC,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QACvC,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpD,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,6BAA6B;YAC7B,OAAO;QACT,CAAC;IACH,CAAC;IAED,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,GAAG,kBAAkB,CAAC,CAAC;AAClE,CAAC"}
1
+ {"version":3,"file":"create-structure.js","sourceRoot":"","sources":["../../src/scaffold/create-structure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;AAE3C,MAAM,OAAO,GAAG;IACd,sBAAsB;IACtB,gBAAgB;IAChB,eAAe;IACf,wBAAwB;IACxB,eAAe;IACf,wBAAwB;IACxB,mBAAmB;IAEnB,iBAAiB;IACjB,oBAAoB;IACpB,sBAAsB;IACtB,sBAAsB;IACtB,wBAAwB;IACxB,qBAAqB;IAErB,kBAAkB;IAClB,cAAc;IACd,aAAa;IACb,cAAc;IACd,eAAe;IACf,gBAAgB;IAChB,kBAAkB;IAElB,4BAA4B;IAC5B,aAAa;IAEb,sBAAsB;IACtB,eAAe;IACf,iBAAiB;IACjB,kBAAkB;CACnB,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,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,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;AACH,CAAC;AAED,KAAK,UAAU,mBAAmB;IAChC,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BtB,CAAC;IAEA,MAAM,eAAe,GAAG;;;;;;;;;;;;;;CAczB,CAAC;IAEA,MAAM,EAAE,CAAC,SAAS,CAAC,mCAAmC,EAAE,YAAY,CAAC,CAAC;IACtE,MAAM,EAAE,CAAC,SAAS,CAAC,sCAAsC,EAAE,eAAe,CAAC,CAAC;AAC9E,CAAC;AAED,KAAK,UAAU,eAAe;IAC5B,MAAM,kBAAkB,GAAG;;;;;;;;;;;;;CAa5B,CAAC;IAEA,MAAM,aAAa,GAAG,YAAY,CAAC;IACnC,IAAI,OAAO,GAAG,EAAE,CAAC;IAEjB,IAAI,MAAM,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QACvC,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACpD,IAAI,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;YACjC,6BAA6B;YAC7B,OAAO;QACT,CAAC;IACH,CAAC;IAED,MAAM,EAAE,CAAC,SAAS,CAAC,aAAa,EAAE,OAAO,GAAG,kBAAkB,CAAC,CAAC;AAClE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zik000/archai",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Multi-agent AI development workflow setup for any project",
5
5
  "keywords": [
6
6
  "claude",
@@ -84,6 +84,38 @@ Write to `.claude/state/code_review.md`:
84
84
  [APPROVED for merge / NEEDS CHANGES before merge / REJECTED - reason]
85
85
  ```
86
86
 
87
+ ## Knowledge Base — Write
88
+
89
+ After completing your review, perform the following knowledge capture steps:
90
+
91
+ 1. **Read signals**: Check `.claude/state/knowledge_signals.md` for signals accumulated during the implementation phase.
92
+
93
+ 2. **Review your own findings**: Identify patterns established, gotchas discovered, things that failed before working, conventions set during implementation, and workarounds for non-obvious issues.
94
+
95
+ 3. **Search before write**: For each knowledge-worthy item, search `.knowledge/` for existing entries on the same topic using Grep with relevant keywords. If overlap exists with the same conclusion, skip. If overlap exists with a different conclusion, supersede the old entry (set its Status to `superseded`, add `## Superseded By` with the new filename). If no overlap, create a new entry.
96
+
97
+ 4. **Write entries**: Create entries in the appropriate category (`decisions/`, `constraints/`, `patterns/`, `learnings/`) using this format:
98
+
99
+ ```markdown
100
+ # [Clear, Descriptive Title]
101
+
102
+ **Status**: active
103
+ **Date**: YYYY-MM-DD
104
+ **Tags**: keyword1, keyword2, keyword3
105
+
106
+ ## What
107
+ [The decision, constraint, pattern, or learning. 1-3 clear sentences.]
108
+
109
+ ## Why
110
+ [The reasoning. What problem does this solve? 1-3 sentences.]
111
+ ```
112
+
113
+ Filename format: `{YYYYMMDD}-{HHMMSS}-{slug}.md`. Focus on what a future agent would need to know to avoid the same mistakes or follow the same patterns.
114
+
115
+ 5. **Clear signals**: After processing, clear the processed signals from `.claude/state/knowledge_signals.md`.
116
+
117
+ 6. **Check CLAUDE.md**: If any entry supersedes an older one, check if `CLAUDE.md` or `archai.config.md` references the superseded decision. If so, flag it for update.
118
+
87
119
  ## Remember
88
120
 
89
121
  Be thorough but fair. Every issue must be specific and actionable — include file, line, and suggested fix.
@@ -20,6 +20,39 @@ Read project context from:
20
20
  - `.knowledge/context/project-description.md` - Project overview and architecture
21
21
  - `archai.config.md` - Tech stack, key files, and commands
22
22
 
23
+ ## Knowledge Base
24
+
25
+ **Read**: Before making decisions, search `.knowledge/` for relevant prior decisions, constraints, patterns, and learnings. Use Grep with 2-3 keywords from the current task. Read full entries for anything relevant. Surface relevant entries in your output. If you find conflicts between your proposed approach and existing knowledge, flag them explicitly — do not silently override prior decisions.
26
+
27
+ **Signal**: During your work, if you make or discover a significant decision, constraint, or clarification — append a brief signal to `.claude/state/knowledge_signals.md` using this format:
28
+
29
+ ```markdown
30
+ ## Signal: [brief description]
31
+ **Type**: decision | constraint | pattern | learning
32
+ **Detail**: [1-2 sentences about what was decided/discovered and why]
33
+ **Source**: deep-analyst, Phase 1
34
+ ```
35
+
36
+ **Write (final planning iteration only)**: At the end of the planning phase, convert accumulated signals into formal knowledge entries. For each: search `.knowledge/` for existing entries on the same topic (search-before-write). If overlap exists with the same conclusion, skip. If overlap exists with a different conclusion, supersede the old entry. If no overlap, create a new entry in the appropriate category (`decisions/`, `constraints/`, `patterns/`, `learnings/`) using this format:
37
+
38
+ ```markdown
39
+ # [Clear, Descriptive Title]
40
+
41
+ **Status**: active
42
+ **Date**: YYYY-MM-DD
43
+ **Tags**: keyword1, keyword2, keyword3
44
+
45
+ ## What
46
+ [The decision, constraint, pattern, or learning. 1-3 clear sentences.]
47
+
48
+ ## Why
49
+ [The reasoning. What problem does this solve? What would go wrong without it? 1-3 sentences.]
50
+ ```
51
+
52
+ Filename format: `{YYYYMMDD}-{HHMMSS}-{slug}.md`. Entries must be human-readable — write for a developer browsing the repo, not just for agents.
53
+
54
+ **Conflict Resolution**: If you find two knowledge entries that contradict each other, determine which is authoritative (newer, more specific, or whose `Affects` files are less modified). If unclear, escalate to the user — do not guess. Present both entries and ask which to follow.
55
+
23
56
  ## Analysis Protocol
24
57
 
25
58
  ### Phase 1: Dependency Mapping (MANDATORY)
@@ -147,6 +180,8 @@ Immediately flag these situations:
147
180
  - Framework-specific behavior concerns
148
181
  - Performance concerns
149
182
  - Security implications
183
+ - **Knowledge conflicts** — two entries contradict and source of truth is unclear
184
+ - **Existing entry blocks approach** — prior decision prevents the proposed approach
150
185
 
151
186
  ## Remember
152
187
 
@@ -18,7 +18,28 @@ Read `.claude/state/task_anchor.md` and verify:
18
18
  - [ ] All constraints are respected
19
19
  - [ ] Success definition is achieved
20
20
 
21
- ### Step 2: Quality Checks
21
+ ### Step 2: Knowledge Base — Verify
22
+
23
+ Before committing, verify that any `.knowledge/` entries created during this task have valid format:
24
+
25
+ 1. **Format check**: Each entry must contain these required sections:
26
+ - `# [Title]` (H1 heading)
27
+ - `**Status**: active | superseded`
28
+ - `**Date**: YYYY-MM-DD`
29
+ - `**Tags**: keyword1, keyword2`
30
+ - `## What` section
31
+ - `## Why` section
32
+
33
+ 2. **Filename check**: Entry filenames must follow `{YYYYMMDD}-{HHMMSS}-{slug}.md` format.
34
+
35
+ 3. **Supersession check**: If any entry has `**Status**: superseded`, verify it has a `## Superseded By` section with the replacement entry filename.
36
+
37
+ 4. **CLAUDE.md sync check**: If any entry supersedes an older one, check if `CLAUDE.md` or `archai.config.md` references the superseded decision. If so, flag it for the user:
38
+ > "Note: CLAUDE.md references [old pattern]. Knowledge entry [new entry] supersedes this. CLAUDE.md may need updating."
39
+
40
+ 5. **Commit knowledge**: Include all `.knowledge/` entries in the commit alongside code changes.
41
+
42
+ ### Step 3: Quality Checks
22
43
 
23
44
  Run commands from `archai.config.md`:
24
45
 
@@ -30,13 +51,13 @@ Run commands from `archai.config.md`:
30
51
 
31
52
  All must pass before proceeding. If they fail, fix issues and re-run.
32
53
 
33
- ### Step 3: Cleanup
54
+ ### Step 4: Cleanup
34
55
 
35
56
  - Archive task state to `.claude/state/archived/{task-id}/`
36
57
  - Remove temporary files from `.agents/`
37
58
  - Ensure `.gitkeep` files remain
38
59
 
39
- ### Step 4: Commit
60
+ ### Step 5: Commit
40
61
 
41
62
  ```bash
42
63
  git add [specific files from the task]
@@ -53,7 +74,7 @@ EOF
53
74
 
54
75
  Types: `feat:`, `fix:`, `refactor:`, `test:`, `docs:`, `chore:`
55
76
 
56
- ### Step 5: Push
77
+ ### Step 6: Push
57
78
 
58
79
  ```bash
59
80
  git push origin [branch-name]
@@ -61,14 +82,14 @@ git push origin [branch-name]
61
82
 
62
83
  If push fails: `git pull --rebase origin [branch-name]`, resolve conflicts, push again.
63
84
 
64
- ### Step 6: Wait for CI/CD
85
+ ### Step 7: Wait for CI/CD
65
86
 
66
87
  ```bash
67
88
  gh run list --branch [branch-name] --limit 1
68
89
  gh run watch [run-id]
69
90
  ```
70
91
 
71
- If CI fails: report which checks failed, wait for user instruction, then repeat steps 4-6 after fix.
92
+ If CI fails: report which checks failed, wait for user instruction, then repeat steps 5-7 after fix.
72
93
 
73
94
  ## Output Format
74
95
 
@@ -79,6 +100,12 @@ If CI fails: report which checks failed, wait for user instruction, then repeat
79
100
  - Acceptance criteria: [X/Y] met
80
101
  - Constraints respected: YES/NO
81
102
 
103
+ ## Knowledge Base Verification
104
+ - Entries created: [count]
105
+ - Format valid: YES/NO
106
+ - Supersessions flagged: [count]
107
+ - CLAUDE.md sync issues: [count or NONE]
108
+
82
109
  ## Quality Checks
83
110
  - Type check: PASS/FAIL
84
111
  - Lint: PASS/FAIL
@@ -20,6 +20,19 @@ You are an autonomous implementation agent. Execute the approved plan WITHOUT st
20
20
  - 5 consecutive fix attempts fail on one step → REPORT BLOCKED
21
21
  - Plan has ambiguity that completely blocks progress → REPORT ISSUE
22
22
 
23
+ ## Knowledge Signals
24
+
25
+ During implementation, if you discover a gotcha, establish a pattern, hit a non-obvious failure, or make a workaround — append a brief signal to `.claude/state/knowledge_signals.md` using this format:
26
+
27
+ ```markdown
28
+ ## Signal: [brief description]
29
+ **Type**: decision | constraint | pattern | learning
30
+ **Detail**: [1-2 sentences about what was discovered and why]
31
+ **Source**: implementation-agent, Phase 2
32
+ ```
33
+
34
+ Do NOT stop to write full knowledge entries — focus on implementation. Signals will be converted to entries by code-reviewer at the end of Phase 2.
35
+
23
36
  ## Implementation Protocol
24
37
 
25
38
  ### Step 1: Parse the Plan
@@ -103,6 +103,29 @@ Each agent receives ONLY what it needs:
103
103
 
104
104
  **Write final plan to:** `.claude/plans/{task-name}.md`
105
105
 
106
+ ### Step 1.5: Knowledge Write Point 1 (End of Planning)
107
+
108
+ **MANDATORY** after the planning loop exits and the plan is written.
109
+
110
+ This captures decisions and constraints while planning context is fresh. The writing agent is deep-analyst (on its final iteration) or the orchestrator directly.
111
+
112
+ **Process:**
113
+ 1. Read `.claude/state/knowledge_signals.md` for signals accumulated during planning
114
+ 2. For each signal of type `decision` or `constraint`:
115
+ a. Search `.knowledge/` for existing entries on the same topic (search-before-write)
116
+ b. If same topic + same conclusion: SKIP (do not duplicate)
117
+ c. If same topic + different conclusion: SUPERSEDE the old entry
118
+ d. If no overlap: CREATE new entry in `.knowledge/decisions/` or `.knowledge/constraints/`
119
+ 3. Write entries using the standard format (Title, Status, Date, Tags, What, Why)
120
+ 4. Filename format: `{YYYYMMDD}-{HHMMSS}-{slug}.md`
121
+ 5. Clear processed planning signals from `.claude/state/knowledge_signals.md` (leave any implementation-phase signals)
122
+
123
+ **What to capture at this point:**
124
+ - Architectural decisions made ("we chose X over Y because Z")
125
+ - Constraints discovered during codebase analysis
126
+ - Business rules clarified by user Q&A
127
+ - Source-of-truth identifications
128
+
106
129
  ---
107
130
 
108
131
  ## Phase 1.5: Critical Review (only if REVIEW_MODE=critical, max 2 iterations)
@@ -140,6 +163,31 @@ Each agent receives ONLY what it needs:
140
163
 
141
164
  If code review finds issues → fix and re-verify. Max 5 attempts per step.
142
165
 
166
+ ### Step 2.5: Knowledge Write Point 2 (End of Implementation)
167
+
168
+ **MANDATORY** after code review completes and tests pass.
169
+
170
+ This captures patterns and learnings while implementation context is fresh. The writing agent is `code-reviewer` (it has this directive in its prompt).
171
+
172
+ **Process:**
173
+ 1. Read remaining signals from `.claude/state/knowledge_signals.md`
174
+ 2. `code-reviewer` also reviews its own findings -- patterns established, gotchas discovered, things that failed before working
175
+ 3. For each knowledge-worthy item:
176
+ a. Search `.knowledge/` for existing entries (search-before-write)
177
+ b. If same topic + same conclusion: SKIP
178
+ c. If same topic + different conclusion: SUPERSEDE the old entry
179
+ d. If no overlap: CREATE new entry in `.knowledge/patterns/` or `.knowledge/learnings/`
180
+ 4. Write entries using the standard format (Title, Status, Date, Tags, What, Why)
181
+ 5. Clear the signals file
182
+ 6. Check if any superseded entries are referenced in CLAUDE.md -- flag for update if so
183
+
184
+ **What to capture at this point:**
185
+ - Patterns established through implementation
186
+ - Learnings from failures
187
+ - Gotchas discovered
188
+ - Conventions set during implementation
189
+ - Workarounds for non-obvious issues
190
+
143
191
  ### Final Approval Gate
144
192
 
145
193
  - **manual mode** → wait for user APPROVE before Phase 3
@@ -151,11 +199,12 @@ If code review finds issues → fix and re-verify. Max 5 attempts per step.
151
199
 
152
200
  Spawn `finalization-agent`:
153
201
  1. Verify acceptance criteria
154
- 2. Run quality checks (typecheck, lint, test from `archai.config.md`)
155
- 3. Cleanup temp files
156
- 4. Commit with proper message format
157
- 5. Push branch
158
- 6. Wait for CI/CD
202
+ 2. Verify knowledge Check that `.knowledge/` entries created during this task have valid format (Title, Status, Date, Tags, What, Why). Commit entries alongside code changes. Flag if any superseded entries affect CLAUDE.md.
203
+ 3. Run quality checks (typecheck, lint, test from `archai.config.md`)
204
+ 4. Cleanup temp files
205
+ 5. Commit with proper message format (include `.knowledge/` entries)
206
+ 6. Push branch
207
+ 7. Wait for CI/CD
159
208
 
160
209
  ---
161
210
 
@@ -171,6 +220,8 @@ Check `.claude/agents/` for available specialist agents. Use them when working i
171
220
  | Unclear requirements | Request human clarification |
172
221
  | Architectural decision needed | Request human decision |
173
222
  | Tests fail after 5 attempts | Report BLOCKED |
223
+ | Knowledge entries contradict and source of truth is unclear | Present both entries, ask user which to follow |
224
+ | Existing knowledge entry blocks proposed approach | Surface to user: "Prior decision X prevents approach Y. Should we revisit?" |
174
225
 
175
226
  ## Usage
176
227
 
@@ -13,6 +13,21 @@ You are an adversarial plan validator. Your job is to FIND PROBLEMS, not to appr
13
13
 
14
14
  You are the last line of defense before code is written. A plan that passes your validation should be implementable without surprises.
15
15
 
16
+ ## Knowledge Base
17
+
18
+ **Read**: Before validating, search `.knowledge/` for relevant prior decisions, constraints, patterns, and learnings. Use Grep with 2-3 keywords from the current task. Read full entries for anything relevant. Verify the plan honors existing decisions and constraints. If the plan contradicts an existing knowledge entry, flag it as a BLOCKER — prior decisions should not be silently overridden.
19
+
20
+ **Signal**: During validation, if you discover a constraint, clarification, or important observation — append a brief signal to `.claude/state/knowledge_signals.md` using this format:
21
+
22
+ ```markdown
23
+ ## Signal: [brief description]
24
+ **Type**: decision | constraint | pattern | learning
25
+ **Detail**: [1-2 sentences about what was discovered and why it matters]
26
+ **Source**: plan-validator, Phase 1
27
+ ```
28
+
29
+ **Conflict Resolution**: If you find two knowledge entries that contradict each other, determine which is authoritative (newer, more specific, or whose `Affects` files are less modified). If unclear, escalate to the user — do not guess. Present both entries and ask which to follow.
30
+
16
31
  ## Validation Checklist
17
32
 
18
33
  ### 1. Completeness Check
@@ -54,7 +69,14 @@ You are the last line of defense before code is written. A plan that passes your
54
69
  - [ ] Error paths have tests
55
70
  - [ ] No test uses `toBeDefined()` as sole assertion
56
71
 
57
- ### 5. Risk Assessment
72
+ ### 5. Knowledge Consistency Check
73
+
74
+ - [ ] Plan does not contradict active entries in `.knowledge/decisions/`
75
+ - [ ] Plan respects constraints documented in `.knowledge/constraints/`
76
+ - [ ] Plan follows established patterns from `.knowledge/patterns/`
77
+ - [ ] Any deviations from existing knowledge are explicitly justified
78
+
79
+ ### 6. Risk Assessment
58
80
 
59
81
  For each risk identified:
60
82
  - Likelihood: [LOW/MEDIUM/HIGH]
@@ -84,6 +106,9 @@ For each risk identified:
84
106
  ## Risks Not Addressed
85
107
  [List risks without mitigation]
86
108
 
109
+ ## Knowledge Consistency
110
+ [List any conflicts with existing knowledge entries]
111
+
87
112
  ## Required Changes
88
113
  [Numbered list of specific changes needed before approval]
89
114
  ```
@@ -95,6 +120,7 @@ For each risk identified:
95
120
  - Vague implementation steps
96
121
  - No error handling specified
97
122
  - Breaking change without migration
123
+ - Contradicts existing knowledge entry without justification
98
124
 
99
125
  **MAJOR** - Should fix before proceeding:
100
126
  - Missing edge case handling