@laitszkin/apollo-toolkit 5.0.1 → 5.0.3

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.
@@ -87,6 +87,7 @@ Cover the following sections:
87
87
  - **System Invariants**: Architectural constraints that must not be violated, plus violation symptoms
88
88
  - **Technical Trade-offs**: Each decision with rejected alternatives and lock-in effects
89
89
  - **Design-Time Refactoring**: T1–T3 code health findings classified and dispositioned
90
+ - **References**: List important project context files the LLM will need to understand this design (e.g., `CLAUDE.md`, `AGENTS.md`, architecture atlas files). This reduces the LLM's need to search for relevant files when processing the design document.
90
91
 
91
92
  Use `Req 1`, `Req 2` numbering to reference SPEC.md requirements (matching the SPEC.md template's `Requirement 1`, `Requirement 2`).
92
93
 
@@ -127,6 +128,7 @@ Cover the following sections:
127
128
  - **Hardening Requirements**: Regression tests, drift checks, property-based tests, edge cases, authorization checks
128
129
  - **E2E / Integration Decisions**: Per flow, choose the appropriate test level with rationale
129
130
  - **Design-Time Refactoring (T3)**: If T3 refactoring is planned, define its test coverage requirements here
131
+ - **References**: List important project context files the LLM will need (e.g., `CLAUDE.md`, `AGENTS.md`).
130
132
 
131
133
  **Mandatory test coverage** (applies when the SPEC.md describes changes other than pure documentation or pure test changes):
132
134
 
@@ -143,7 +145,15 @@ Risk definitions: **Medium risk** = paths involving I/O, external dependencies,
143
145
 
144
146
  Use the `apltk architecture` CLI tool to generate the Architecture Diff, following the C4 model hierarchy.
145
147
 
146
- #### 5a. Read the Existing Architecture
148
+ #### 5a. Survey the project with `apltk codegraph survey`
149
+
150
+ **Prerequisite** before any diff work. Survey the project code to establish a code-level baseline for comparison with the atlas.
151
+
152
+ Run `apltk codegraph survey --json` to get entry points, function clusters, and cross-boundary edges.
153
+
154
+ Consult `references/codegraph.md` for detailed flags.
155
+
156
+ #### 5b. Read the Existing Architecture
147
157
 
148
158
  Read the project's existing architecture files (`resources/project-architecture/atlas/atlas.index.yaml` + the affected feature YAML files).
149
159
  Do not read unrelated features or modules — maintain context economy.
@@ -156,13 +166,13 @@ If no existing architecture exists, skip the baseline comparison and start defin
156
166
  - T1 items (module-internal simplification) are safe to refactor immediately — existing tests validate behavioral preservation
157
167
  - T2 and T3 items feed into the target architecture design in Step 3
158
168
 
159
- #### 5b. Measure Baseline Drift
169
+ #### 5c. Measure Baseline Drift
160
170
 
161
171
  Compare the existing architecture diagram against the current code to assess its reliability:
162
172
  - If the baseline atlas differs significantly from the code (> 20% entries inconsistent), flag the risk in the architecture diff
163
173
  - If the baseline atlas is reliable, the diff can be layered directly on top of it
164
174
 
165
- #### 5c. Define the Diff by C4 Level
175
+ #### 5d. Define the Diff by C4 Level
166
176
 
167
177
  1. **System Context**: Define external actors, system boundaries, cross-system edges
168
178
  2. **Container level** (features): Define new or modified features and the edges between them
@@ -171,13 +181,13 @@ Compare the existing architecture diagram against the current code to assess its
171
181
 
172
182
  C4 level mapping: System Context → system boundary, Container → feature, Component → submodule, Code → function (selective). See `references/definition.md` for full definitions.
173
183
 
174
- #### 5d. Evidence Tracing
184
+ #### 5e. Evidence Tracing
175
185
 
176
186
  Each component should link to:
177
187
  - The requirement number from SPEC.md (requirement → module)
178
188
  - The technical decision from research findings (decision → dependency choice)
179
189
 
180
- #### 5e. Generate the Diff and Validate
190
+ #### 5f. Generate the Diff and Validate
181
191
 
182
192
  Two alternative workflows — use the **Classic flow** when `codegraph` is not installed, or the **CodeGraph-integrated flow** when it is available.
183
193
 
@@ -188,7 +198,7 @@ Generate and validate the architecture diff using `apltk architecture` commands.
188
198
 
189
199
  1. **Survey the existing API landscape** — Use `apltk codegraph list-apis` to review the full project API directory (function names, file paths, callers). Understand what existing modules and functions your new feature will interact with.
190
200
 
191
- 2. **Fill the proposal skeleton** — Based on your design decisions from steps 5a5d, fill in the `proposal.yaml` file generated by `apltk architecture template`. Define the feature, its submodules, their functions, and cross-feature edges.
201
+ 2. **Fill the proposal skeleton** — Based on your design decisions from steps 5b5e, fill in the `proposal.yaml` file generated by `apltk architecture template`. Define the feature, its submodules, their functions, and cross-feature edges.
192
202
 
193
203
  3. **Apply and verify** — Apply the mutations and verify correctness:
194
204
  - `apltk architecture apply` processes all mutations with undo protection
@@ -233,6 +243,7 @@ Before delivering, run two passes — completeness then quality.
233
243
  - `assets/templates/DESIGN.md` — DESIGN.md template
234
244
  - `assets/templates/CHECKLIST.md` — CHECKLIST.md template
235
245
  - `references/architecture.md` — `apltk architecture` CLI reference (all mutation commands)
246
+ - `references/codegraph.md` — `apltk codegraph` CLI reference (consult for subcommand flags)
236
247
  - `references/definition.md` — C4 model level definitions
237
248
  - `references/code-smells.md` — Common code smell patterns to spot during architecture survey
238
249
  - `references/module-internal-simplification.md` — T1: module-internal simplification patterns
@@ -37,3 +37,10 @@ Map each BDD requirement from SPEC.md to one or more tests:
37
37
  | Flow / Risk | Test Level | Rationale |
38
38
  |---|---|---|
39
39
  | [Flow description] | [E2E / Integration / Existing coverage / N/A] | [why] |
40
+
41
+ ---
42
+
43
+ ## References
44
+
45
+ - **Project context files**: [List important project files the LLM will need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`]
46
+ - **Related documents**: [Links to related SPEC.md, DESIGN.md, or external documentation]
@@ -151,3 +151,10 @@ Code health findings identified during architecture survey, classified by module
151
151
  | […] | […] | […] | […] | […] |
152
152
 
153
153
  If none, write **None**.
154
+
155
+ ---
156
+
157
+ ## 9. References
158
+
159
+ - **Project context files**: [List important project files the LLM will need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`]
160
+ - **Related documents**: [Links to related SPEC.md, other design docs, or external documentation]
@@ -0,0 +1,41 @@
1
+ # apltk codegraph — Code Intelligence CLI Reference
2
+
3
+ ## Purpose
4
+ Parse source code into a knowledge graph of symbols (functions, classes) and relationships (call edges), backed by a local SQLite database with FTS5 full-text search. Powered by @colbymchenry/codegraph (tree-sitter-backed code knowledge graph engine).
5
+
6
+ ## Usage
7
+ ```
8
+ apltk codegraph <subcommand> [options]
9
+ ```
10
+
11
+ ## Subcommands
12
+
13
+ ### Lifecycle
14
+
15
+ | Subcommand | Description | Key Flags |
16
+ |------------|-------------|-----------|
17
+ | `init` | Initialize CodeGraph for the project | `--index` (run initial indexing immediately), `--json` |
18
+ | `sync` | Sync index with current file state (incremental) | `--json` |
19
+ | `status` | Show index statistics (files, nodes, edges, languages) | `--json` |
20
+
21
+ ### Discovery
22
+
23
+ | Subcommand | Description | Key Flags |
24
+ |------------|-------------|-----------|
25
+ | `search <query>` | Search code graph for symbols via FTS5 | `--limit N` (default 20, max 100), `--json` |
26
+ | `explore <query>` | Deep-dive on a symbol — callers, callees, source | `--feature <name>`, `--json` |
27
+ | `survey [dir]` | Scan directory, suggest submodule groupings and edges | `--feature <name>`, `--json` |
28
+ | `list-apis [path]` | List public APIs in project or sub-path | `--all` (include internal symbols), `--json` |
29
+
30
+ ### Validation
31
+
32
+ | Subcommand | Description | Key Flags |
33
+ |------------|-------------|-----------|
34
+ | `verify --spec <dir>` | Verify a spec overlay against actual code | `--json` |
35
+
36
+ ## Common Workflows
37
+
38
+ - **Before atlas work**: `apltk codegraph init --index` (first time), then `apltk codegraph survey --json`
39
+ - **After code changes**: `apltk codegraph sync` to keep index current
40
+ - **Understanding a symbol**: `apltk codegraph explore <name>` to see callers and callees
41
+ - **Searching code**: `apltk codegraph search <query> --json --limit 30`
@@ -51,24 +51,20 @@ At load time, check the project state to select the correct mode:
51
51
 
52
52
  Applicable modes: design (full initialization), record (quick recording)
53
53
 
54
- ### 1. Survey the project with `apltk codegraph survey`
54
+ ### 1. Analyze the project with `apltk codegraph`
55
55
 
56
- Before diving into the code, establish a high-level understanding:
57
- - Which external actors interact with the system (users, third-party services, other systems)
58
- - What high-level capabilities the system provides
56
+ **Prerequisite** before any architecture work. The code graph provides the source-code evidence that powers the atlas.
59
57
 
60
- Then read `sample-demo/` to understand the expected output format and abstraction level.
58
+ 1. Initialize: `apltk codegraph init --index` (run once per project to build the symbol index).
59
+ 2. Survey: `apltk codegraph survey --json` for a structured report with file/function counts, entry points, and suggested submodule groupings.
61
60
 
62
- Next, run `apltk codegraph survey` to get a structured survey report:
63
- - List of all files in the project directory with function counts
64
- - Entry points (public functions called from external files)
65
- - Suggested submodule groupings and cross-boundary edges
66
- - Supports `--json` output for programmatic consumption by the LLM
67
-
68
- Based on the survey report, decide how to partition features (C4 Container level):
69
- - Group closely interconnected function clusters into the same feature's submodules
61
+ Based on the survey, partition features (C4 Container level):
62
+ - Group interconnected function clusters into the same feature's submodules
70
63
  - Identify feature boundaries and cross-feature call relationships
71
- - Record the directory path and entry points for each feature
64
+
65
+ Then read `sample-demo/` to understand the expected output format and abstraction level before writing the atlas.
66
+
67
+ Consult `references/codegraph.md` for detailed flags.
72
68
 
73
69
  ### 2. Write the atlas with `apltk architecture apply`
74
70
 
@@ -107,7 +103,8 @@ If time or context constraints prevent full traceability, record the scanned sco
107
103
 
108
104
  ## References
109
105
 
110
- - `references/architecture.md` — Full parameter reference for the apltk architecture tool (consult when CLI flag details are needed).
106
+ - `references/codegraph.md` — `apltk codegraph` CLI reference (consult for subcommand flags).
107
+ - `references/architecture.md` — Full parameter reference for the `apltk architecture` tool (consult when CLI flag details are needed).
111
108
  - `references/TEMPLATE_SPEC.md` — Atlas field reference, enum values, and CLI shape cheat sheet.
112
109
  - `references/definition.md` — Detailed definitions of feature and submodule.
113
110
  - `assets/architecture-page.template.html` — HTML template.
@@ -0,0 +1,41 @@
1
+ # apltk codegraph — Code Intelligence CLI Reference
2
+
3
+ ## Purpose
4
+ Parse source code into a knowledge graph of symbols (functions, classes) and relationships (call edges), backed by a local SQLite database with FTS5 full-text search. Powered by @colbymchenry/codegraph (tree-sitter-backed code knowledge graph engine).
5
+
6
+ ## Usage
7
+ ```
8
+ apltk codegraph <subcommand> [options]
9
+ ```
10
+
11
+ ## Subcommands
12
+
13
+ ### Lifecycle
14
+
15
+ | Subcommand | Description | Key Flags |
16
+ |------------|-------------|-----------|
17
+ | `init` | Initialize CodeGraph for the project | `--index` (run initial indexing immediately), `--json` |
18
+ | `sync` | Sync index with current file state (incremental) | `--json` |
19
+ | `status` | Show index statistics (files, nodes, edges, languages) | `--json` |
20
+
21
+ ### Discovery
22
+
23
+ | Subcommand | Description | Key Flags |
24
+ |------------|-------------|-----------|
25
+ | `search <query>` | Search code graph for symbols via FTS5 | `--limit N` (default 20, max 100), `--json` |
26
+ | `explore <query>` | Deep-dive on a symbol — callers, callees, source | `--feature <name>`, `--json` |
27
+ | `survey [dir]` | Scan directory, suggest submodule groupings and edges | `--feature <name>`, `--json` |
28
+ | `list-apis [path]` | List public APIs in project or sub-path | `--all` (include internal symbols), `--json` |
29
+
30
+ ### Validation
31
+
32
+ | Subcommand | Description | Key Flags |
33
+ |------------|-------------|-----------|
34
+ | `verify --spec <dir>` | Verify a spec overlay against actual code | `--json` |
35
+
36
+ ## Common Workflows
37
+
38
+ - **Before atlas work**: `apltk codegraph init --index` (first time), then `apltk codegraph survey --json`
39
+ - **After code changes**: `apltk codegraph sync` to keep index current
40
+ - **Understanding a symbol**: `apltk codegraph explore <name>` to see callers and callees
41
+ - **Searching code**: `apltk codegraph search <query> --json --limit 30`
@@ -41,6 +41,16 @@ description: 基於 repo 最新程式碼與文檔,更新 CLAUDE.md 和 AGENTS.
41
41
 
42
42
  > 兩份檔案皆應維持在 100 行以內。若超過此限制,優先精煉而非擴充。
43
43
 
44
+ #### 加入 `apltk codegraph` 相關命令
45
+
46
+ 在兩份文檔的 `Common Development Commands` 區塊中,加入:
47
+
48
+ - `apltk codegraph <subcommand> [options]` — CodeGraph code intelligence CLI(init/sync/status/search/explore/survey/list-apis/verify)。由 tree-sitter 驅動的代碼知識圖譜引擎。
49
+
50
+ #### 加入代碼調查要求
51
+
52
+ 在兩份文檔中,明確要求 agent 在開始實作前,應先通過 `apltk codegraph` 進行代碼調查(如 `apltk codegraph survey`、`apltk codegraph explore`),確保變更基於對現有代碼的真實理解。此規則可放在 `Common Development Commands` 區塊的開頭作為前置條件說明,或放在 Prohibitions 區塊附近作為開發慣例。
53
+
44
54
  ## 參考資料
45
55
 
46
56
  - `references/constraint-file-reference.md`:三區塊契約、撰寫規則、AGENTS.md vs CLAUDE.md 區分指引、核對清單與輸出模板。
@@ -37,6 +37,8 @@ CLAUDE.md 可在這三個區塊之後額外加入 Claude Code 特有設定區塊
37
37
  - 只收錄能被當前倉庫驗證的命令。
38
38
  - 優先從 `package.json`、`Makefile`、`bin/`、`scripts/`、CI 設定或其他真實入口提取。
39
39
  - 每條命令附上一句簡短用途說明,避免捏造不存在的工作流。
40
+ - 若專案已安裝 `apltk codegraph`,必須在 Commands 區塊中包含該 CLI 的完整子命令列表(init/sync/status/search/explore/survey/list-apis/verify)。
41
+ - 在 Commands 區塊開頭或附近加入前置條件:要求 agent 在開始實作前,先通過 `apltk codegraph survey`(或 `explore`)進行代碼調查,確保變更基於對現有代碼的真實理解。
40
42
 
41
43
  ### `Project Business Goals`
42
44
 
@@ -95,7 +95,7 @@ Each worker prompt must include:
95
95
  ```
96
96
  ## Mission — What to do and why
97
97
  ## Input — Which files to read
98
- ## What to do — Concrete steps (describe "what" to do, not "which tool" to use)
98
+ ## What to do — Concrete steps, each specifying the exact file path, the function or line range, and what specific change to make (add/delete/modify). Never leave the change description vague.
99
99
  ## Scope — Allowed and forbidden files
100
100
  ## Output — What to report on completion (file list, change summary, test results, risks)
101
101
  ## Verify — Verification commands and expected results
@@ -104,7 +104,7 @@ Each worker prompt must include:
104
104
 
105
105
  **Writing principles:**
106
106
  - **Self-contained**: Workers do not see the coordinator's context. The prompt must include everything necessary
107
- - **Concrete**: Embed file paths, function names, line numbers. Do not write "fix it" or "based on your findings"
107
+ - **Concrete**: For every file the worker must modify, specify: (1) the exact file path, (2) the function or line range, (3) what to add, delete, or change. Do not write "fix it", "update as needed", or "based on your findings"
108
108
  - **Declarative**: Describe "what to do", not "which tool to use"
109
109
  - **Clear boundaries**: Explicitly list allowed and forbidden files
110
110
 
@@ -146,12 +146,13 @@ Use `assets/templates/PROMPT.md`. Fill each section according to the table below
146
146
  | 2. Mission | SPEC.md Goal + business value |
147
147
  | 3. Scope & Boundaries | SPEC.md In/Out of Scope |
148
148
  | 4. Technical Context | DESIGN.md: module list with responsibilities, interaction anchors (INT-###) and dependency order, external dependency setup order (EXT-###), system invariants, technical decisions and trade-offs |
149
- | 5. Task Units | Step 3 (task decomposition) + Step 4 (dependency analysis) |
150
- | 6. Worker Prompt Library | Step 6 one entry per dispatchable task |
151
- | 7. Batch Schedule | Step 7 (batch schedule) |
152
- | 8. Verification Checkpoints | CHECKLIST.md: behavior-to-test mapping (CL-###), hardening requirements, test execution commands |
153
- | 9. Error Recovery | Fixed template populate spec-specific test commands from CHECKLIST.md |
154
- | 10. Boundaries | Fixed template + spec-specific rules |
149
+ | 5. References | Important project context files (CLAUDE.md, AGENTS.md, architecture atlas, codegraph index) reduces LLM search overhead |
150
+ | 6. Task Units | Step 3 (task decomposition) + Step 4 (dependency analysis) |
151
+ | 7. Worker Prompt Library | Step 6 one entry per dispatchable task |
152
+ | 8. Batch Schedule | Step 7 (batch schedule) |
153
+ | 9. Verification Checkpoints | CHECKLIST.md: behavior-to-test mapping (CL-###), hardening requirements, test execution commands |
154
+ | 10. Error Recovery | Fixed template populate spec-specific test commands from CHECKLIST.md |
155
+ | 11. Boundaries | Fixed template + spec-specific rules (including worktree cleanup after each batch) |
155
156
 
156
157
  ### 11. Pre-delivery Self-Review
157
158
 
@@ -159,21 +160,21 @@ Before delivering PROMPT.md, verify all of the following.
159
160
 
160
161
  **Worker prompt quality:**
161
162
 
162
- - Every worker prompt in Section 6 is self-contained. Scan for phrases like "based on your findings", "fix it appropriately", "as discussed above" — these leak shared context assumptions. If found, rewrite the prompt to include the necessary information inline.
163
+ - Every worker prompt in Section 7 is self-contained. Scan for phrases like "based on your findings", "fix it appropriately", "as discussed above" — these leak shared context assumptions. If found, rewrite the prompt to include the necessary information inline.
163
164
  - Every worker prompt has a concrete file-level Scope (allowed + forbidden files listed explicitly).
164
165
  - Every worker prompt has a concrete Verify command with an expected output (not just "run tests").
165
166
 
166
167
  **Coverage completeness:**
167
168
 
168
- - Every BDD requirement from SPEC.md is addressed by at least one task in Section 5. If a requirement has no task, add one or document why it is already satisfied by existing code.
169
+ - Every BDD requirement from SPEC.md is addressed by at least one task in Section 6. If a requirement has no task, add one or document why it is already satisfied by existing code.
169
170
  - Every module from DESIGN.md has a corresponding task or is explicitly noted as unchanged.
170
- - Every hardening requirement from CHECKLIST.md appears in Section 8.
171
+ - Every hardening requirement from CHECKLIST.md appears in Section 9.
171
172
 
172
173
  **Structural consistency:**
173
174
 
174
- - Each task's Depends on field in Section 5 matches the batch ordering in Section 7. No task scheduled in a batch before its dependencies are met.
175
- - Every task listed in Section 7 (Batch Schedule) has a worker prompt in Section 6 — unless it is explicitly marked as coordinator-handled.
176
- - No orphaned tasks (a task listed in Section 5 that never appears in any batch), no missing dependencies (a Depends on field referencing a task ID that does not exist).
175
+ - Each task's Depends on field in Section 6 matches the batch ordering in Section 8. No task scheduled in a batch before its dependencies are met.
176
+ - Every task listed in Section 8 (Batch Schedule) has a worker prompt in Section 7 — unless it is explicitly marked as coordinator-handled.
177
+ - No orphaned tasks (a task listed in Section 6 that never appears in any batch), no missing dependencies (a Depends on field referencing a task ID that does not exist).
177
178
 
178
179
  ### 12. Produce PROMPT.md
179
180
 
@@ -15,11 +15,11 @@
15
15
  ### What you do
16
16
 
17
17
  - Read and understand the mission, scope, technical context, and task definitions below
18
- - Spawn workers to execute individual tasks, giving each a self-contained prompt (provided in Section 6)
18
+ - Spawn workers to execute individual tasks, giving each a self-contained prompt (provided in Section 7)
19
19
  - Wait for all workers in a batch to complete, then digest their results
20
20
  - Run verification commands at each checkpoint
21
21
  - Decide whether to proceed to the next batch, retry a failed worker, or halt
22
- - Handle lightweight coordination tasks: resolving merge conflicts, updating lockfiles
22
+ - Handle lightweight coordination tasks: resolving merge conflicts, updating lockfiles, cleaning up worktrees
23
23
  - Commit all changes in a single commit after the final verification gate passes
24
24
 
25
25
  ### What you NEVER do
@@ -74,7 +74,14 @@
74
74
 
75
75
  ---
76
76
 
77
- ## 5. Task Units
77
+ ## 5. References
78
+
79
+ - **Project context files**: [List important project files the coordinator and workers may need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`, codegraph index files]
80
+ - **Related documents**: [Links to related specs, design docs, or external documentation]
81
+
82
+ ---
83
+
84
+ ## 6. Task Units
78
85
 
79
86
  [Each task is an atomic work unit. Task ID format: `T{batch}.{sequence}`.]
80
87
 
@@ -100,7 +107,7 @@
100
107
 
101
108
  ---
102
109
 
103
- ## 6. Worker Prompt Library
110
+ ## 7. Worker Prompt Library
104
111
 
105
112
  [Each dispatchable task has a pre-written self-contained worker prompt. The coordinator extracts the corresponding block and dispatches it without modification.]
106
113
 
@@ -114,8 +121,8 @@
114
121
  - Read the following files: [list]
115
122
 
116
123
  ## What to do
117
- 1. [Concrete step describe "what" to do, not "which tool" to use]
118
- 2. [Include specific file paths, function names, line numbers]
124
+ 1. [Specify the exact file path, the function or line range, and what specific change to make (add/delete/modify). Example: "In src/auth/login.ts, function validateToken() (line 42-58): add a null check for the token parameter before calling decode()."]
125
+ 2. [Repeat for each file never leave the change description vague]
119
126
 
120
127
  ## Scope
121
128
  - Allowed files:
@@ -146,7 +153,7 @@ On completion, report:
146
153
 
147
154
  ---
148
155
 
149
- ## 7. Batch Schedule
156
+ ## 8. Batch Schedule
150
157
 
151
158
  [Batched according to the dependency graph. Tasks within the same batch have no file overlap and no logical dependency — they can run in parallel.]
152
159
 
@@ -183,7 +190,7 @@ On completion, report:
183
190
 
184
191
  ---
185
192
 
186
- ## 8. Verification Checkpoints
193
+ ## 9. Verification Checkpoints
187
194
 
188
195
  ### Per-batch
189
196
 
@@ -206,7 +213,7 @@ On completion, report:
206
213
 
207
214
  ---
208
215
 
209
- ## 9. Error Recovery
216
+ ## 10. Error Recovery
210
217
 
211
218
  | Scenario | Response |
212
219
  |---|---|
@@ -218,15 +225,16 @@ On completion, report:
218
225
 
219
226
  ---
220
227
 
221
- ## 10. Boundaries
228
+ ## 11. Boundaries
222
229
 
223
230
  ### ALWAYS
224
231
 
225
232
  - Run gate verification immediately after every batch
226
- - Extract worker prompts verbatim from Section 6 — do not rewrite them
233
+ - Extract worker prompts verbatim from Section 7 — do not rewrite them
227
234
  - After a worker reports, digest the results before deciding next steps
228
235
  - Follow the File Ownership implied by task assignments — do not let two workers modify the same file
229
236
  - **Resolve merge conflicts yourself** — when combining worker results, the coordinator handles conflict resolution. This is coordination, not implementation.
237
+ - **After each batch completes, clean up any temporary branches or worktrees created by workers** — no ephemeral worktree should be left orphaned.
230
238
  - After two failures, pause and ask — do not keep retrying
231
239
 
232
240
  ### ASK FIRST — pause and confirm with the user
@@ -109,7 +109,7 @@ Each fix worker prompt must include:
109
109
  ## Mission — What to fix and why
110
110
  ## Context — Which review dimension, which spec requirement
111
111
  ## Input — Which files to read
112
- ## What to do — Concrete fix steps (describe "what" to do, not "which tool" to use)
112
+ ## What to do — Concrete fix steps, each specifying the exact file path, the function or line range, and what specific change to make (add/delete/modify). Never leave the change description vague.
113
113
  ## Scope — Allowed and forbidden files
114
114
  ## Output — What to report on completion
115
115
  ## Verify — Verification commands and expected results
@@ -186,7 +186,8 @@ Use `assets/templates/FIX.md`. Fill according to the table below.
186
186
  | 9. Verification Checkpoints | Fixed scaffold, customized with spec-specific commands |
187
187
  | 10. Error Recovery | Fixed scaffold (natural language) |
188
188
  | 11. Fix History | Fixed scaffold (history entries only, no instructions) |
189
- | 12. Boundaries | Fixed scaffold + spec-specific rules |
189
+ | 12. References | Important project context files (CLAUDE.md, AGENTS.md, architecture atlas, codegraph index) — reduces LLM search overhead |
190
+ | 13. Boundaries | Fixed scaffold + spec-specific rules (including worktree cleanup after each batch) |
190
191
 
191
192
  ### 11. Produce FIX.md
192
193
 
@@ -120,8 +120,8 @@
120
120
  - Read the following files: [list]
121
121
 
122
122
  ## What to do
123
- 1. [Concrete fix steps describe "what" to do, not "which tool" to use]
124
- 2. [Include specific file paths, function names, line numbers, modification approach]
123
+ 1. [Specify the exact file path, the function or line range, and what specific change to make (add/delete/modify). Example: "In src/auth/login.ts, function validateToken() (line 42-58): add a null check for the token parameter before calling decode()."]
124
+ 2. [Repeat for each file never leave the change description vague]
125
125
 
126
126
  ## Scope
127
127
  - Allowed files:
@@ -311,7 +311,14 @@ If there are no entries here, see Section 5 for each fix's regression test desig
311
311
 
312
312
  ---
313
313
 
314
- ## 12. Boundaries
314
+ ## 12. References
315
+
316
+ - **Project context files**: [List important project files the fix coordinator and workers may need — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`, codegraph index files]
317
+ - **Related documents**: [Links to REPORT.md, SPEC.md, DESIGN.md, or external documentation]
318
+
319
+ ---
320
+
321
+ ## 13. Boundaries
315
322
 
316
323
  ### ALWAYS
317
324
 
@@ -322,6 +329,7 @@ If there are no entries here, see Section 5 for each fix's regression test desig
322
329
  - Regression tests must not start before all fix batches pass
323
330
  - Resolve merge conflicts yourself — the coordinator handles them. This is coordination, not implementation.
324
331
  - **For fixes marked as Complex**: ensure the worker performs systematic debugging (reading related code, tracing execution paths) before applying the fix. Do not let the worker guess the fix.
332
+ - **After each batch completes, clean up any temporary branches or worktrees created by workers** — no ephemeral worktree should be left orphaned.
325
333
 
326
334
  ### ASK FIRST — pause and confirm with the user
327
335
 
@@ -111,6 +111,7 @@ Include the following sections:
111
111
  - **Requirement Status Summary**: Per-requirement: completion status, evidence location, open findings
112
112
  - **Findings**: Issue list sorted by P0 → P3 (only levels with findings)
113
113
  - **Review History**: Previous rounds (if any)
114
+ - **References**: List important project context files the next skill (qa) will need (e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`). This reduces the LLM's need to search for relevant files when processing the report.
114
115
 
115
116
  **Verdict criteria** (P-level directly determines verdict — no separate requirement check needed):
116
117
 
@@ -56,3 +56,10 @@
56
56
  - **Verdict**: [Ready to Merge / Needs Attention / Needs Work]
57
57
  - **Issues**: P0:X, P1:X, P2:X, P3:X
58
58
  - **Key findings**: [1-2 sentence summary of the most important findings in this round]
59
+
60
+ ---
61
+
62
+ ## References
63
+
64
+ - **Project context files**: [List important project files the reviewer used — e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`]
65
+ - **Related documents**: [Links to related SPEC.md, DESIGN.md, or external documentation]
@@ -96,7 +96,7 @@ Generate SPEC.md using the template at `assets/templates/SPEC.md`.
96
96
  - **Uncertainty Level** → Per requirement, mark Known or Exploratory.
97
97
  - **Error and Edge Cases** → List specific cases. Free-form list; no fixed categories needed in the template (the five categories from Step 2 guide your thinking, not the output format).
98
98
  - **Clarification Questions** → List questions for the user. Must be populated when any requirement is Exploratory. Omit only if all requirements are fully clear.
99
- - **References** → Link to official docs and related code files for traceability.
99
+ - **References** → List important project context files the LLM will need (e.g., `CLAUDE.md`, `AGENTS.md`, `resources/project-architecture/**`), plus official docs and related code files for traceability.
100
100
 
101
101
  **BDD writing guidelines**:
102
102
  - **GIVEN** states the precondition and actor role
@@ -17,14 +17,24 @@ Keep the architecture diagram continuously aligned with the actual codebase.
17
17
 
18
18
  ## Workflow
19
19
 
20
- ### 1. Review the current atlas
20
+ ### 1. Analyze current code with `apltk codegraph survey`
21
+
22
+ **Prerequisite** before measuring drift. The code graph provides the structural baseline for comparison with the atlas.
23
+
24
+ Run `apltk codegraph survey --json` to get a structured view of the current codebase:
25
+ - Entry points, function clusters, and suggested submodule groupings
26
+ - Cross-boundary edges for identifying architectural relationships
27
+
28
+ Consult `references/codegraph.md` for detailed flags.
29
+
30
+ ### 2. Review the current atlas
21
31
 
22
32
  Read the existing architecture diagram.
23
33
  Capture the relationship between features and submodules.
24
34
 
25
35
  > Read only `atlas.index.yaml` + the YAML files of affected features. Do not read unrelated features or unchanged modules to preserve context economy.
26
36
 
27
- ### 2. Measure architecture drift
37
+ ### 3. Measure architecture drift
28
38
 
29
39
  Before deciding the update scope, compare the atlas against the current code:
30
40
 
@@ -36,7 +46,7 @@ Determine the update strategy based on drift severity:
36
46
  - **Low drift (< 20%)**: Update only the features affected by the diff
37
47
  - **High drift (≥ 20%)**: Flag as significant divergence, notify the user and recommend a full re-initialization via `init-project-html`
38
48
 
39
- ### 3. Filter diff noise
49
+ ### 4. Filter diff noise
40
50
 
41
51
  Analyze the diff scope and filter non-architectural changes:
42
52
 
@@ -45,11 +55,11 @@ Analyze the diff scope and filter non-architectural changes:
45
55
 
46
56
  Map the filtered diff hunks to the affected features.
47
57
 
48
- ### 4. Cross-reference code with the current atlas
58
+ ### 5. Cross-reference code with the current atlas
49
59
 
50
60
  Dispatch subagents in parallel to cross-reference the code against the architecture diagram and verify whether the atlas has errors or omissions.
51
61
 
52
- ### 5. Update the atlas via `apltk` CLI
62
+ ### 6. Update the atlas via `apltk` CLI
53
63
 
54
64
  Use `apltk architecture` commands to update the architecture diagram:
55
65
 
@@ -67,7 +77,7 @@ apltk architecture function add --feature <slug> --submodule <slug> --name <fn>
67
77
 
68
78
  After completing the update, re-measure drift to confirm it has been reduced to an acceptable range.
69
79
 
70
- ### 6. Self-review
80
+ ### 7. Self-review
71
81
 
72
82
  Confirm the following before finishing:
73
83
 
@@ -79,5 +89,6 @@ Confirm the following before finishing:
79
89
 
80
90
  ## References
81
91
 
82
- - `references/architecture.md` — Full parameter reference for the apltk architecture tool (consult when CLI flag details are needed).
92
+ - `references/codegraph.md` — `apltk codegraph` CLI reference (consult for subcommand flags).
93
+ - `references/architecture.md` — Full parameter reference for the `apltk architecture` tool (consult when CLI flag details are needed).
83
94
  - `references/definition.md` — Detailed definitions of feature and submodule.
@@ -0,0 +1,41 @@
1
+ # apltk codegraph — Code Intelligence CLI Reference
2
+
3
+ ## Purpose
4
+ Parse source code into a knowledge graph of symbols (functions, classes) and relationships (call edges), backed by a local SQLite database with FTS5 full-text search. Powered by @colbymchenry/codegraph (tree-sitter-backed code knowledge graph engine).
5
+
6
+ ## Usage
7
+ ```
8
+ apltk codegraph <subcommand> [options]
9
+ ```
10
+
11
+ ## Subcommands
12
+
13
+ ### Lifecycle
14
+
15
+ | Subcommand | Description | Key Flags |
16
+ |------------|-------------|-----------|
17
+ | `init` | Initialize CodeGraph for the project | `--index` (run initial indexing immediately), `--json` |
18
+ | `sync` | Sync index with current file state (incremental) | `--json` |
19
+ | `status` | Show index statistics (files, nodes, edges, languages) | `--json` |
20
+
21
+ ### Discovery
22
+
23
+ | Subcommand | Description | Key Flags |
24
+ |------------|-------------|-----------|
25
+ | `search <query>` | Search code graph for symbols via FTS5 | `--limit N` (default 20, max 100), `--json` |
26
+ | `explore <query>` | Deep-dive on a symbol — callers, callees, source | `--feature <name>`, `--json` |
27
+ | `survey [dir]` | Scan directory, suggest submodule groupings and edges | `--feature <name>`, `--json` |
28
+ | `list-apis [path]` | List public APIs in project or sub-path | `--all` (include internal symbols), `--json` |
29
+
30
+ ### Validation
31
+
32
+ | Subcommand | Description | Key Flags |
33
+ |------------|-------------|-----------|
34
+ | `verify --spec <dir>` | Verify a spec overlay against actual code | `--json` |
35
+
36
+ ## Common Workflows
37
+
38
+ - **Before atlas work**: `apltk codegraph init --index` (first time), then `apltk codegraph survey --json`
39
+ - **After code changes**: `apltk codegraph sync` to keep index current
40
+ - **Understanding a symbol**: `apltk codegraph explore <name>` to see callers and callees
41
+ - **Searching code**: `apltk codegraph search <query> --json --limit 30`