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.
- package/README.md +5 -1
- package/dist/cli/commands/extension.js +10 -3
- package/dist/cli/commands/extension.js.map +1 -1
- package/dist/core/agents.js +2 -2
- package/dist/core/agents.js.map +1 -1
- package/dist/core/extensions.d.ts +2 -1
- package/dist/core/extensions.d.ts.map +1 -1
- package/dist/core/extensions.js.map +1 -1
- package/dist/core/mcp.d.ts +2 -2
- package/dist/core/mcp.d.ts.map +1 -1
- package/dist/core/mcp.js +67 -10
- package/dist/core/mcp.js.map +1 -1
- package/dist/core/transformer.d.ts.map +1 -1
- package/dist/core/transformer.js +1 -0
- package/dist/core/transformer.js.map +1 -1
- package/dist/core/transformers/antigravity.d.ts.map +1 -1
- package/dist/core/transformers/antigravity.js +2 -0
- package/dist/core/transformers/antigravity.js.map +1 -1
- package/package.json +1 -1
- package/skills/aif/SKILL.md +29 -0
- package/skills/aif-architecture/SKILL.md +26 -0
- package/skills/aif-best-practices/SKILL.md +20 -0
- package/skills/aif-build-automation/SKILL.md +21 -1
- package/skills/aif-ci/SKILL.md +20 -0
- package/skills/aif-commit/SKILL.md +42 -12
- package/skills/aif-dockerize/SKILL.md +22 -1
- package/skills/aif-docs/SKILL.md +23 -1
- package/skills/aif-evolve/SKILL.md +352 -139
- package/skills/aif-explore/SKILL.md +384 -0
- package/skills/aif-fix/SKILL.md +22 -0
- package/skills/aif-grounded/SKILL.md +22 -0
- package/skills/aif-implement/SKILL.md +62 -1
- package/skills/aif-improve/SKILL.md +20 -0
- package/skills/aif-loop/SKILL.md +20 -0
- package/skills/aif-plan/SKILL.md +65 -1
- package/skills/aif-plan/references/EXAMPLES.md +18 -0
- package/skills/aif-plan/references/TASK-FORMAT.md +14 -0
- package/skills/aif-review/SKILL.md +40 -0
- package/skills/aif-roadmap/SKILL.md +21 -0
- package/skills/aif-rules/SKILL.md +23 -0
- package/skills/aif-security-checklist/SKILL.md +25 -0
- package/skills/aif-skill-generator/SKILL.md +23 -0
- package/skills/aif-skill-generator/scripts/validate.sh +4 -4
- package/skills/aif-verify/SKILL.md +93 -1
- package/skills/aif-verify/references/CONTEXT-GATES-AND-OWNERSHIP.md +75 -0
|
@@ -20,15 +20,81 @@ analyze recurring problems, tech-specific pitfalls, project conventions
|
|
|
20
20
|
enhance skills with project-specific rules, guards, and patterns
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
## Critical: Never Edit Built-in Skills Directly
|
|
24
|
+
|
|
25
|
+
**NEVER modify any files inside built-in `aif-*` skill directories** (`skills/aif-*/`).
|
|
26
|
+
All files in these directories are owned by ai-factory and will be overwritten on update — any direct edits will be lost.
|
|
27
|
+
|
|
28
|
+
**ALWAYS write project-specific rules to skill-context:**
|
|
29
|
+
```
|
|
30
|
+
.ai-factory/skill-context/<skill-name>/SKILL.md
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This is the ONLY correct target for built-in skill improvements. No exceptions.
|
|
34
|
+
|
|
23
35
|
## Workflow
|
|
24
36
|
|
|
25
|
-
### Step 0: Load Context
|
|
37
|
+
### Step 0: Resolve Target & Load Context
|
|
38
|
+
|
|
39
|
+
#### Step 0.1: Resolve Target
|
|
40
|
+
|
|
41
|
+
**Normalize skill name from `$ARGUMENTS`:**
|
|
42
|
+
|
|
43
|
+
| User input | Resolved skill name |
|
|
44
|
+
|--------------------|---------------------|
|
|
45
|
+
| `plan` | `aif-plan` |
|
|
46
|
+
| `aif-plan` | `aif-plan` |
|
|
47
|
+
| `/aif-plan` | `aif-plan` |
|
|
48
|
+
| `my-custom-skill` | `my-custom-skill` |
|
|
49
|
+
|
|
50
|
+
Rule: first, strip any leading `/` from the argument. Then: if the argument does not start with `aif-` AND a skill named `aif-<argument>` exists — use `aif-<argument>`. Otherwise use as-is.
|
|
51
|
+
|
|
52
|
+
**After resolving the skill name:** verify that the resolved skill actually exists
|
|
53
|
+
(check `{{skills_dir}}/<resolved-name>/SKILL.md` or `skills/<resolved-name>/SKILL.md`).
|
|
54
|
+
If the skill is not found → report an error to the user and stop:
|
|
55
|
+
"Skill '<resolved-name>' not found. Use `/aif-evolve` without arguments to evolve
|
|
56
|
+
all skills, or specify a valid skill name."
|
|
57
|
+
|
|
58
|
+
**Determine which skills to evolve from `$ARGUMENTS`:**
|
|
59
|
+
- If `$ARGUMENTS` contains a specific skill name → evolve only that skill
|
|
60
|
+
- If `$ARGUMENTS` is "all" or empty → evolve all installed skills
|
|
61
|
+
|
|
62
|
+
#### Step 0.2: Load Context
|
|
26
63
|
|
|
27
64
|
**Read `.ai-factory/DESCRIPTION.md`** to understand:
|
|
28
65
|
- Tech stack
|
|
29
66
|
- Architecture
|
|
30
67
|
- Conventions
|
|
31
68
|
|
|
69
|
+
**Read skill-context files for target skills:**
|
|
70
|
+
|
|
71
|
+
- If evolving a **specific skill** (e.g., `/aif-evolve plan`) → read only:
|
|
72
|
+
1. `.ai-factory/skill-context/aif-plan/SKILL.md` (target skill's context)
|
|
73
|
+
2. `.ai-factory/skill-context/aif-evolve/SKILL.md` (evolve's own context, if exists
|
|
74
|
+
**and** target skill is not `aif-evolve` itself)
|
|
75
|
+
- If evolving **all skills** (`/aif-evolve` or `/aif-evolve all`) → read all context files:
|
|
76
|
+
`Glob: .ai-factory/skill-context/*/SKILL.md` (this already includes evolve's own context — do NOT read it separately)
|
|
77
|
+
|
|
78
|
+
These contain previously accumulated project-specific rules for built-in skills.
|
|
79
|
+
Keep them in memory — they affect gap analysis in Step 5.
|
|
80
|
+
|
|
81
|
+
Skill-context rules are **project-level overrides** — when they conflict with the base SKILL.md of the target skill, skill-context wins (same principle as nested CLAUDE.md files).
|
|
82
|
+
|
|
83
|
+
**How to apply evolve's own skill-context rules (`aif-evolve`):**
|
|
84
|
+
- Treat them as **project-level overrides** for this skill's general instructions
|
|
85
|
+
- When a skill-context rule conflicts with a general rule written in this SKILL.md,
|
|
86
|
+
**the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
|
|
87
|
+
- When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
|
|
88
|
+
- Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
|
|
89
|
+
they exist because the project's experience proved the default insufficient
|
|
90
|
+
- **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the evolution
|
|
91
|
+
report, proposed improvements, skill-context file edits, and stale rule analysis. If a
|
|
92
|
+
skill-context rule says "evolve MUST prioritize X" or "report MUST include Y" — you MUST comply.
|
|
93
|
+
Producing evolution output that ignores skill-context rules is a bug.
|
|
94
|
+
|
|
95
|
+
**Enforcement:** After generating any output artifact, verify it against all skill-context rules.
|
|
96
|
+
If any rule is violated — fix the output before presenting it to the user.
|
|
97
|
+
|
|
32
98
|
### Step 1: Collect Intelligence
|
|
33
99
|
|
|
34
100
|
**1.1: Read all patches**
|
|
@@ -38,11 +104,28 @@ Glob: .ai-factory/patches/*.md
|
|
|
38
104
|
```
|
|
39
105
|
|
|
40
106
|
Read every patch. For each one, extract:
|
|
41
|
-
- **Problem
|
|
42
|
-
- **Root cause
|
|
43
|
-
- **Prevention
|
|
107
|
+
- **Problem categories** (null-check, async, validation, types, API, DB, etc.)
|
|
108
|
+
- **Root cause patterns** (what classes of mistake were made)
|
|
109
|
+
- **Prevention points** — each independent actionable rule from the Prevention/Solution section.
|
|
110
|
+
A single patch often contains **multiple independent prevention points targeting different skills**.
|
|
111
|
+
Extract EACH one separately with its target skill(s). Do NOT treat a patch as a single unit.
|
|
44
112
|
- **Tags**
|
|
45
113
|
|
|
114
|
+
**Build a Prevention Point Registry** — a flat list of ALL extracted prevention points across
|
|
115
|
+
all patches. This registry is the primary input for Step 5 gap analysis.
|
|
116
|
+
|
|
117
|
+
```
|
|
118
|
+
| # | Patch | Prevention Point (specific action) | Target Skill(s) |
|
|
119
|
+
|---|-------|------------------------------------|-----------------|
|
|
120
|
+
| 1 | <patch-file> | <concrete action to enforce> | <skill-1> |
|
|
121
|
+
| 2 | <patch-file> | <different action from same patch> | <skill-1>, <skill-2> |
|
|
122
|
+
| 3 | <other-patch> | <action> | <skill-3> |
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**CRITICAL:** A patch with 5 prevention points produces 5 rows, not 1.
|
|
126
|
+
If a prevention point targets 2 skills, it appears once but with both skills listed —
|
|
127
|
+
and EACH skill must be checked independently in Step 5.
|
|
128
|
+
|
|
46
129
|
**1.2: Aggregate patterns**
|
|
47
130
|
|
|
48
131
|
Group patches by tags and categories. Identify:
|
|
@@ -59,79 +142,197 @@ Scan the project for patterns:
|
|
|
59
142
|
- Logging patterns (logger used, format, levels)
|
|
60
143
|
- Import conventions, file structure
|
|
61
144
|
|
|
62
|
-
|
|
145
|
+
**When evolving a specific skill**, focus convention scanning on areas relevant to that skill
|
|
146
|
+
(e.g., for `/aif-plan` — focus on file structure and naming; for `/aif-fix` — error handling and testing).
|
|
147
|
+
|
|
148
|
+
### Step 2: Read Target Skills
|
|
149
|
+
|
|
150
|
+
**Read ONLY the base SKILL.md files for target skills — not all skills.**
|
|
151
|
+
|
|
152
|
+
- If evolving a **specific skill** (e.g., `/aif-evolve plan`) → read only that one:
|
|
153
|
+
`Read: {{skills_dir}}/aif-plan/SKILL.md` (or `skills/aif-plan/SKILL.md` if not installed)
|
|
154
|
+
- If evolving **all skills** (`/aif-evolve` or `/aif-evolve all`) → read all:
|
|
155
|
+
`Glob: {{skills_dir}}/*/SKILL.md` (or `Glob: skills/*/SKILL.md` if not installed)
|
|
156
|
+
|
|
157
|
+
Keep loaded SKILL.md content in memory — Step 3 needs it for comparison (do NOT re-read).
|
|
158
|
+
|
|
159
|
+
### Step 3: Check for Stale Rules in Skill-Context
|
|
160
|
+
|
|
161
|
+
**When:** Run this step for every **target** `aif-*` skill that has a skill-context file.
|
|
63
162
|
|
|
64
|
-
**
|
|
163
|
+
**For each rule in `.ai-factory/skill-context/<skill-name>/SKILL.md`:**
|
|
164
|
+
|
|
165
|
+
**Scope constraint:** Step 3 can ONLY modify or remove skill-context files.
|
|
166
|
+
It must NEVER propose editing, deleting, or reverting base `skills/aif-*/` files.
|
|
167
|
+
Even if the base file contains errors or incomplete rules — that is outside evolve's scope.
|
|
168
|
+
|
|
169
|
+
1. Use the base `SKILL.md` already loaded in Step 2 (do NOT re-read the file).
|
|
170
|
+
2. Compare each skill-context rule against the base SKILL.md content:
|
|
65
171
|
|
|
66
|
-
|
|
67
|
-
|
|
172
|
+
**Case A — Base fully covers skill-context rule (equivalent or superset):**
|
|
173
|
+
The base SKILL.md now contains a rule that is equivalent to or MORE complete than
|
|
174
|
+
the skill-context rule.
|
|
175
|
+
This includes:
|
|
176
|
+
- Exact equivalent — same rule, same content
|
|
177
|
+
- Base is a superset — base has everything skill-context has, plus more
|
|
178
|
+
(e.g., skill-context has Wave 1+3, base now has Wave 1+2+3)
|
|
179
|
+
→ Do NOT auto-remove. Do NOT ask the user yet.
|
|
180
|
+
→ Collect for the report in Step 4 — include both rules and mark as
|
|
181
|
+
"Fully covered by base — recommend removing from skill-context".
|
|
182
|
+
Note: if user chooses to keep the skill-context rule, this is valid —
|
|
183
|
+
skill-context has priority over base, so keeping it acts as a guarantee
|
|
184
|
+
that the complete/correct version is always applied.
|
|
68
185
|
|
|
69
|
-
**
|
|
186
|
+
**Case B — Contradicting rule found in base SKILL.md:**
|
|
187
|
+
The base skill now has a rule that directly contradicts the skill-context rule.
|
|
188
|
+
→ Do NOT auto-remove. Do NOT ask the user yet.
|
|
189
|
+
→ Collect this conflict for the report in Step 4 — include both rules and mark as "Conflict — user decision required".
|
|
70
190
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
191
|
+
**Case C — Partial overlap (in either direction):**
|
|
192
|
+
The base SKILL.md and skill-context rule overlap, but NEITHER fully covers the other.
|
|
193
|
+
This includes:
|
|
194
|
+
- Base covers part of skill-context, but skill-context has unique parts too
|
|
195
|
+
- Skill-context covers part of base, but base has unique parts too
|
|
196
|
+
(e.g., skill-context has A→B→C, base has A→C→D — both have unique parts)
|
|
197
|
+
→ Do NOT auto-narrow. Analyze whether parts depend on each other
|
|
198
|
+
(ordering, prerequisites, data flow).
|
|
199
|
+
→ Collect this overlap for the report in Step 4 — include both rules, analysis, and mark as "Partial overlap — user decision required".
|
|
200
|
+
**Priority warning:** skill-context has priority over base on the same topic.
|
|
201
|
+
If user keeps skill-context as-is, the base's unique parts will likely be LOST
|
|
202
|
+
(AI uses skill-context version, ignores base version of the same rule).
|
|
203
|
+
Always explain this consequence in option descriptions.
|
|
74
204
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
205
|
+
**Case D — No overlap:**
|
|
206
|
+
The rule is still unique to the project context.
|
|
207
|
+
→ Keep as-is, no action needed.
|
|
208
|
+
|
|
209
|
+
### Step 4: Present & Resolve Stale Rules
|
|
79
210
|
|
|
80
|
-
|
|
211
|
+
**Skip this step** if no Case A/B/C rules were found in Step 3.
|
|
212
|
+
|
|
213
|
+
Present all stale rule findings using the stale rules report format
|
|
214
|
+
(Case A/B/C sections with base vs skill-context comparison).
|
|
215
|
+
|
|
216
|
+
**IMPORTANT: All decisions here affect ONLY skill-context files.**
|
|
217
|
+
Never propose editing, deleting, or reverting base `skills/aif-*/` files —
|
|
218
|
+
they are outside of evolve's scope.
|
|
219
|
+
|
|
220
|
+
#### Stale Rules Report Format
|
|
221
|
+
|
|
222
|
+
For each stale rule, present:
|
|
223
|
+
|
|
224
|
+
##### /aif-plan — Fully covered: [Rule Name]
|
|
225
|
+
- **Base SKILL.md says:** [base rule text]
|
|
226
|
+
- **Skill-context says:** [project rule text]
|
|
227
|
+
- **Decision required:** Keep in skill-context (has priority over base — ensures
|
|
228
|
+
the complete version is always applied) / Remove from skill-context (trust base) /
|
|
229
|
+
Rewrite skill-context rule
|
|
230
|
+
|
|
231
|
+
##### /aif-plan — Conflict: [Rule Name]
|
|
232
|
+
- **Base SKILL.md says:** [base rule text]
|
|
233
|
+
- **Skill-context says:** [project rule text]
|
|
234
|
+
- **Decision required:** Keep skill-context rule (has priority — base version will
|
|
235
|
+
be ignored) / Remove skill-context rule (trust base) / Rewrite skill-context rule
|
|
236
|
+
|
|
237
|
+
##### /aif-fix — Partial overlap: [Rule Name]
|
|
238
|
+
- **Base SKILL.md says:** [base rule text]
|
|
239
|
+
- **Skill-context says:** [project rule text]
|
|
240
|
+
- **Analysis:** [explain overlap and whether parts are independent or sequential]
|
|
241
|
+
- **Decision required:** Rewrite skill-context to include both unique parts
|
|
242
|
+
(recommended when parts are sequential) / Keep skill-context as-is (WARNING:
|
|
243
|
+
base's unique parts will be lost — skill-context has priority) / Narrow
|
|
244
|
+
skill-context to uncovered part / Remove from skill-context (trust base —
|
|
245
|
+
skill-context's unique parts will be lost)
|
|
246
|
+
|
|
247
|
+
#### Collecting Decisions
|
|
248
|
+
|
|
249
|
+
Use `AskUserQuestion` to collect stale rule decisions. Process in batches
|
|
250
|
+
of up to 3 decisions per `AskUserQuestion` call:
|
|
251
|
+
|
|
252
|
+
- Present first batch (up to 3 stale rules) → `AskUserQuestion`
|
|
253
|
+
- Get answers → apply decisions
|
|
254
|
+
- If more stale rules remain → present next batch → `AskUserQuestion`
|
|
255
|
+
- Repeat until all stale rules are resolved
|
|
256
|
+
|
|
257
|
+
**Do NOT proceed to Step 5 until all stale rule decisions are collected
|
|
258
|
+
and applied.** This determines the actual skill-context state for gap analysis.
|
|
259
|
+
|
|
260
|
+
### Step 5: Analyze Gaps
|
|
261
|
+
|
|
262
|
+
**Before analyzing gaps:** re-read skill-context files for target skills that were
|
|
263
|
+
modified in Step 4 (stale rule removals/rewrites). Do NOT use the version loaded
|
|
264
|
+
in Step 0.2 — it is outdated after Step 4 changes.
|
|
265
|
+
|
|
266
|
+
For each skill, consider the base SKILL.md AND its **current** skill-context file
|
|
267
|
+
(after stale rule decisions from Step 4 have been applied).
|
|
268
|
+
A gap only exists if NEITHER source covers it.
|
|
81
269
|
|
|
82
270
|
For each skill, identify what's missing based on collected intelligence:
|
|
83
271
|
|
|
84
|
-
**
|
|
272
|
+
**5.1: Patch-driven gaps (prevention-point-exhaustive)**
|
|
273
|
+
|
|
274
|
+
**CRITICAL: Check each prevention point × each target skill independently.**
|
|
275
|
+
|
|
276
|
+
Iterate over the Prevention Point Registry built in Step 1.1. For each row:
|
|
277
|
+
1. For EACH target skill listed in that row:
|
|
278
|
+
- Check if the base SKILL.md already covers this **specific** prevention action
|
|
279
|
+
- Check if the skill-context already has a rule covering this **specific** prevention action
|
|
280
|
+
2. A prevention point is "covered" for a skill ONLY when there is a rule that addresses
|
|
281
|
+
the **specific action described** — not merely when the same patch filename appears in
|
|
282
|
+
a Source field.
|
|
283
|
+
3. Mark uncovered (prevention_point, skill) pairs as gaps → these become inputs for Step 6.
|
|
85
284
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
285
|
+
**Common trap — Source reference ≠ full coverage:**
|
|
286
|
+
Finding `Source: <patch-filename>` in a skill-context rule means ONE rule was derived
|
|
287
|
+
from that patch. It does **NOT** mean ALL prevention points from that patch are covered.
|
|
288
|
+
A patch with 5 prevention points may have only 1 covered. Always verify the **content**
|
|
289
|
+
of the existing rule against each prevention point individually.
|
|
91
290
|
|
|
92
|
-
**
|
|
291
|
+
**Verification:** After completing the registry scan, count: total prevention points,
|
|
292
|
+
covered, uncovered. If uncovered > 0 — these are gaps for Step 6.
|
|
293
|
+
|
|
294
|
+
**5.2: Tech-stack gaps**
|
|
93
295
|
|
|
94
296
|
Compare project tech stack against skill instructions:
|
|
95
297
|
- Skills reference generic patterns but project uses specific framework? → Add framework-specific guidance
|
|
96
298
|
- Project uses TypeScript but skills show JS examples? → Update examples
|
|
97
299
|
- Project uses specific ORM (Prisma, Eloquent)? → Add ORM-specific patterns
|
|
98
300
|
|
|
99
|
-
**
|
|
301
|
+
**5.3: Convention gaps**
|
|
100
302
|
|
|
101
303
|
Compare project conventions against skill instructions:
|
|
102
304
|
- Project has specific error handling pattern? → Skills should enforce it
|
|
103
305
|
- Project uses specific logger? → Skills should reference it
|
|
104
306
|
- Project has specific file structure? → Skills should follow it
|
|
105
307
|
|
|
106
|
-
### Step
|
|
308
|
+
### Step 6: Generate Improvements
|
|
107
309
|
|
|
108
310
|
For each gap found, create a concrete improvement:
|
|
109
311
|
|
|
110
|
-
```markdown
|
|
111
|
-
## Improvement: [skill-name]
|
|
112
|
-
|
|
113
|
-
### What
|
|
114
|
-
[Specific change to make]
|
|
115
|
-
|
|
116
|
-
### Why
|
|
117
|
-
[Which patches/patterns drove this change]
|
|
118
|
-
|
|
119
|
-
### Where
|
|
120
|
-
[Exact section in SKILL.md to modify]
|
|
121
|
-
|
|
122
|
-
### Change
|
|
123
|
-
[The actual text to add/modify]
|
|
124
|
-
```
|
|
125
|
-
|
|
126
312
|
**Quality rules for improvements:**
|
|
313
|
+
- **One prevention point = one rule.** A single patch may contain multiple independent prevention
|
|
314
|
+
items. Each one becomes a separate rule — do NOT merge them into a single vague summary.
|
|
315
|
+
- **Preserve concrete formats and patterns** from patches. If a patch specifies an exact format,
|
|
316
|
+
syntax, or template — the rule MUST include it verbatim. Do NOT paraphrase specifics into
|
|
317
|
+
vague descriptions.
|
|
127
318
|
- Each improvement must be traceable to a patch, convention, or tech-stack fact
|
|
128
319
|
- No generic advice — only project-specific enhancements
|
|
129
320
|
- Improvements must be minimal and focused — don't rewrite entire skills
|
|
130
321
|
- Preserve existing skill structure — add, don't replace
|
|
131
322
|
|
|
132
|
-
### Step
|
|
323
|
+
### Step 7: Present & Apply
|
|
133
324
|
|
|
134
|
-
**
|
|
325
|
+
**7.1: Present improvements to user**
|
|
326
|
+
|
|
327
|
+
Each improvement MUST explicitly state the target file path.
|
|
328
|
+
Use the following target labels:
|
|
329
|
+
|
|
330
|
+
- **`skill-context`** → `.ai-factory/skill-context/<skill-name>/SKILL.md`
|
|
331
|
+
- **`SKILL.md`** → direct edit of the skill's own `SKILL.md` (only for custom/non-aif skills)
|
|
332
|
+
- **Nested file** → if the skill directory contains additional files (e.g., `templates/`, `checklists/`),
|
|
333
|
+
specify the exact relative path within the skill directory
|
|
334
|
+
|
|
335
|
+
Format:
|
|
135
336
|
|
|
136
337
|
```
|
|
137
338
|
## Skill Evolution Report
|
|
@@ -143,35 +344,95 @@ Based on:
|
|
|
143
344
|
|
|
144
345
|
### Proposed Improvements
|
|
145
346
|
|
|
146
|
-
#### /aif-fix
|
|
147
|
-
|
|
148
|
-
|
|
347
|
+
#### /aif-fix (N rules)
|
|
348
|
+
**Target:** `.ai-factory/skill-context/aif-fix/SKILL.md`
|
|
349
|
+
|
|
350
|
+
1. **Add null-check guard**
|
|
351
|
+
- **Source:** patch-2026-02-10.md, patch-2026-02-12.md (5 patches involved null references)
|
|
352
|
+
- **Why:** Recurring null-reference errors on optional DB relations
|
|
353
|
+
- **Rule:** "Check for optional/nullable fields before accessing nested properties"
|
|
354
|
+
|
|
355
|
+
2. **Add async/await pattern**
|
|
356
|
+
- **Source:** patch-2026-02-11.md (3 patches involved unhandled promises)
|
|
357
|
+
- **Why:** Unhandled promise rejections in API layer
|
|
358
|
+
- **Rule:** "Always use try/catch with async/await"
|
|
149
359
|
|
|
150
|
-
|
|
151
|
-
|
|
360
|
+
#### /aif-implement (N rules)
|
|
361
|
+
**Target:** `.ai-factory/skill-context/aif-implement/SKILL.md`
|
|
152
362
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
363
|
+
1. **Add Prisma-specific warning**
|
|
364
|
+
- **Source:** patch-2026-02-13.md (2 patches from incorrect Prisma queries)
|
|
365
|
+
- **Why:** Silent data loss from wrong Prisma query methods
|
|
366
|
+
- **Rule:** "Log all Prisma queries in DEBUG mode"
|
|
156
367
|
|
|
157
|
-
#### /
|
|
158
|
-
|
|
159
|
-
→ Add to Correctness: "Optional chaining for nullable relations"
|
|
368
|
+
#### /my-custom-skill (N rules)
|
|
369
|
+
**Target:** `skills/my-custom-skill/SKILL.md` (direct edit — custom skill)
|
|
160
370
|
|
|
161
|
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
-
|
|
371
|
+
1. **Add pattern**
|
|
372
|
+
- **Source:** codebase convention
|
|
373
|
+
- **Why:** Missing guard in Step 2
|
|
374
|
+
- **Rule:** "..."
|
|
165
375
|
```
|
|
166
376
|
|
|
167
|
-
**
|
|
377
|
+
**After presenting the full report, use `AskUserQuestion` to collect decisions:**
|
|
168
378
|
|
|
169
|
-
For
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
379
|
+
For improvements — ask: Yes apply all / Let me pick / No just save report
|
|
380
|
+
|
|
381
|
+
**If user chooses "Let me pick":** present improvements in batches of up to 4
|
|
382
|
+
per `AskUserQuestion` call (same approach as Step 4 stale rules). For each
|
|
383
|
+
improvement, options: Apply / Skip. Continue until all improvements are resolved.
|
|
384
|
+
Then proceed to 7.2 with only approved improvements.
|
|
385
|
+
|
|
386
|
+
**Do NOT apply any changes until the user answers.**
|
|
387
|
+
|
|
388
|
+
**7.2: Apply approved improvements**
|
|
389
|
+
|
|
390
|
+
For each approved improvement, determine the target:
|
|
391
|
+
|
|
392
|
+
**If the skill is a built-in `aif-*` skill** (its SKILL.md is inside the package `skills/` directory):
|
|
393
|
+
|
|
394
|
+
1. Create directory if needed:
|
|
395
|
+
mkdir -p .ai-factory/skill-context/<skill-name>
|
|
396
|
+
2. If `.ai-factory/skill-context/<skill-name>/SKILL.md` doesn't exist — create it with the header template
|
|
397
|
+
3. If it exists — read it first, then for each improvement decide:
|
|
398
|
+
- **Update existing rule** — when a rule on the same topic already exists (e.g., a null-check rule
|
|
399
|
+
exists from 3 patches, and 5 new null-check patches arrived → strengthen the existing rule,
|
|
400
|
+
update its Source list, adjust severity/wording based on new evidence)
|
|
401
|
+
- **Add new rule** — when no existing rule covers this topic
|
|
402
|
+
- **Merge rules** — when multiple narrow rules can be combined into one broader rule
|
|
403
|
+
(e.g., three separate "check field X" rules → one "always null-check optional DB relations" rule)
|
|
404
|
+
4. Update the `> Last updated:` and `> Based on:` lines in the header
|
|
405
|
+
5. **NEVER edit any files inside the skill's `skills/aif-*/` directory** — all files there are owned by ai-factory and WILL be overwritten on update. All improvements go to skill-context only.
|
|
406
|
+
6. After applying all changes (including stale rule removals), if a skill-context file has no rules left
|
|
407
|
+
(only the header remains), delete the file and its directory:
|
|
408
|
+
`rm .ai-factory/skill-context/<skill-name>/SKILL.md`
|
|
409
|
+
`rmdir .ai-factory/skill-context/<skill-name>` (only if empty)
|
|
410
|
+
7. Update the `> Based on:` count and `> Last updated:` in skill-context files that were
|
|
411
|
+
only affected by stale rule removals (Step 4) but did NOT receive new improvements
|
|
412
|
+
(those were already updated in item 4).
|
|
413
|
+
|
|
414
|
+
**If the skill is a custom/project skill** (not `aif-*`):
|
|
415
|
+
1. Edit the skill's `SKILL.md` directly (existing behavior, unchanged)
|
|
416
|
+
|
|
417
|
+
**Context file template:**
|
|
418
|
+
|
|
419
|
+
**IMPORTANT: All skill-context files MUST be written in English**, regardless of the user's language or the language used in patches/RULES.md. Skill-context rules are consumed by AI agents — English ensures consistent interpretation across all skills and sessions.
|
|
420
|
+
|
|
421
|
+
```
|
|
422
|
+
# Project Rules for /<skill-name>
|
|
173
423
|
|
|
174
|
-
|
|
424
|
+
> Auto-generated by `/aif-evolve`. Do not edit manually.
|
|
425
|
+
> Last updated: YYYY-MM-DD HH:mm
|
|
426
|
+
> Based on: N analyzed patches
|
|
427
|
+
|
|
428
|
+
## Rules
|
|
429
|
+
|
|
430
|
+
### [Rule Name]
|
|
431
|
+
**Source**: [patch filenames or "codebase convention"]
|
|
432
|
+
**Rule**: [Specific, actionable instruction in English]
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
**7.3: Save evolution log**
|
|
175
436
|
|
|
176
437
|
Create `.ai-factory/evolutions/YYYY-MM-DD-HH.mm.md`:
|
|
177
438
|
|
|
@@ -189,18 +450,20 @@ mkdir -p .ai-factory/evolutions
|
|
|
189
450
|
|
|
190
451
|
## Improvements Applied
|
|
191
452
|
|
|
192
|
-
### [skill-name]
|
|
453
|
+
### [skill-name] → skill-context
|
|
193
454
|
- [change description] ← driven by patches: [patch filenames]
|
|
455
|
+
**File:** `.ai-factory/skill-context/[skill-name]/SKILL.md`
|
|
194
456
|
|
|
195
|
-
### [skill-name]
|
|
457
|
+
### [skill-name] → SKILL.md (custom skill)
|
|
196
458
|
- [change description] ← driven by: [tech stack / convention]
|
|
459
|
+
**File:** `skills/[skill-name]/SKILL.md`
|
|
197
460
|
|
|
198
461
|
## Patterns Identified
|
|
199
462
|
- [pattern]: [frequency] occurrences
|
|
200
463
|
- [pattern]: [frequency] occurrences
|
|
201
464
|
```
|
|
202
465
|
|
|
203
|
-
### Step
|
|
466
|
+
### Step 8: Suggest Next Actions
|
|
204
467
|
|
|
205
468
|
```
|
|
206
469
|
## Evolution Complete
|
|
@@ -218,86 +481,36 @@ Improvements applied: Y
|
|
|
218
481
|
|
|
219
482
|
### Context Cleanup
|
|
220
483
|
|
|
221
|
-
|
|
484
|
+
After completing evolution, suggest `/clear` or `/compact` — context is heavy after reading all patches and skills.
|
|
222
485
|
|
|
223
|
-
|
|
224
|
-
AskUserQuestion: Free up context before continuing?
|
|
225
|
-
|
|
226
|
-
Options:
|
|
227
|
-
1. /clear — Full reset (recommended)
|
|
228
|
-
2. /compact — Compress history
|
|
229
|
-
3. Continue as is
|
|
230
|
-
```
|
|
231
|
-
|
|
232
|
-
## What Each Skill Can Learn
|
|
233
|
-
|
|
234
|
-
| Skill | Learns From | Example Enhancement |
|
|
235
|
-
|-------|-------------|---------------------|
|
|
236
|
-
| `/aif-fix` | Patches → common errors | "Check for X before accessing Y" |
|
|
237
|
-
| `/aif-implement` | Patches → prevention rules | "When creating models, always validate Z" |
|
|
238
|
-
| `/aif-plan` | Patches → logging gaps | "Add validation task for nullable fields" |
|
|
239
|
-
| `/aif-review` | Patches → missed issues | "Check: are all optional relations null-safe?" |
|
|
240
|
-
| `/aif-commit` | Codebase → conventions | "Use project's commit prefix format" |
|
|
241
|
-
|
|
242
|
-
## Important Rules
|
|
486
|
+
## Rules
|
|
243
487
|
|
|
244
488
|
1. **Traceable** — every improvement must link to a patch, convention, or tech fact
|
|
245
|
-
2. **Minimal** — add rules, don't rewrite skills
|
|
489
|
+
2. **Minimal** — add rules to skill-context, don't rewrite base skills
|
|
246
490
|
3. **Reversible** — user approves before changes are applied
|
|
247
491
|
4. **Cumulative** — each evolution builds on previous ones
|
|
248
492
|
5. **No hallucination** — only suggest improvements backed by evidence
|
|
249
|
-
6. **Preserve structure** — don't change skill workflow, only enrich
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
493
|
+
6. **Preserve structure** — don't change base skill workflow, only enrich via skill-context
|
|
494
|
+
7. **Skill-context only** — all improvements for built-in `aif-*` skills go to `.ai-factory/skill-context/`, never to `skills/aif-*/`. **NEVER edit any files inside `skills/aif-*/`** — they are overwritten on update. No exceptions.
|
|
495
|
+
8. **English only** — all skill-context files must be written in English, regardless of user's language
|
|
496
|
+
9. **No generic advice** — "write clean code" is not an improvement; only project-specific enhancements
|
|
497
|
+
10. **No new skills** — suggest `/aif-skill-generator` instead
|
|
498
|
+
11. **No losing coverage** — do not remove rules unless they are stale (Steps 3-4).
|
|
499
|
+
Merges in Step 7 (combining narrow rules into a broader one) are allowed as long
|
|
500
|
+
as all prevention points are preserved in the merged rule.
|
|
501
|
+
12. **Installed only** — do not evolve skills not installed in the project
|
|
502
|
+
13. **Ownership boundary** — this command owns `.ai-factory/evolutions/*.md` and `.ai-factory/skill-context/*`; treat roadmap/rules/research/plan artifacts as read-only context unless explicitly asked
|
|
503
|
+
|
|
504
|
+
## Example
|
|
254
505
|
|
|
255
506
|
```
|
|
256
507
|
/aif-evolve fix
|
|
257
508
|
|
|
258
509
|
→ Found 6/10 patches tagged #null-check
|
|
259
|
-
→ Improvement
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
"
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
### Example 2: Laravel project with N+1 issues
|
|
267
|
-
|
|
268
|
-
```
|
|
269
|
-
/aif-evolve all
|
|
270
|
-
|
|
271
|
-
→ Stack: Laravel + Eloquent (from DESCRIPTION.md)
|
|
272
|
-
→ Found 3 patches tagged #n-plus-one #database
|
|
273
|
-
→ Improvement: Add to /aif-implement logging:
|
|
274
|
-
"Enable query logging: DB::enableQueryLog() in DEBUG mode"
|
|
275
|
-
→ Improvement: Add to /aif-review checklist:
|
|
276
|
-
"- [ ] Eager loading used for related models (no N+1)"
|
|
277
|
-
→ Improvement: Add to /aif-plan descriptions:
|
|
278
|
-
"Include 'use ->with() for relations' in DB-related tasks"
|
|
510
|
+
→ Improvement for /aif-fix (2 rules):
|
|
511
|
+
Target: .ai-factory/skill-context/aif-fix/SKILL.md
|
|
512
|
+
1. "PRIORITY CHECK: Look for optional/nullable fields accessed
|
|
513
|
+
without null guards. This is the #1 source of bugs in this project."
|
|
514
|
+
2. "When fixing nullable relation errors, check ALL usages of that
|
|
515
|
+
relation in the same file — same bug often repeats nearby."
|
|
279
516
|
```
|
|
280
|
-
|
|
281
|
-
### Example 3: First run with no patches
|
|
282
|
-
|
|
283
|
-
```
|
|
284
|
-
/aif-evolve
|
|
285
|
-
|
|
286
|
-
→ No patches found (first run)
|
|
287
|
-
→ Analyzing project context only...
|
|
288
|
-
→ Stack: Next.js 14 + Prisma + TypeScript
|
|
289
|
-
→ Improvement: Add to /aif-implement:
|
|
290
|
-
"Use server actions for mutations, API routes for external APIs"
|
|
291
|
-
→ Improvement: Add to /aif-fix:
|
|
292
|
-
"For Prisma errors, check schema.prisma for field types first"
|
|
293
|
-
→ Improvement: Add to /aif-review:
|
|
294
|
-
"- [ ] Server components don't use client-only hooks"
|
|
295
|
-
```
|
|
296
|
-
|
|
297
|
-
## DO NOT:
|
|
298
|
-
- Do not rewrite entire skills
|
|
299
|
-
- Do not remove existing rules
|
|
300
|
-
- Do not add generic advice ("write clean code")
|
|
301
|
-
- Do not create new skills (suggest using `/aif-skill-generator` instead)
|
|
302
|
-
- Do not apply changes without user approval
|
|
303
|
-
- Do not evolve skills not installed in the project
|