ai-factory 2.13.2 → 2.14.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.
Files changed (30) hide show
  1. package/dist/cli/wizard/skill-hints.d.ts.map +1 -1
  2. package/dist/cli/wizard/skill-hints.js +1 -0
  3. package/dist/cli/wizard/skill-hints.js.map +1 -1
  4. package/package.json +2 -1
  5. package/skills/aif/SKILL.md +23 -12
  6. package/skills/aif/references/config-template.yaml +10 -0
  7. package/skills/aif/references/update-config.mjs +1 -0
  8. package/skills/aif-archive/SKILL.md +317 -0
  9. package/skills/aif-distillation/SKILL.md +4 -2
  10. package/skills/aif-distillation/references/LARGE-MATERIALS.md +21 -1
  11. package/skills/aif-explore/SKILL.md +29 -4
  12. package/skills/aif-fix/SKILL.md +23 -2
  13. package/skills/aif-implement/SKILL.md +3 -0
  14. package/skills/aif-improve/SKILL.md +96 -177
  15. package/skills/aif-improve/references/CHECK-MODE.md +101 -0
  16. package/skills/aif-improve/references/EXAMPLES.md +88 -0
  17. package/skills/aif-improve/references/LIST-MODE.md +83 -0
  18. package/skills/aif-improve/references/VALIDATOR.md +89 -0
  19. package/skills/aif-plan/SKILL.md +23 -3
  20. package/skills/aif-reference/SKILL.md +22 -3
  21. package/skills/aif-review/SKILL.md +44 -17
  22. package/skills/aif-review/references/CHECK-MODE.md +109 -0
  23. package/skills/aif-review/references/SEVERITY.md +35 -0
  24. package/skills/aif-review/references/VALIDATOR.md +103 -0
  25. package/skills/aif-rules/SKILL.md +18 -2
  26. package/skills/aif-security-checklist/SKILL.md +20 -3
  27. package/skills/aif-skill-generator/SKILL.md +39 -19
  28. package/skills/aif-skill-generator/references/SECURITY-SCANNING.md +5 -3
  29. package/skills/aif-skill-generator/scripts/cleanup-blocked-skill.py +617 -0
  30. package/skills/aif-verify/SKILL.md +14 -1
@@ -48,6 +48,7 @@ Handoff sync is handled inline — see **Step 0.2** (after reading the plan file
48
48
  1. Read `.ai-factory/config.yaml` if it exists to resolve:
49
49
  - `paths.description`, `paths.architecture`, `paths.rules_file`, `paths.roadmap`, `paths.research`
50
50
  - `paths.plan`, `paths.plans`, `paths.fix_plan`, `paths.patches`
51
+ - `paths.archive`
51
52
  - `paths.rules`
52
53
  - `language.ui`, `language.artifacts`
53
54
  - `git.enabled`, `git.base_branch`, `git.create_branches`
@@ -461,6 +462,8 @@ Then continue with normal execution using the selected plan file.
461
462
  4. `paths.plan` (from `/aif-plan fast`) - fallback when no full plan exists
462
463
  5. `paths.fix_plan` - redirect to `/aif-fix` (from `/aif-fix` plan mode)
463
464
 
465
+ **Note:** Plan discovery scans `paths.plans/` only. Plans archived to `paths.archive/plans/` by `/aif-archive` are excluded from discovery.
466
+
464
467
  **Read the plan file** to understand:
465
468
 
466
469
  - Context and settings (testing, logging preferences)
@@ -1,8 +1,8 @@
1
1
  ---
2
2
  name: aif-improve
3
- description: Refine and enhance an existing implementation plan with a second iteration. Re-analyzes the codebase, checks for gaps, missing tasks, wrong dependencies, and improves the plan quality. Use after /aif-plan to polish the plan before implementation, or to improve an existing /aif-fix plan.
4
- argument-hint: "[--list] [@plan-file] [improvement prompt or empty for auto-review]"
5
- allowed-tools: Read Write Edit Glob Grep Bash(git *) TaskCreate TaskUpdate TaskList TaskGet AskUserQuestion Questions
3
+ description: Refine an existing implementation plan with a second iteration. Re-analyzes the codebase for gaps, missing tasks, and wrong dependencies. Use after /aif-plan or to improve an /aif-fix plan. Optional +check flag validates refinements via a fresh-context subagent.
4
+ argument-hint: "[--list] [+check] [@plan-file] [improvement prompt or empty for auto-review]"
5
+ allowed-tools: Read Write Edit Glob Grep Bash(git *) Task Agent TaskCreate TaskUpdate TaskList TaskGet AskUserQuestion Questions
6
6
  disable-model-invocation: false
7
7
  ---
8
8
 
@@ -22,11 +22,11 @@ enhanced plan with better tasks, correct dependencies, more detail
22
22
 
23
23
  ## Workflow
24
24
 
25
- ### Step 0: Load Config & Find the Plan
25
+ ### Step 0: Load Config & Parse Arguments
26
26
 
27
27
  **FIRST:** Read `.ai-factory/config.yaml` if it exists to resolve:
28
- - **Paths:** `paths.plan`, `paths.plans`, `paths.fix_plan`, `paths.research`, `paths.description`, and `paths.patches`
29
- - **Language:** `language.ui` for prompts
28
+ - **Paths:** `paths.plan`, `paths.plans`, `paths.fix_plan`, `paths.research`, `paths.description`, `paths.patches`, and `paths.archive`
29
+ - **Language:** `language.ui` for prompts and summaries, `language.artifacts` for plan artifact updates, and `language.technical_terms` for human-readable technical terminology in plan artifacts
30
30
  - **Git:** `git.enabled`, `git.base_branch`, `git.create_branches`
31
31
  - **Workflow:** `workflow.plan_id_format` (default: `slug`) — used by branch-based plan discovery.
32
32
  Active values: `slug` and `sequential`. When `sequential`, the resolver globs
@@ -42,48 +42,44 @@ If config.yaml doesn't exist, use defaults:
42
42
  - research: `.ai-factory/RESEARCH.md`
43
43
  - patches/: `.ai-factory/patches/`
44
44
  - DESCRIPTION.md: `.ai-factory/DESCRIPTION.md`
45
- - Language: `en` (English)
45
+ - `ui_language`: `en`
46
+ - `artifact_language`: `en`
47
+ - `technical_terms_policy`: `keep`
46
48
  - `workflow.plan_id_format`: `slug`
47
49
 
50
+ Resolved language values:
51
+ - `ui_language = language.ui || "en"`
52
+ - `artifact_language = language.artifacts || language.ui || "en"`
53
+ - `technical_terms_policy = language.technical_terms || "keep"`
54
+
55
+ If `technical_terms_policy` is not one of `keep`, `translate`, or `mixed`, treat it as `keep`. Legacy values such as `english` also behave like `keep`.
56
+
57
+ All AskUserQuestion prompts, progress updates, refinement reports, summaries, and next-step guidance MUST be written in `ui_language`.
58
+
59
+ Any generated or updated plan artifact content under `paths.plan`, `paths.plans`, or `paths.fix_plan` MUST be written in `artifact_language`.
60
+
61
+ Templates and examples define structure, not fixed English output. If `artifact_language` is not `en`, translate human-readable headings, labels, task prose, roadmap rationale, research summaries, improvement notes, and dependency notes before saving. Preserve markdown structure, checkbox syntax, task IDs, numeric prefixes, branch names, commit messages, commands, file paths, config keys, package names, API names, `WARN`/`INFO` labels, and raw errors unchanged. Apply `technical_terms_policy` to other human-readable terminology.
62
+
48
63
  **First parse arguments:**
49
64
 
50
65
  ```
51
66
  - --list → list available plans only (read-only, then STOP)
67
+ - +check → after refinement, validate findings via a fresh-context subagent
52
68
  - @<path> → explicit plan file override (highest priority)
53
69
  - remaining argument text → optional improvement prompt
54
70
  ```
55
71
 
56
- When both are present, `--list` wins and no refinement is executed.
72
+ `+check` is orthogonal to the other flags and may appear anywhere in `$ARGUMENTS`. Strip it from the argument string before resolving `@<path>` and the improvement prompt.
73
+
74
+ When `--list` is present, it wins and no refinement is executed. `+check` is silently ignored in `--list` mode (there is nothing to validate before refinement runs).
57
75
 
58
76
  ### Step 0.list: List Available Plans (`--list`)
59
77
 
60
- If `$ARGUMENTS` contains `--list`, run read-only discovery and stop.
78
+ If `$ARGUMENTS` contains `--list`, execute the procedure in `references/LIST-MODE.md` and STOP. That document is the single source of truth for the discovery rules, output shape, and read-only contract (no refinement, no file modifications, `+check` is silently ignored). Do not duplicate its content here.
61
79
 
62
- ```
63
- 1. Get current branch:
64
- git branch --show-current (git mode only)
65
- 2. Convert branch to filename stem: replace "/" with "-" (git mode only)
66
- → this is <branch-slug>
67
- 3. Check existence of:
68
- - <configured plans dir>/<branch-slug>.md (default `plan_id_format`)
69
- - when `workflow.plan_id_format = sequential`: also glob
70
- `<configured plans dir>/[0-9][0-9][0-9][0-9]_<branch-slug>.md`;
71
- report all matches (highest-numbered first)
72
- - if git mode is off or branch creation is disabled: any `*.md` full-mode plan in `<configured plans dir>/`
73
- (a leading 4-digit prefix counts as a match)
74
- - <resolved fast plan path>
75
- - <resolved fix plan path>
76
- 4. Print availability summary and usage hints:
77
- - /aif-improve @<path> <optional prompt>
78
- - /aif-improve <optional prompt> # automatic priority
79
- 5. If none found, suggest creating a plan via /aif-plan or /aif-fix
80
- 6. STOP.
81
- ```
80
+ ### Step 1: Resolve Active Plan
82
81
 
83
- **Important:** In `--list` mode:
84
- - Do not execute refinement
85
- - Do not modify files
86
- - Do not update TaskList/plan content
82
+ This step runs in the default (non-`--list`) mode and picks **one** plan file for refinement using the priority chain below. The discovery-list logic for `--list` lives in `references/LIST-MODE.md` and is independent of this step.
87
83
 
88
84
  **Locate the active plan file using this priority:**
89
85
 
@@ -113,6 +109,8 @@ If `$ARGUMENTS` contains `--list`, run read-only discovery and stop.
113
109
  5. No full-mode plan and no resolved fast plan → Check the resolved fix plan path (from /aif-fix plan mode)
114
110
  ```
115
111
 
112
+ **Note:** Plan discovery scans `paths.plans/` only. Plans archived to `paths.archive/plans/` by `/aif-archive` are excluded from discovery.
113
+
116
114
  **If NO plan file found at any location:**
117
115
 
118
116
  ```
@@ -126,11 +124,11 @@ To create a plan first, use:
126
124
 
127
125
  → **STOP here.** Do not proceed without a plan file.
128
126
 
129
- **If plan file found → read it and continue to Step 1.**
127
+ **If plan file found → proceed to Step 2 (Load Context).**
130
128
 
131
- ### Step 1: Load Context
129
+ ### Step 2: Load Context
132
130
 
133
- **1.1: Read the plan file**
131
+ **2.1: Read the plan file**
134
132
 
135
133
  Read the found plan file completely. Understand:
136
134
  - Feature scope and goals
@@ -139,7 +137,7 @@ Read the found plan file completely. Understand:
139
137
  - Commit checkpoints
140
138
  - Which tasks are already completed (checkboxes `- [x]`)
141
139
 
142
- **1.2: Read project context**
140
+ **2.2: Read project context**
143
141
 
144
142
  Read `.ai-factory/DESCRIPTION.md` (use path from config) if it exists:
145
143
  - Tech stack
@@ -149,7 +147,7 @@ Read `.ai-factory/DESCRIPTION.md` (use path from config) if it exists:
149
147
 
150
148
  Read `.ai-factory/RESEARCH.md` (use path from config) if it exists and is relevant to the plan being refined.
151
149
 
152
- **1.3: Read patches (limited fallback)**
150
+ **2.3: Read patches (limited fallback)**
153
151
 
154
152
  Use patches as fallback context, not the default source:
155
153
 
@@ -181,7 +179,7 @@ codebase conventions, and tech-stack analysis. These rules are tailored to the c
181
179
  **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
182
180
  If any rule is violated — fix the output before presenting it to the user.
183
181
 
184
- **1.4: Load current task list**
182
+ **2.4: Load current task list**
185
183
 
186
184
  ```
187
185
  TaskList → Get all tasks with statuses
@@ -189,11 +187,11 @@ TaskList → Get all tasks with statuses
189
187
 
190
188
  Understand what's already been created, what's in progress, what's completed.
191
189
 
192
- ### Step 2: Deep Codebase Analysis
190
+ ### Step 3: Deep Codebase Analysis
193
191
 
194
192
  Now do a **deeper** codebase exploration than what `/aif-plan` did initially:
195
193
 
196
- **2.1: Trace through existing code paths**
194
+ **3.1: Trace through existing code paths**
197
195
 
198
196
  For each task in the plan, find the relevant files:
199
197
  ```
@@ -207,7 +205,7 @@ Look for:
207
205
  - Hidden dependencies the plan missed
208
206
  - Shared utilities or services the plan should use instead of creating new ones
209
207
 
210
- **2.2: Check for integration points**
208
+ **3.2: Check for integration points**
211
209
 
212
210
  Look for things the plan might have missed:
213
211
  - API routes that need updating
@@ -217,7 +215,7 @@ Look for things the plan might have missed:
217
215
  - Middleware or guards that apply
218
216
  - Existing validation patterns
219
217
 
220
- **2.3: Check for edge cases**
218
+ **3.3: Check for edge cases**
221
219
 
222
220
  Based on the tech stack and codebase:
223
221
  - Error handling patterns used in the project
@@ -226,45 +224,62 @@ Based on the tech stack and codebase:
226
224
  - Rate limiting, caching considerations
227
225
  - Data validation at boundaries
228
226
 
229
- ### Step 3: Identify Improvements
227
+ ### Step 4: Identify Improvements
230
228
 
231
229
  Compare the plan against what you found. Categorize issues:
232
230
 
233
- **3.1: Missing tasks**
231
+ **4.1: Missing tasks**
234
232
  - Tasks that should exist but don't (e.g., migration, config update, index creation)
235
233
  - Tasks for edge cases not covered
236
234
 
237
- **3.2: Task quality issues**
235
+ **4.2: Task quality issues**
238
236
  - Descriptions too vague (no file paths, no specific implementation details)
239
237
  - Missing logging requirements
240
238
  - Missing error handling details
241
239
  - Incorrect file paths
242
240
 
243
- **3.3: Dependency issues**
241
+ **4.3: Dependency issues**
244
242
  - Wrong task order (task A depends on B but B comes after A)
245
243
  - Missing dependencies (task C needs task A's output but isn't blocked by it)
246
244
  - Unnecessary dependencies (tasks could run in parallel)
247
245
 
248
- **3.4: Redundant or duplicate tasks**
246
+ **4.4: Redundant or duplicate tasks**
249
247
  - Two tasks doing the same thing
250
248
  - Task that's unnecessary because the code already exists
251
249
  - Task that duplicates existing functionality
252
250
 
253
- **3.5: Scope issues**
251
+ **4.5: Task size issues**
254
252
  - Tasks too large (should be split)
255
253
  - Tasks too small (should be merged)
256
- - Tasks outside the feature scope (gold-plating)
254
+ - Split/merge findings go into the "📝 Task Improvements" report section (`improvements` group, alongside 4.2) — they restructure existing tasks rather than add or remove them.
257
255
 
258
- **3.6: User-prompted improvements (if $ARGUMENTS provided)**
256
+ **4.6: Out-of-scope tasks**
257
+ - Tasks already in the plan that look useful in themselves but are unrelated to the feature this plan is about (gold-plating)
258
+ - On approval these are removed from the active plan — the same drop action as `removals` (see Step 6.4). The difference is the report only: an out-of-scope task goes to its own "💡 Out of scope" section instead of being lumped into "🗑️ Removals", so the user sees a useful-but-unrelated idea before it is dropped and can choose to capture it elsewhere. The skill itself does not persist out-of-scope items anywhere.
259
259
 
260
- If the user provided specific improvement instructions in `$ARGUMENTS` (excluding `--list` and `@<path>` tokens):
260
+ **4.7: User-prompted improvements (if $ARGUMENTS provided)**
261
+
262
+ If the user provided specific improvement instructions in `$ARGUMENTS` (excluding `--list`, `+check`, and `@<path>` tokens):
261
263
  - Apply the user's feedback to the plan
262
264
  - Look for tasks that need modification based on the prompt
263
265
  - Add new tasks if the user's prompt requires them
264
266
 
265
- ### Step 4: Present Improvements
267
+ This is a dispatcher step, not a separate finding category. Each finding it produces is routed to its natural group based on its nature: a new task goes to 4.1 (`missing`), a rewording or expansion of an existing task goes to 4.2 (`improvements`), an explicit removal request goes to 4.4 (`removals`), and a "useful-but-out-of-scope" idea goes to 4.6 (`out_of_scope`). There is no separate 4.7 group in the Step 5 report or in `+check` validation.
268
+
269
+ ### Optional: `+check` validation between Step 4 and Step 5
270
+
271
+ When the `+check` flag is set (and `--list` is not), run the validation procedure from `references/CHECK-MODE.md` here, between Step 4 and Step 5. It re-reads cited files via a fresh-context subagent, then drops invented items, rewrites partially-correct ones, and recomputes dependencies on the filtered list. Without `+check`, skip this entirely — the output has no validator-related lines and the Summary block stays in its default shape without the two `+check` counter rows.
272
+
273
+ ### Step 5: Present Improvements
274
+
275
+ Show the user what you found in a clear format. The emoji-grouped sections are kept for scannability, but the items inside "🆕 Missing Tasks", "📝 Task Improvements", "🗑️ Removals", and "💡 Out of scope" all follow the same prose shape — no labeled `Why:` / `Issue:` / `Fix:` fields:
266
276
 
267
- Show the user what you found in a clear format:
277
+ 1. **Behavioral impact** what breaks or becomes harder if the plan stays as-is (missing capability, vague task that will be misimplemented, redundant task that wastes effort).
278
+ 2. **Optional note** — short citation from the codebase, an existing pattern the plan should match, or a consequence. Include only when it adds signal.
279
+ 3. **Plan anchor** — `Task #X` reference (or "after Task #X" for new tasks).
280
+ 4. **Suggested edit** — concrete change: what to add / how to reword / what to remove.
281
+
282
+ The "🔗 Dependency Fixes" group is **not** restated in this shape — it is always computed after the four other groups (and after `+check` filtering when the flag is set, see `references/CHECK-MODE.md`) and uses the short legacy form: `Task #X should depend on Task #Y. Reason: …`. The dependency entries reference only tasks that survived filtering.
268
283
 
269
284
  ```
270
285
  ## Plan Refinement Report
@@ -275,35 +290,28 @@ Tasks analyzed: N
275
290
  ### Findings
276
291
 
277
292
  #### 🆕 Missing Tasks (N found)
278
- 1. **[New task subject]**
279
- Why: [reason this task is needed]
280
- After: Task #X (dependency)
281
-
282
- 2. **[New task subject]**
283
- Why: [reason]
293
+ 1. The plan currently leaves authenticated requests without a session refresh step — long-running clients silently lose access after the access-token TTL. The existing middleware in `src/middleware/auth.ts` already exposes a `refresh()` hook, so the plan should reuse it instead of inventing a new one. After Task #3. Add a new task: "Wire `authMiddleware.refresh()` into the login flow and cover the expired-token path with an explicit test."
284
294
 
285
295
  #### 📝 Task Improvements (N found)
286
- 1. **Task #X: [subject]**
287
- Issue: [what's wrong]
288
- Fix: [what should change]
289
-
290
- 2. **Task #Y: [subject]**
291
- Issue: [what's wrong]
292
- Fix: [what should change]
296
+ 1. Task #4 ("Add validation") gives no field-by-field contract — implementer will either over-validate or skip the email format check that the rest of the codebase enforces via `validators/email.ts`. Task #4. Rewrite as: "Validate `email` (via `validators/email.ts`), `password` (min 12 chars), and `displayName` (1-64 chars) in `RegisterRequest`; return 422 with field-level errors when validation fails."
293
297
 
294
298
  #### 🔗 Dependency Fixes (N found)
295
- 1. Task #X should depend on Task #Y
296
- Reason: [why]
299
+ 1. Task #5 should depend on Task #2. Reason: Task #5 consumes the session helper introduced in Task #2.
297
300
 
298
301
  #### 🗑️ Removals (N found)
299
- 1. **Task #X: [subject]**
300
- Reason: [why it's redundant/unnecessary]
302
+ 1. Task #7 ("Create UserRepository") duplicates `src/repos/user.ts:12` which already exposes the same query surface — keeping the task will lead to a parallel implementation. Task #7. Remove the task; rely on the existing repository and adjust Task #8 to import it.
303
+
304
+ #### 💡 Out of scope — for later (N found)
305
+ 1. Task #11 ("Refactor the logging module") looks reasonable on its own but is unrelated to the login feature this plan is about — keeping it expands scope without any concrete trigger from the current code paths. Task #11. Drop it from the active plan; the idea is surfaced here so you can capture it elsewhere (issue tracker, backlog note) if it's worth revisiting as its own feature later.
301
306
 
302
307
  #### 📋 Summary
303
308
  - Missing tasks: N
304
309
  - Tasks to improve: N
305
310
  - Dependencies to fix: N
306
311
  - Tasks to remove: N
312
+ - Out of scope: N
313
+
314
+ When `+check` ran successfully, two extra rows (`Hidden by +check: N`, `Adjusted by +check: M`) are appended to the Summary block — the exact wording and failure-mode replacements live in `references/CHECK-MODE.md`.
307
315
 
308
316
  AskUserQuestion: Apply these improvements?
309
317
 
@@ -320,6 +328,8 @@ Options:
320
328
 
321
329
  **If no improvements found:**
322
330
 
331
+ The completion templates below define structure only. Render all human-readable text in these user-facing responses in `ui_language`. Preserve command names, paths, task counts, and numeric counts unchanged.
332
+
323
333
  ```
324
334
  ## Plan Review Complete
325
335
 
@@ -332,11 +342,11 @@ Ready to implement:
332
342
  /aif-implement
333
343
  ```
334
344
 
335
- ### Step 5: Apply Approved Improvements
345
+ ### Step 6: Apply Approved Improvements
336
346
 
337
347
  Based on user's choice:
338
348
 
339
- **5.1: Apply task improvements**
349
+ **6.1: Apply task improvements**
340
350
 
341
351
  For existing tasks that need better descriptions:
342
352
  ```
@@ -344,7 +354,7 @@ TaskGet(taskId) → read current
344
354
  TaskUpdate(taskId, description: "improved description", subject: "improved subject")
345
355
  ```
346
356
 
347
- **5.2: Add missing tasks**
357
+ **6.2: Add missing tasks**
348
358
 
349
359
  For new tasks:
350
360
  ```
@@ -352,19 +362,23 @@ TaskCreate(subject, description, activeForm)
352
362
  TaskUpdate(taskId, addBlockedBy: [...]) → set dependencies
353
363
  ```
354
364
 
355
- **5.3: Fix dependencies**
365
+ **6.3: Fix dependencies**
356
366
 
357
367
  ```
358
368
  TaskUpdate(taskId, addBlockedBy: [...])
359
369
  ```
360
370
 
361
- **5.4: Remove redundant tasks**
371
+ **6.4: Remove redundant or out-of-scope tasks**
372
+
373
+ Both `removals` and `out_of_scope` translate to the same plan-file action — drop the task:
362
374
 
363
375
  ```
364
376
  TaskUpdate(taskId, status: "deleted")
365
377
  ```
366
378
 
367
- **5.5: Update the plan file**
379
+ The difference between the two is the report only. `removals` are dead-weight duplicates: mentioned once and forgotten. `out_of_scope` items appear in the "💡 Out of scope" section so the user sees the idea was noticed and consciously dropped from this plan, not removed without a trace. The skill does not persist out-of-scope tasks anywhere — capturing the idea elsewhere (issue tracker, backlog) is the user's call.
380
+
381
+ **6.5: Update the plan file**
368
382
 
369
383
  **CRITICAL:** After all changes, update the plan file to reflect the new state:
370
384
 
@@ -377,13 +391,15 @@ TaskUpdate(taskId, status: "deleted")
377
391
 
378
392
  Use `Edit` to make surgical changes to the plan file, or `Write` to regenerate it if changes are extensive.
379
393
 
394
+ When editing or regenerating the plan file, keep all human-readable artifact content in `artifact_language`; the examples above are structural only. Preserve completed `- [x]` checkboxes exactly.
395
+
380
396
  **Filename invariant:** when the existing plan filename matches the sequential
381
397
  pattern `^[0-9]{4}_.*\.md$` (e.g. `0042_feature-user-auth.md`), preserve the
382
398
  exact numeric prefix on rewrite. Never renumber a plan during an improve pass —
383
399
  the prefix is permanent and must survive any regeneration. Write back to the
384
400
  same absolute path you read from.
385
401
 
386
- **5.6: Confirm completion**
402
+ **6.6: Confirm completion**
387
403
 
388
404
  ```
389
405
  ## Plan Refined
@@ -417,108 +433,11 @@ Suggest the user to free up context space if needed: `/clear` (full reset) or `/
417
433
  2. **Preserve completed work** — never modify or remove `- [x]` completed tasks
418
434
  3. **Traceable improvements** — every change must be justified by codebase analysis or user input
419
435
  4. **Respect settings** — if testing is "no", don't add test tasks. If logging is "minimal", don't add verbose logging tasks
420
- 5. **No gold-plating** — don't add tasks outside the feature scope unless critical
436
+ 5. **No gold-plating** — don't propose adding tasks outside the feature scope unless critical. When you find a task already in the plan that drifts outside scope, route it to the "💡 Out of scope" report section, not to "🗑️ Removals" — the user should see useful-but-not-here ideas separately from dead-weight duplicates.
421
437
  6. **Minimal viable improvements** — suggest only what matters, not every possible enhancement
422
438
  7. **User approves first** — never apply changes without user confirmation
423
439
  8. **Keep plan file in sync** — the plan file MUST match the task list after improvements
424
440
 
425
441
  ## Examples
426
442
 
427
- ### Example 1: Auto-review (no arguments)
428
-
429
- ```
430
- User: /aif-improve
431
-
432
- → Found plan: .ai-factory/plans/feature-user-auth.md
433
- → 6 tasks in plan
434
- → Deep codebase analysis...
435
- → Found: project uses middleware pattern for auth, plan misses middleware task
436
- → Found: Task #3 description doesn't mention existing UserService
437
- → Found: Task #5 depends on Task #3 but no dependency set
438
-
439
- Report:
440
- - 1 missing task (auth middleware)
441
- - 1 task to improve (reference UserService)
442
- - 1 dependency to fix
443
-
444
- Apply? → Yes → Changes applied
445
- ```
446
-
447
- ### Example 2: With user prompt
448
-
449
- ```
450
- User: /aif-improve добавь обработку ошибок и валидацию входных данных
451
-
452
- → Found plan: <resolved fast plan path>
453
- → 4 tasks in plan
454
- → User wants: error handling + input validation
455
- → Analyzing each task for missing error handling...
456
- → Found: none of the tasks mention input validation
457
- → Found: error handling is inconsistent
458
-
459
- Report:
460
- - 2 tasks improved (added validation details to descriptions)
461
- - 1 new task (create shared validation utils)
462
- - Updated task descriptions with error handling patterns from codebase
463
-
464
- Apply? → Yes → Changes applied
465
- ```
466
-
467
- ### Example 3: No plan found
468
-
469
- ```
470
- User: /aif-improve
471
-
472
- → Branch: <current-branch-or-empty>
473
- → No matching branch-based full plan found
474
- → No resolved fast plan found
475
- → No resolved fix plan found
476
- → No plan file found
477
-
478
- "No active plan found. Create one first:
479
- - /aif-plan full <description>
480
- - /aif-plan fast <description>
481
- - /aif-fix <bug description>"
482
- ```
483
-
484
- ### Example 4: Explicit plan file
485
-
486
- ```
487
- User: /aif-improve @my-custom-plan.md add rollback and edge-case handling
488
-
489
- → Explicit plan override: my-custom-plan.md
490
- → Found plan: my-custom-plan.md
491
- → User wants: rollback + edge-case handling
492
- → Deep codebase analysis...
493
- → Report prepared
494
- ```
495
-
496
- ### Example 5: List mode
497
-
498
- ```
499
- User: /aif-improve --list
500
-
501
- ## Available Plans
502
- Current branch: feature/user-auth
503
- - [x] .ai-factory/plans/feature-user-auth.md
504
- - [ ] <resolved fast plan path>
505
- - [x] <resolved fix plan path>
506
-
507
- Use:
508
- - /aif-improve @.ai-factory/plans/feature-user-auth.md
509
- - /aif-improve add validation and retries
510
- ```
511
-
512
- ### Example 6: Plan already looks good
513
-
514
- ```
515
- User: /aif-improve
516
-
517
- → Found plan: .ai-factory/plans/feature-product-search.md
518
- → 5 tasks in plan
519
- → Deep analysis... all tasks well-defined, dependencies correct
520
- → No significant improvements found
521
-
522
- "Plan looks solid! Ready to implement:
523
- /aif-implement"
524
- ```
443
+ Worked examples for the default, prompt-driven, no-plan, explicit-plan-file, and "plan looks solid" flows live in `references/EXAMPLES.md`. The `--list` mode example lives in `references/LIST-MODE.md`; the `+check` mode example lives in `references/CHECK-MODE.md`.
@@ -0,0 +1,101 @@
1
+ # `+check` validation procedure
2
+
3
+ This file describes the optional findings-validation pass that runs when `aif-improve` is invoked with the `+check` flag. The parent skill defers to this document so the main `SKILL.md` stays focused on the default refinement workflow; `+check` is opt-in and most invocations do not need it.
4
+
5
+ ## When this runs
6
+
7
+ `aif-improve` is invoked with `+check` and **without** `--list`. The pass executes between Step 4 (Identify Improvements) and Step 5 (Present Improvements). Without `+check`, skip this procedure entirely — there are no validator-related lines in the output and the Step 5 Summary block stays in its default shape without the two `+check` counter rows.
8
+
9
+ `+check` together with `--list` is silently ignored (no refinement to validate).
10
+
11
+ ## Procedure
12
+
13
+ The validation pass has two sequential phases.
14
+
15
+ ### Phase (a) — validate the four findings groups
16
+
17
+ 1. Collect items from the four findings groups built in Step 4: `missing` (4.1), `improvements` (4.2 + 4.5 — everything that rewords or expands existing tasks), `removals` (4.4 — redundant/duplicate tasks dropped without trace), and `out_of_scope` (4.6 — useful-but-unrelated tasks routed to the "💡 Out of scope" report section). Number them across all four groups in display order — group label is carried alongside each item. **If the combined list is empty, skip steps 2–5 of phase (a) entirely**: do not dispatch the validator, treat phase (a) as successful with `hidden = 0`, `adjusted = 0`, and proceed directly to phase (b) (Dependency Fixes still get recomputed normally).
18
+ 2. Build the project context block: working directory path, optional excerpt from `.ai-factory/DESCRIPTION.md`, a one-line summary of the plan being refined (plan path + task count), and the user's improvement prompt parsed in Step 0 — verbatim when the run had one, or the literal marker `none — bare auto-review` when `$ARGUMENTS` carried no prompt text. The validator needs the prompt to tell a user-requested task apart from agent-invented gold-plating.
19
+ 3. Read `references/VALIDATOR.md`. The reference declares two substitution slots at the top of the file — one for the project context block from step 2 and one for the items list from step 1 (each under its own `### Item N (group: …)` heading). Replace both before dispatch; the exact placeholder tokens are listed in the VALIDATOR.md header.
20
+ 4. Dispatch one call: `Task(subagent_type: general-purpose, prompt: <rendered template>)`. The subagent runs with fresh context. Read-only behavior (no writes, no commands) is enforced by the prompt inside `references/VALIDATOR.md`, not by the dispatch interface — `general-purpose` exposes the full tool set, so a tool-level restriction is not available.
21
+ 5. Parse the response by `### Item N` headings. The group of each item is always its **original** group from step 1 — the validator is forbidden by `references/VALIDATOR.md` from changing it. The `Group:` line in the response is an integrity check, not a control field: if its value differs from the original group, treat the whole item block as malformed (see failure modes below). For each well-formed item:
22
+ - `Verdict: keep` → keep the item unchanged in its original group.
23
+ - `Verdict: modify` → replace the item text with `Modified-text`, put it back in its original group. Increment `adjusted`.
24
+ - `Verdict: drop` → remove the item from the output. Increment `hidden`.
25
+
26
+ ### Phase (b) — recompute dependencies on the filtered list
27
+
28
+ After phase (a) finishes, the main skill (not the validator) recomputes the 🔗 Dependency Fixes group against the **post-(a) plan state**:
29
+
30
+ - start from the original plan tasks,
31
+ - add tasks introduced by `missing.keep` and `missing.modify` (these are confirmed new tasks),
32
+ - remove tasks targeted by `removals.keep`, `removals.modify`, `out_of_scope.keep`, and `out_of_scope.modify` (the validator confirmed the proposal to drop the task from the plan),
33
+ - tasks rescued by `removals.drop` or `out_of_scope.drop` stay in the plan — the validator overruled the proposal — and remain valid dependency targets,
34
+ - `improvements` only reword existing tasks; they never add or remove anything from the graph.
35
+
36
+ Any dependency that points at a task absent from the post-(a) plan is discarded. Dependencies are NOT sent to the validator — the legacy short form (`Task #X should depend on Task #Y. Reason: …`) is preserved and the counters from phase (a) do not include this group.
37
+
38
+ ## Failure modes
39
+
40
+ - **Per-item malformed response** (heading missing, no `Verdict` line, unknown verdict token, missing `Modified-text` line when `Verdict` is `modify`, or `Group:` value that differs from the item's original group): treat that item as `keep` and append one extra line at the very end of the Step 5 output: `WARN [+check]: validator response for item N was malformed, kept as-is`. Continue with the remaining items.
41
+ - **Whole-dispatch failure** (empty response, exception, timeout, validator refusal): treat **all** items in phase (a) as `keep`, skip the `Hidden by +check` / `Adjusted by +check` Summary rows, and append one line at the end of Step 5: `WARN [+check]: validator failed (<reason>), all items kept as-is`. Phase (b) still runs against the unfiltered list — dependencies are recomputed normally.
42
+
43
+ ## Output additions
44
+
45
+ When phase (a) ran successfully (no whole-dispatch failure), the Step 5 Summary block gains two extra rows at the end:
46
+
47
+ ```
48
+ - Hidden by +check: N
49
+ - Adjusted by +check: M
50
+ ```
51
+
52
+ The counters cover the four validated groups (`missing`, `improvements`, `removals`, `out_of_scope`) — `Dependencies to fix` is computed after validation and is not part of the counters. Skip both rows entirely when `+check` was not set, when the whole-dispatch failure path applies (the single `WARN [+check]` line replaces them), or when Step 5 takes the no-improvements branch (the "Plan Review Complete" / "Plan looks solid" path has no Summary block to extend).
53
+
54
+ ## Examples
55
+
56
+ ### Success
57
+
58
+ ```
59
+ User: /aif-improve +check
60
+
61
+ → Found plan: .ai-factory/plans/feature-user-auth.md
62
+ → Step 4 produced 4 missing, 3 improvements, 2 removals, 1 out_of_scope
63
+ → +check validator dispatched (see procedure above)
64
+ → Validator returned: 7 keep, 2 modify, 1 drop
65
+ → Dependencies recomputed against the post-(a) plan state
66
+
67
+ Step 5 report:
68
+ - Missing tasks: 3
69
+ - Tasks to improve: 3
70
+ - Dependencies to fix: 2
71
+ - Tasks to remove: 2
72
+ - Out of scope: 1
73
+ - Hidden by +check: 1
74
+ - Adjusted by +check: 2
75
+
76
+ Apply? → Yes → Changes applied
77
+ ```
78
+
79
+ ### Whole-dispatch failure
80
+
81
+ ```
82
+ User: /aif-improve +check
83
+
84
+ → Found plan: .ai-factory/plans/feature-user-auth.md
85
+ → Step 4 produced 4 missing, 3 improvements, 2 removals, 1 out_of_scope
86
+ → +check validator dispatched
87
+ → Validator failed (empty response)
88
+ → Phase (a): all items treated as keep (no Hidden/Adjusted counters emitted)
89
+ → Phase (b): dependencies still recomputed normally against the unfiltered list
90
+
91
+ Step 5 report (original counters, no +check rows appended):
92
+ - Missing tasks: 4
93
+ - Tasks to improve: 3
94
+ - Dependencies to fix: 2
95
+ - Tasks to remove: 2
96
+ - Out of scope: 1
97
+
98
+ WARN [+check]: validator failed (empty response), all items kept as-is
99
+
100
+ Apply? → Yes → Changes applied
101
+ ```