ai-factory 2.2.2 → 2.4.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 (45) hide show
  1. package/README.md +5 -1
  2. package/dist/cli/commands/extension.js +10 -3
  3. package/dist/cli/commands/extension.js.map +1 -1
  4. package/dist/core/agents.js +2 -2
  5. package/dist/core/agents.js.map +1 -1
  6. package/dist/core/extensions.d.ts +2 -1
  7. package/dist/core/extensions.d.ts.map +1 -1
  8. package/dist/core/extensions.js.map +1 -1
  9. package/dist/core/mcp.d.ts +2 -2
  10. package/dist/core/mcp.d.ts.map +1 -1
  11. package/dist/core/mcp.js +67 -10
  12. package/dist/core/mcp.js.map +1 -1
  13. package/dist/core/transformer.d.ts.map +1 -1
  14. package/dist/core/transformer.js +1 -0
  15. package/dist/core/transformer.js.map +1 -1
  16. package/dist/core/transformers/antigravity.d.ts.map +1 -1
  17. package/dist/core/transformers/antigravity.js +2 -0
  18. package/dist/core/transformers/antigravity.js.map +1 -1
  19. package/package.json +1 -1
  20. package/skills/aif/SKILL.md +29 -0
  21. package/skills/aif-architecture/SKILL.md +26 -0
  22. package/skills/aif-best-practices/SKILL.md +20 -0
  23. package/skills/aif-build-automation/SKILL.md +21 -1
  24. package/skills/aif-ci/SKILL.md +20 -0
  25. package/skills/aif-commit/SKILL.md +42 -12
  26. package/skills/aif-dockerize/SKILL.md +22 -1
  27. package/skills/aif-docs/SKILL.md +23 -1
  28. package/skills/aif-evolve/SKILL.md +352 -139
  29. package/skills/aif-explore/SKILL.md +384 -0
  30. package/skills/aif-fix/SKILL.md +22 -0
  31. package/skills/aif-grounded/SKILL.md +22 -0
  32. package/skills/aif-implement/SKILL.md +62 -1
  33. package/skills/aif-improve/SKILL.md +20 -0
  34. package/skills/aif-loop/SKILL.md +20 -0
  35. package/skills/aif-plan/SKILL.md +65 -1
  36. package/skills/aif-plan/references/EXAMPLES.md +18 -0
  37. package/skills/aif-plan/references/TASK-FORMAT.md +14 -0
  38. package/skills/aif-review/SKILL.md +40 -0
  39. package/skills/aif-roadmap/SKILL.md +21 -0
  40. package/skills/aif-rules/SKILL.md +23 -0
  41. package/skills/aif-security-checklist/SKILL.md +25 -0
  42. package/skills/aif-skill-generator/SKILL.md +23 -0
  43. package/skills/aif-skill-generator/scripts/validate.sh +4 -4
  44. package/skills/aif-verify/SKILL.md +93 -1
  45. package/skills/aif-verify/references/CONTEXT-GATES-AND-OWNERSHIP.md +75 -0
@@ -0,0 +1,384 @@
1
+ ---
2
+ name: aif-explore
3
+ description: Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
4
+ argument-hint: "[topic or plan name]"
5
+ allowed-tools: Read Glob Grep Write Edit Bash AskUserQuestion Questions
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ Enter explore mode. Think deeply. Visualize freely. Follow the conversation wherever it goes.
10
+
11
+ **IMPORTANT: Explore mode is for thinking, not implementing.** You may read files, search code, and investigate the codebase, but you must NEVER implement features or modify project code. If the user asks to implement something, remind them to exit explore mode first (e.g., start with `/aif-plan`). If the user asks to persist exploration context, write/edit **only** `.ai-factory/RESEARCH.md` (this is capturing thinking, not implementing).
12
+
13
+ **This is a stance, not a workflow.** There are no fixed steps, no required sequence, no mandatory outputs. You're a thinking partner helping the user explore.
14
+
15
+ ---
16
+
17
+ ## Artifact Ownership
18
+
19
+ - Primary ownership in explore mode: `.ai-factory/RESEARCH.md` only.
20
+ - All other context artifacts (`DESCRIPTION.md`, `ARCHITECTURE.md`, `ROADMAP.md`, `RULES.md`, plan files) are read-only in this mode.
21
+ - If a discovery should affect another artifact, capture it in RESEARCH now and route follow-up to the owner command later.
22
+
23
+ ---
24
+
25
+ ## The Stance
26
+
27
+ - **Curious, not prescriptive** - Ask questions that emerge naturally, don't follow a script
28
+ - **Open threads, not interrogations** - Surface multiple interesting directions and let the user follow what resonates. Don't funnel them through a single path of questions.
29
+ - **Visual** - Use ASCII diagrams liberally when they'd help clarify thinking
30
+ - **Adaptive** - Follow interesting threads, pivot when new information emerges
31
+ - **Patient** - Don't rush to conclusions, let the shape of the problem emerge
32
+ - **Grounded** - Explore the actual codebase when relevant, don't just theorize
33
+
34
+ ---
35
+
36
+ ## What You Might Do
37
+
38
+ Depending on what the user brings, you might:
39
+
40
+ **Explore the problem space**
41
+ - Ask clarifying questions that emerge from what they said
42
+ - Challenge assumptions
43
+ - Reframe the problem
44
+ - Find analogies
45
+
46
+ **Investigate the codebase**
47
+ - Map existing architecture relevant to the discussion
48
+ - Find integration points
49
+ - Identify patterns already in use
50
+ - Surface hidden complexity
51
+
52
+ **Compare options**
53
+ - Brainstorm multiple approaches
54
+ - Build comparison tables
55
+ - Sketch tradeoffs
56
+ - Recommend a path (if asked)
57
+
58
+ **Visualize**
59
+ ```
60
+ +-----------------------------------------+
61
+ | Use ASCII diagrams liberally |
62
+ +-----------------------------------------+
63
+ | |
64
+ | +--------+ +--------+ |
65
+ | | State |-------->| State | |
66
+ | | A | | B | |
67
+ | +--------+ +--------+ |
68
+ | |
69
+ | System diagrams, state machines, |
70
+ | data flows, architecture sketches, |
71
+ | dependency graphs, comparison tables |
72
+ | |
73
+ +-----------------------------------------+
74
+ ```
75
+
76
+ **Surface risks and unknowns**
77
+ - Identify what could go wrong
78
+ - Find gaps in understanding
79
+ - Suggest spikes or investigations
80
+
81
+ ---
82
+
83
+ ## AI Factory Context
84
+
85
+ You have access to AI Factory's project context. Use it naturally, don't force it.
86
+
87
+ **Read `.ai-factory/skill-context/aif-explore/SKILL.md`** — MANDATORY if the file exists.
88
+
89
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
90
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
91
+
92
+ **How to apply skill-context rules:**
93
+ - Treat them as **project-level overrides** for this skill's general instructions
94
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
95
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
96
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
97
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
98
+ they exist because the project's experience proved the default insufficient
99
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including exploration
100
+ summaries, diagrams, and any file updates (DESCRIPTION.md, ARCHITECTURE.md). If a skill-context
101
+ rule says "exploration MUST cover X" or "summary MUST include Y" — you MUST comply. Producing
102
+ output that ignores skill-context rules is a bug.
103
+
104
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
105
+ If any rule is violated — fix the output before presenting it to the user.
106
+
107
+ ### Check for context
108
+
109
+ At the start, read these files if present:
110
+
111
+ - `.ai-factory/DESCRIPTION.md` — project description, tech stack, constraints
112
+ - `.ai-factory/ARCHITECTURE.md` — architecture decisions, folder structure
113
+ - `.ai-factory/RULES.md` — project conventions and rules
114
+ - `.ai-factory/RESEARCH.md` — persisted exploration notes (so you can `/clear` and still keep context)
115
+ - `.ai-factory/PLAN.md` — active fast plan (if any)
116
+ - `.ai-factory/plans/<branch>.md` — active full plans (if any)
117
+ - `.ai-factory/ROADMAP.md` — strategic milestones (if any)
118
+
119
+ This tells you:
120
+ - What the project is about
121
+ - What conventions to follow
122
+ - If there's active work in progress
123
+ - Any prior exploration context worth carrying into planning
124
+
125
+ ### Input handling
126
+
127
+ The argument after `/aif-explore` can be:
128
+ - A vague idea: "real-time collaboration"
129
+ - A specific problem: "the auth system is getting unwieldy"
130
+ - A plan name: to explore in context of `.ai-factory/plans/<name>.md`
131
+ - A comparison: "postgres vs sqlite for this"
132
+ - Nothing: just enter explore mode
133
+
134
+ ### When no plan exists
135
+
136
+ Think freely. When insights crystallize, you might offer:
137
+
138
+ - "This feels solid enough to plan. Want me to start `/aif-plan`?"
139
+ - Or keep exploring - no pressure to formalize
140
+
141
+ ### When a plan exists
142
+
143
+ If the user mentions a plan or you detect one is relevant:
144
+
145
+ 1. **Read existing plan for context**
146
+ - `.ai-factory/PLAN.md` (fast mode)
147
+ - `.ai-factory/plans/<branch>.md` (full mode)
148
+
149
+ 2. **Reference it naturally in conversation**
150
+ - "Your plan mentions adding Redis, but we just realized SQLite fits better..."
151
+ - "Task 3 scopes this to premium users, but we're now thinking everyone..."
152
+
153
+ 3. **Offer to capture when decisions are made**
154
+
155
+ Default in explore mode: capture everything in `.ai-factory/RESEARCH.md` so it survives `/clear`.
156
+ Later (during planning), you can migrate stabilized decisions into the appropriate context file.
157
+
158
+ | Insight Type | Capture Now (Explore) | Later (Optional) |
159
+ |--------------|------------------------|------------------|
160
+ | New requirement | `.ai-factory/RESEARCH.md` | `.ai-factory/DESCRIPTION.md` |
161
+ | Architecture decision | `.ai-factory/RESEARCH.md` | `.ai-factory/ARCHITECTURE.md` |
162
+ | Project convention | `.ai-factory/RESEARCH.md` | `.ai-factory/RULES.md` |
163
+ | Strategic direction | `.ai-factory/RESEARCH.md` | `.ai-factory/ROADMAP.md` |
164
+ | Assumption invalidated | `.ai-factory/RESEARCH.md` | Relevant file |
165
+ | Exploration context (persisted) | `.ai-factory/RESEARCH.md` | (keep in RESEARCH) |
166
+ | New task/feature | Run `/aif-plan` | `.ai-factory/PLAN.md` or `.ai-factory/plans/<branch>.md` |
167
+
168
+ Example offers:
169
+ - "Want me to save this to `.ai-factory/RESEARCH.md` so you can `/clear` and come back later?"
170
+ - "That's an architecture decision — save it to RESEARCH now and we can migrate it to ARCHITECTURE during planning."
171
+
172
+ 4. **The user decides** - Offer and move on. Don't pressure. Don't auto-capture.
173
+
174
+ ### Optional: Persist exploration context (`.ai-factory/RESEARCH.md`)
175
+
176
+ If the conversation is crystallizing (you're about to plan, you want to `/clear`, or you want to continue later), offer to save a compact, durable research snapshot.
177
+
178
+ **Hard rule in explore mode:** If the user chooses to save, you may write/edit **only** `.ai-factory/RESEARCH.md` (and create the `.ai-factory/` directory if missing). Do not write or modify any other project files.
179
+
180
+ Ask:
181
+
182
+ ```
183
+ Save these exploration results to .ai-factory/RESEARCH.md so we can /clear and /aif-plan can reuse them?
184
+
185
+ Options:
186
+ 1. Yes — update Active Summary + append a new Session (recommended)
187
+ 2. Yes — update Active Summary only
188
+ 3. No
189
+ ```
190
+
191
+ If user selects (1) or (2):
192
+ - Ensure `.ai-factory/` exists (`mkdir -p .ai-factory`)
193
+ - If `.ai-factory/RESEARCH.md` does not exist, create it with this skeleton:
194
+
195
+ ```markdown
196
+ # Research
197
+
198
+ Updated: YYYY-MM-DD HH:MM
199
+ Status: active
200
+
201
+ ## Active Summary (input for /aif-plan)
202
+ <!-- aif:active-summary:start -->
203
+ Topic:
204
+ Goal:
205
+ Constraints:
206
+ Decisions:
207
+ Open questions:
208
+ Success signals:
209
+ Next step:
210
+ <!-- aif:active-summary:end -->
211
+
212
+ ## Sessions
213
+ <!-- aif:sessions:start -->
214
+ <!-- aif:sessions:end -->
215
+ ```
216
+
217
+ - Update the `Updated:` timestamp
218
+ - Replace only the content inside `aif:active-summary:start/end`
219
+ - If user selected option (1), append a new session entry just before `<!-- aif:sessions:end -->`:
220
+
221
+ ```markdown
222
+ ### YYYY-MM-DD HH:MM — <short title>
223
+ What changed:
224
+ Key notes:
225
+ Links (paths):
226
+ ```
227
+
228
+ Keep prior sessions verbatim (do not rewrite history).
229
+
230
+ ---
231
+
232
+ ## What You Don't Have To Do
233
+
234
+ - Follow a script
235
+ - Ask the same questions every time
236
+ - Produce a specific artifact
237
+ - Reach a conclusion
238
+ - Stay on topic if a tangent is valuable
239
+ - Be brief (this is thinking time)
240
+
241
+ ---
242
+
243
+ ## Handling Different Entry Points
244
+
245
+ **User brings a vague idea:**
246
+ ```
247
+ User: I'm thinking about adding real-time collaboration
248
+
249
+ You: Real-time collab is a big space. Let me think about this...
250
+
251
+ COLLABORATION SPECTRUM
252
+
253
+ Awareness Coordination Sync
254
+ | | |
255
+ v v v
256
+ +--------+ +--------+ +--------+
257
+ |Presence| |Cursors | | CRDT |
258
+ | "3 | | Multi | |Conflict|
259
+ |online" | | select | | free |
260
+ +--------+ +--------+ +--------+
261
+ | | |
262
+ trivial moderate complex
263
+
264
+ Where's your head at?
265
+ ```
266
+
267
+ **User brings a specific problem:**
268
+ ```
269
+ User: The auth system is a mess
270
+
271
+ You: [reads codebase]
272
+
273
+ +---------------------------------------------+
274
+ | CURRENT AUTH FLOW |
275
+ +---------------------------------------------+
276
+ |
277
+ +-------------+-------------+
278
+ v v v
279
+ +---------+ +---------+ +---------+
280
+ | Google | | GitHub | | Email |
281
+ | OAuth | | OAuth | | Magic |
282
+ +----+----+ +----+----+ +----+----+
283
+ | | |
284
+ +-------------+-------------+
285
+ v
286
+ +-----------+
287
+ | Session |
288
+ +-----+-----+
289
+ |
290
+ v
291
+ +-----------+
292
+ | Perms |
293
+ +-----------+
294
+
295
+ I see three tangles. Which one's burning?
296
+ ```
297
+
298
+ **User is stuck mid-implementation:**
299
+ ```
300
+ User: /aif-explore add-auth-system
301
+ The OAuth integration is more complex than expected
302
+
303
+ You: [reads plan from .ai-factory/plans/add-auth-system.md]
304
+
305
+ You're on task 4: "Implement OAuth flow"
306
+
307
+ Let me trace what's involved...
308
+
309
+ [draws diagram, explores options, suggests paths]
310
+
311
+ Want to update the plan to reflect this?
312
+ Or add a spike task to investigate?
313
+ ```
314
+
315
+ **User wants to compare options:**
316
+ ```
317
+ User: Should we use Postgres or SQLite?
318
+
319
+ You: Generic answer is boring. What's the context?
320
+
321
+ User: A CLI tool that tracks local dev environments
322
+
323
+ You: That changes everything.
324
+
325
+ +---------------------------------------------+
326
+ | CLI TOOL DATA STORAGE |
327
+ +---------------------------------------------+
328
+
329
+ Key constraints:
330
+ * No daemon running
331
+ * Must work offline
332
+ * Single user
333
+
334
+ SQLite Postgres
335
+ Deployment embedded ok needs server no
336
+ Offline yes ok no no
337
+ Single file yes ok no no
338
+
339
+ SQLite. Not even close.
340
+
341
+ Unless... is there a sync component?
342
+ ```
343
+
344
+ ---
345
+
346
+ ## Ending Discovery
347
+
348
+ There's no required ending. Discovery might:
349
+
350
+ - **Flow into action**: "Ready to plan? Run `/aif-plan`"
351
+ - **Result in context updates**: "Updated ARCHITECTURE.md with these decisions"
352
+ - **Just provide clarity**: User has what they need, moves on
353
+ - **Continue later**: "We can pick this up anytime"
354
+
355
+ When it feels like things are crystallizing, you might summarize:
356
+
357
+ ```
358
+ ## What We Figured Out
359
+
360
+ **The problem**: [crystallized understanding]
361
+
362
+ **The approach**: [if one emerged]
363
+
364
+ **Open questions**: [if any remain]
365
+
366
+ **Next steps** (if ready):
367
+ - Create a plan: /aif-plan [fast|full] <description>
368
+ - Keep exploring: just keep talking
369
+ ```
370
+
371
+ But this summary is optional. Sometimes the thinking IS the value.
372
+
373
+ ---
374
+
375
+ ## Guardrails
376
+
377
+ - **Don't implement** - Never write code or implement features. Updating AI Factory context files is fine, writing application code is not.
378
+ - **Don't fake understanding** - If something is unclear, dig deeper
379
+ - **Don't rush** - Discovery is thinking time, not task time
380
+ - **Don't force structure** - Let patterns emerge naturally
381
+ - **Don't auto-capture** - Offer to save insights, don't just do it
382
+ - **Do visualize** - A good diagram is worth many paragraphs
383
+ - **Do explore the codebase** - Ground discussions in reality
384
+ - **Do question assumptions** - Including the user's and your own
@@ -48,6 +48,26 @@ Fix a specific bug or problem in the codebase. Supports two modes: immediate fix
48
48
  - If the current problem resembles a past patch — apply the same approach or avoid the same mistakes
49
49
  - This is your accumulated experience. Use it.
50
50
 
51
+ **Read `.ai-factory/skill-context/aif-fix/SKILL.md`** — MANDATORY if the file exists.
52
+
53
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
54
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
55
+
56
+ **How to apply skill-context rules:**
57
+ - Treat them as **project-level overrides** for this skill's general instructions
58
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
59
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
60
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
61
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
62
+ they exist because the project's experience proved the default insufficient
63
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the FIX_PLAN.md
64
+ template and patch files. The FIX_PLAN.md template in Step 1.1 is a **base structure**. If a
65
+ skill-context rule says "steps MUST include X" or "plan MUST have section Y" — you MUST augment
66
+ the template accordingly. Generating a FIX_PLAN.md or patch that violates skill-context rules is a bug.
67
+
68
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
69
+ If any rule is violated — fix the output before presenting it to the user.
70
+
51
71
  ### Step 1: Understand the Problem & Choose Mode
52
72
 
53
73
  From `$ARGUMENTS`, identify:
@@ -324,6 +344,8 @@ function fixedFunction(input) {
324
344
  8. **Minimal changes** - Don't refactor unrelated code
325
345
  9. **One fix at a time** - Don't scope creep
326
346
  10. **Clean up** - Delete FIX_PLAN.md after successful fix execution
347
+ 11. **Ownership boundary** - `/aif-fix` owns `.ai-factory/FIX_PLAN.md` and `.ai-factory/patches/*.md`; treat `.ai-factory/DESCRIPTION.md`, roadmap/rules/architecture context artifacts as read-only unless the user explicitly requests otherwise
348
+ 12. **Logging scope** - Keep `[FIX]` logging requirements for fixes; context-gate outputs in this command should use `WARN`/`ERROR` and must not change global logging policy in other skills
327
349
 
328
350
  ## After Fixing
329
351
 
@@ -24,6 +24,28 @@ Use when:
24
24
 
25
25
  ## Workflow
26
26
 
27
+ ### Step 0: Load Skill Context
28
+
29
+ **Read `.ai-factory/skill-context/aif-grounded/SKILL.md`** — MANDATORY if the file exists.
30
+
31
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
32
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
33
+
34
+ **How to apply skill-context rules:**
35
+ - Treat them as **project-level overrides** for this skill's general instructions
36
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
37
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
38
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
39
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
40
+ they exist because the project's experience proved the default insufficient
41
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the response
42
+ format, evidence requirements, and confidence assessment. If a skill-context rule says "analysis
43
+ MUST include X" or "confidence MUST account for Y" — you MUST comply. Producing an analysis
44
+ that ignores skill-context rules is a bug.
45
+
46
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
47
+ If any rule is violated — fix the output before presenting it to the user.
48
+
27
49
  ### Step 1: Classify the request
28
50
 
29
51
  Classify into one of:
@@ -3,7 +3,7 @@ name: aif-implement
3
3
  description: Execute implementation tasks from the current plan. Works through tasks sequentially, marks completion, and preserves progress for continuation across sessions. Use when user says "implement", "start coding", "execute plan", or "continue implementation".
4
4
  argument-hint: '[task-id or "status"]'
5
5
  allowed-tools: Read Write Edit Glob Grep Bash TaskList TaskGet TaskUpdate AskUserQuestion Questions
6
- disable-model-invocation: true
6
+ disable-model-invocation: false
7
7
  ---
8
8
 
9
9
  # Implement - Execute Task Plan
@@ -115,6 +115,26 @@ Based on choice:
115
115
  - Apply proper error handling and logging as specified
116
116
  - **Avoid pitfalls documented in patches** — don't repeat past mistakes
117
117
 
118
+ **Read `.ai-factory/skill-context/aif-implement/SKILL.md`** — MANDATORY if the file exists.
119
+
120
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
121
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
122
+
123
+ **How to apply skill-context rules:**
124
+ - Treat them as **project-level overrides** for this skill's general instructions
125
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
126
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
127
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
128
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
129
+ they exist because the project's experience proved the default insufficient
130
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the code
131
+ you write and how you update plan checkboxes. If a skill-context rule says "code MUST follow X"
132
+ or "implementation MUST include Y" — you MUST comply. Writing code that violates skill-context
133
+ rules is a bug.
134
+
135
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
136
+ If any rule is violated — fix the output before presenting it to the user.
137
+
118
138
  ### Step 0.1: Find Plan File
119
139
 
120
140
  **Check for plan files in this order:**
@@ -302,10 +322,44 @@ What's next?
302
322
 
303
323
  If `.ai-factory/ROADMAP.md` exists:
304
324
  1. Read it
325
+ 1.1. If the plan file includes `## Roadmap Linkage` with a non-`none` milestone, prefer that milestone for completion marking
305
326
  2. Check if the completed work corresponds to any unchecked milestone
306
327
  3. If yes — mark it `[x]` and add entry to the Completed table with today's date
307
328
  4. Tell the user which milestone was marked done
308
329
 
330
+ ### Context Maintenance (Artifacts)
331
+
332
+ Only do this step when there is something concrete to capture.
333
+
334
+ **DESCRIPTION.md (allowed in this command):**
335
+ - If this plan introduced new dependencies/integrations or changed the stack, update `.ai-factory/DESCRIPTION.md` with factual deltas only.
336
+ - Do not rewrite unrelated sections.
337
+
338
+ **ARCHITECTURE.md + AGENTS.md (allowed in this command):**
339
+ - If new modules/layers/folders were added (or dependency rules changed), update `.ai-factory/ARCHITECTURE.md` to reflect the new structure and constraints.
340
+ - If you maintain `AGENTS.md` structure maps or entry points, refresh them only when they are now incorrect.
341
+
342
+ **ROADMAP.md (allowed, limited):**
343
+ - This command may mark milestone completion when evidence is clear.
344
+ - If milestone mapping is ambiguous, emit `WARN [roadmap] ...` and suggest the owner command:
345
+ - `/aif-roadmap check`
346
+ - or `/aif-roadmap <short update request>`
347
+
348
+ **RULES.md (NOT allowed in this command):**
349
+ - Never edit `.ai-factory/RULES.md` from `/aif-implement`.
350
+ - If you discovered repeatable conventions/pitfalls during implementation, propose up to 3 candidate rules and ask the user to add them via `/aif-rules`.
351
+ - Do not invoke `/aif-rules` automatically (it is user-invoked).
352
+
353
+ If candidate rules exist:
354
+
355
+ ```
356
+ AskUserQuestion: Capture new project rules in `.ai-factory/RULES.md`?
357
+
358
+ Options:
359
+ 1. Yes — output `/aif-rules ...` commands (recommended)
360
+ 2. No — skip
361
+ ```
362
+
309
363
  ### Context Cleanup
310
364
 
311
365
  Context is heavy after implementation. All code changes are saved — suggest freeing space:
@@ -477,6 +531,13 @@ Shows progress without executing.
477
531
  - ❌ Mark incomplete tasks as done
478
532
  - ❌ Violate `.ai-factory/ARCHITECTURE.md` conventions for file placement and module boundaries
479
533
 
534
+ ## Artifact Ownership Boundaries
535
+
536
+ - Primary ownership in this command: task execution state and plan progress checkboxes.
537
+ - Allowed context artifact updates: `.ai-factory/DESCRIPTION.md`, `.ai-factory/ARCHITECTURE.md`, and roadmap milestone completion in `.ai-factory/ROADMAP.md` when implementation evidence justifies it.
538
+ - Read-only context in this command by default: `.ai-factory/RULES.md`, `.ai-factory/RESEARCH.md`.
539
+ - Context-gate findings should be communicated as `WARN`/`ERROR` outputs only; this does not replace the required verbose implementation logging rules below.
540
+
480
541
  For progress display format, blocker handling, session continuity examples, and full flow examples → see `references/IMPLEMENTATION-GUIDE.md`
481
542
 
482
543
  ## Critical Rules
@@ -79,6 +79,26 @@ If patches exist, read them to understand:
79
79
  - What patterns to avoid
80
80
  - What the plan should account for
81
81
 
82
+ **Read `.ai-factory/skill-context/aif-improve/SKILL.md`** — MANDATORY if the file exists.
83
+
84
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
85
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
86
+
87
+ **How to apply skill-context rules:**
88
+ - Treat them as **project-level overrides** for this skill's general instructions
89
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
90
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
91
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
92
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
93
+ they exist because the project's experience proved the default insufficient
94
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the Plan
95
+ Refinement Report and any plan modifications. If a skill-context rule says "tasks MUST include X"
96
+ or "plan structure MUST have Y" — you MUST apply these when refining. Generating a refinement
97
+ report that ignores skill-context rules is a bug.
98
+
99
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
100
+ If any rule is violated — fix the output before presenting it to the user.
101
+
82
102
  **1.4: Load current task list**
83
103
 
84
104
  ```
@@ -93,6 +93,26 @@ Read these files if present:
93
93
 
94
94
  Use them to keep outputs aligned with project conventions.
95
95
 
96
+ **Read `.ai-factory/skill-context/aif-loop/SKILL.md`** — MANDATORY if the file exists.
97
+
98
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
99
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
100
+
101
+ **How to apply skill-context rules:**
102
+ - Treat them as **project-level overrides** for this skill's general instructions
103
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
104
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
105
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
106
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
107
+ they exist because the project's experience proved the default insufficient
108
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the generated
109
+ artifact, run state, and evaluation criteria. If a skill-context rule says "artifact MUST include X"
110
+ or "evaluation MUST check Y" — you MUST comply. Producing loop outputs that violate skill-context
111
+ rules is a bug.
112
+
113
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
114
+ If any rule is violated — fix the output before presenting it to the user.
115
+
96
116
  ## Step 0.1: Handle Non-Iteration Commands
97
117
 
98
118
  If command is `status`, `stop`, `list`, `history`, or `clean`, execute and stop: