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
@@ -34,6 +34,36 @@ Use this context when:
34
34
  - Planning file structure (follow project conventions)
35
35
  - **Follow architecture guidelines from `.ai-factory/ARCHITECTURE.md` when planning file structure and task organization**
36
36
 
37
+ **Read `.ai-factory/skill-context/aif-plan/SKILL.md`** — MANDATORY if the file exists.
38
+
39
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
40
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
41
+
42
+ **How to apply skill-context rules:**
43
+ - Treat them as **project-level overrides** for this skill's general instructions
44
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
45
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
46
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
47
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
48
+ they exist because the project's experience proved the default insufficient
49
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the PLAN.md
50
+ template and task format. The plan template from TASK-FORMAT.md is a **base structure**. If a
51
+ skill-context rule says "tasks MUST include X" or "plan MUST have section Y" — you MUST augment
52
+ the template accordingly. Generating a plan that violates skill-context rules is a bug.
53
+
54
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
55
+ If any rule is violated — fix the output before presenting it to the user.
56
+
57
+ **OPTIONAL (recommended):** Read `.ai-factory/ROADMAP.md` if it exists:
58
+ - Use it to link this plan to a specific milestone (when applicable)
59
+ - This reduces ambiguity in `/aif-implement` milestone completion and `/aif-verify` roadmap gates
60
+
61
+ **OPTIONAL (recommended):** Read `.ai-factory/RESEARCH.md` if it exists:
62
+ - Treat `## Active Summary (input for /aif-plan)` as an additional requirements source
63
+ - Carry over constraints/decisions into tasks and plan settings
64
+ - Prefer the summary over raw notes; use `## Sessions` only when you need deeper rationale
65
+ - If the user omitted the feature description, use `Active Summary -> Topic:` as the default description
66
+
37
67
  ### Step 0.1: Ensure Git Repository
38
68
 
39
69
  ```bash
@@ -57,6 +87,10 @@ full → Full mode (first word)
57
87
  - Remaining text becomes the description
58
88
  - `--list` and `--cleanup` execute immediately and **STOP** (do NOT continue to Step 1+)
59
89
 
90
+ **If the description is empty:**
91
+ - If `.ai-factory/RESEARCH.md` exists and its `Active Summary` has a non-empty `Topic:`, default the description to that topic (no extra user input required)
92
+ - Otherwise, ask the user for a short feature description
93
+
60
94
  **If `--list` is present**, jump to [--list Subcommand](#--list-subcommand).
61
95
  **If `--cleanup` is present**, jump to [--cleanup Subcommand](#--cleanup-subcommand).
62
96
 
@@ -73,6 +107,10 @@ Options:
73
107
  2. Fast — quick plan, no branch, saves to PLAN.md
74
108
  ```
75
109
 
110
+ If the user did not provide a description and `.ai-factory/RESEARCH.md` exists:
111
+ - Mention that you will default the description to the `Active Summary` topic
112
+ - Only ask for `full` vs `fast` (no description prompt needed)
113
+
76
114
  For concrete parsing examples and expected behavior per command shape, read `references/EXAMPLES.md` (Argument Parsing).
77
115
 
78
116
  ---
@@ -140,7 +178,11 @@ AskUserQuestion: Before we start, a few questions:
140
178
  - [ ] Yes, update docs (/aif-docs)
141
179
  - [ ] No, skip docs
142
180
 
143
- 4. Any specific requirements or constraints?
181
+ 4. Roadmap milestone linkage (only if `.ai-factory/ROADMAP.md` exists):
182
+ - [ ] Link this plan to a milestone
183
+ - [ ] Skip — no linkage (allowed; `/aif-verify --strict` should report WARN, not fail, for missing linkage alone)
184
+
185
+ 5. Any specific requirements or constraints?
144
186
  ```
145
187
 
146
188
  **Default to verbose logging.** AI-generated code benefits greatly from extensive logging because:
@@ -150,6 +192,11 @@ AskUserQuestion: Before we start, a few questions:
150
192
 
151
193
  Store all preferences — they will be used in the plan file and passed to `/aif-implement`.
152
194
 
195
+ **If `.ai-factory/ROADMAP.md` exists and the user chose milestone linkage:**
196
+ - Read `.ai-factory/ROADMAP.md` and list candidate milestones (prefer unchecked items)
197
+ - Ask the user to pick one milestone (or type a custom one)
198
+ - Store the selected milestone name and a 1-sentence rationale for inclusion in the plan file
199
+
153
200
  ### Step 1.4: Create Branch or Worktree
154
201
 
155
202
  **If `--parallel` flag is set → create worktree:**
@@ -179,6 +226,7 @@ WORKTREE="../${DIRNAME}-<branch-name-with-hyphens>"
179
226
  # Project context
180
227
  cp .ai-factory/DESCRIPTION.md "${WORKTREE}/.ai-factory/DESCRIPTION.md" 2>/dev/null
181
228
  cp .ai-factory/ARCHITECTURE.md "${WORKTREE}/.ai-factory/ARCHITECTURE.md" 2>/dev/null
229
+ cp .ai-factory/RESEARCH.md "${WORKTREE}/.ai-factory/RESEARCH.md" 2>/dev/null
182
230
 
183
231
  # Past lessons / patches
184
232
  cp -r .ai-factory/patches/ "${WORKTREE}/.ai-factory/patches/" 2>/dev/null
@@ -242,6 +290,10 @@ AskUserQuestion: Before we start:
242
290
  - [ ] No, skip tests
243
291
 
244
292
  2. Any specific requirements or constraints?
293
+
294
+ 3. Roadmap milestone linkage (only if `.ai-factory/ROADMAP.md` exists):
295
+ - [ ] Link this plan to a milestone
296
+ - [ ] Skip — no linkage (allowed; `/aif-verify --strict` should report WARN, not fail, for missing linkage alone)
245
297
  ```
246
298
 
247
299
  **Plan file:** Always `.ai-factory/PLAN.md` (no branch, no branch-named file).
@@ -330,9 +382,19 @@ mkdir -p .ai-factory/plans # only when saving to branch-named plan files
330
382
  - Title with feature name
331
383
  - Branch and creation date
332
384
  - `Settings` section (Testing, Logging, Docs)
385
+ - `Roadmap Linkage` section (optional, only if `.ai-factory/ROADMAP.md` exists)
386
+ - `Research Context` section (optional, if `.ai-factory/RESEARCH.md` exists)
333
387
  - `Tasks` section grouped by phases
334
388
  - `Commit Plan` section when there are 5+ tasks
335
389
 
390
+ If `.ai-factory/ROADMAP.md` exists:
391
+ - If the user linked a milestone, write `## Roadmap Linkage` with `Milestone: "..."` and `Rationale: ...`
392
+ - If the user skipped linkage, write `## Roadmap Linkage` with `Milestone: "none"` and `Rationale: "Skipped by user"`
393
+
394
+ If `.ai-factory/RESEARCH.md` exists:
395
+ - Include `## Research Context` by copying only the `Active Summary` (do not paste full `Sessions`)
396
+ - Keep it compact; it should be readable as a one-screen requirements snapshot
397
+
336
398
  Use the canonical template in `references/TASK-FORMAT.md` (Plan File Template).
337
399
 
338
400
  **Commit Plan Rules:**
@@ -466,6 +528,8 @@ Use canonical examples in `references/TASK-FORMAT.md`:
466
528
  6. **Include file paths** — Help implementer know where to work
467
529
  7. **Commit checkpoints for large plans** — 5+ tasks need commit plan with checkpoints every 3-5 tasks
468
530
  8. **Plan file location** — Fast mode: `.ai-factory/PLAN.md`. Full mode: `.ai-factory/plans/<branch-name>.md`
531
+ 9. **Ownership boundary** — This command owns plan files only (`.ai-factory/PLAN.md`, `.ai-factory/plans/<branch>.md`). Use owner commands (`/aif-roadmap`, `/aif-rules`, `/aif-explore`) for their artifacts.
532
+ 10. **Roadmap linkage (when available)** — If `.ai-factory/ROADMAP.md` exists, include a `## Roadmap Linkage` section in the plan (or explicitly state it was skipped).
469
533
 
470
534
  ## Plan File Handling
471
535
 
@@ -16,6 +16,14 @@
16
16
  -> mode=full, description="Add user authentication with OAuth"
17
17
  ```
18
18
 
19
+ ### Full mode with description omitted (defaults from RESEARCH.md)
20
+
21
+ ```text
22
+ /aif-plan full
23
+ -> mode=full
24
+ -> description defaults to .ai-factory/RESEARCH.md Active Summary Topic (if present)
25
+ ```
26
+
19
27
  ### Full mode with parallel worktree
20
28
 
21
29
  ```text
@@ -44,6 +52,14 @@
44
52
  -> ask mode interactively, description="Add user authentication"
45
53
  ```
46
54
 
55
+ ### No mode + no description (defaults from RESEARCH.md)
56
+
57
+ ```text
58
+ /aif-plan
59
+ -> ask mode interactively
60
+ -> description defaults to .ai-factory/RESEARCH.md Active Summary Topic (if present)
61
+ ```
62
+
47
63
  ## Flow Scenarios
48
64
 
49
65
  ### Scenario 1: Fast mode
@@ -67,6 +83,7 @@
67
83
  -> mode=full
68
84
  -> Quick reconnaissance
69
85
  -> Branch: feature/user-authentication
86
+ -> If ROADMAP.md exists: asks about milestone linkage, user picks one (or skips)
70
87
  -> Asks about tests (Yes), logging (Verbose), docs (Yes)
71
88
  -> Creates branch
72
89
  -> Explores codebase deeply
@@ -83,6 +100,7 @@
83
100
  -> mode=full, parallel=true
84
101
  -> Quick reconnaissance
85
102
  -> Branch: feature/stripe-checkout
103
+ -> If ROADMAP.md exists: asks about milestone linkage, user picks one (or skips)
86
104
  -> Asks about tests (No), logging (Verbose), docs (No)
87
105
  -> Creates worktree ../my-project-feature-stripe-checkout
88
106
  -> Copies context files, cd into worktree
@@ -13,6 +13,20 @@ Created: [date]
13
13
  - Logging: verbose/standard/minimal
14
14
  - Docs: yes/no
15
15
 
16
+ ## Roadmap Linkage (optional)
17
+ <!-- Only when .ai-factory/ROADMAP.md exists -->
18
+ Milestone: "[milestone name from ROADMAP.md]" # or "none"
19
+ Rationale: [1 short sentence]
20
+
21
+ ## Research Context (optional)
22
+ <!-- If .ai-factory/RESEARCH.md exists, copy/paste the Active Summary here -->
23
+ Source: .ai-factory/RESEARCH.md (Active Summary)
24
+
25
+ Goal:
26
+ Constraints:
27
+ Decisions:
28
+ Open questions:
29
+
16
30
  ## Commit Plan
17
31
  <!-- For plans with 5+ tasks, define commit checkpoints -->
18
32
  - **Commit 1** (after tasks 1-3): "feat: add base models and types"
@@ -3,6 +3,7 @@ name: aif-review
3
3
  description: Perform code review on staged changes or a pull request. Checks for bugs, security issues, performance problems, and best practices. Use when user says "review code", "check my code", "review PR", or "is this code okay".
4
4
  argument-hint: "[PR number or empty]"
5
5
  allowed-tools: Bash(git *) Bash(gh *) Read Glob Grep
6
+ disable-model-invocation: false
6
7
  ---
7
8
 
8
9
  # Code Review Assistant
@@ -23,6 +24,42 @@ Perform thorough code reviews focusing on correctness, security, performance, an
23
24
  2. Use `gh pr diff <number>` to get the diff
24
25
  3. Review all changes in the PR
25
26
 
27
+ ## Context Gates (Read-Only)
28
+
29
+ Before finalizing review findings, run read-only context gates:
30
+
31
+ - Check `.ai-factory/ARCHITECTURE.md` (if present) for boundary/dependency alignment issues.
32
+ - Check `.ai-factory/RULES.md` (if present) for explicit convention violations.
33
+ - Check `.ai-factory/ROADMAP.md` (if present) for milestone alignment and mention missing linkage for likely `feat`/`fix`/`perf` work.
34
+
35
+ Gate result severity:
36
+ - `WARN` for non-blocking inconsistencies or missing optional files.
37
+ - `ERROR` only for explicit blocking criteria requested by the user/review policy.
38
+
39
+ `/aif-review` is read-only for context artifacts by default. Do not modify context files unless user explicitly asks.
40
+
41
+ ### Project Context
42
+
43
+ **Read `.ai-factory/skill-context/aif-review/SKILL.md`** — MANDATORY if the file exists.
44
+
45
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
46
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
47
+
48
+ **How to apply skill-context rules:**
49
+ - Treat them as **project-level overrides** for this skill's general instructions
50
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
51
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
52
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
53
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
54
+ they exist because the project's experience proved the default insufficient
55
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the review
56
+ summary format and the checklist criteria. If a skill-context rule says "review MUST check X"
57
+ or "summary MUST include section Y" — you MUST augment the output accordingly. Producing a
58
+ review that ignores skill-context rules is a bug.
59
+
60
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
61
+ If any rule is violated — fix the output before presenting it to the user.
62
+
26
63
  ## Review Checklist
27
64
 
28
65
  ### Correctness
@@ -70,6 +107,9 @@ Perform thorough code reviews focusing on correctness, security, performance, an
70
107
  **Files Reviewed:** [count]
71
108
  **Risk Level:** 🟢 Low / 🟡 Medium / 🔴 High
72
109
 
110
+ ### Context Gates
111
+ [Architecture / Rules / Roadmap gate results with WARN/ERROR labels]
112
+
73
113
  ### Critical Issues
74
114
  [Must be fixed before merge]
75
115
 
@@ -23,6 +23,26 @@ Create and maintain a high-level project roadmap with major milestones.
23
23
  - Chosen architecture pattern and folder structure
24
24
  - Module boundaries and communication patterns
25
25
 
26
+ **Read `.ai-factory/skill-context/aif-roadmap/SKILL.md`** — MANDATORY if the file exists.
27
+
28
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
29
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
30
+
31
+ **How to apply skill-context rules:**
32
+ - Treat them as **project-level overrides** for this skill's general instructions
33
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
34
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
35
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
36
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
37
+ they exist because the project's experience proved the default insufficient
38
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the ROADMAP.md
39
+ template. The template in this SKILL.md is a **base structure**. If a skill-context rule says
40
+ "roadmap MUST include X" or "milestones MUST have Y" — you MUST augment the template accordingly.
41
+ Generating a roadmap that violates skill-context rules is a bug.
42
+
43
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
44
+ If any rule is violated — fix the output before presenting it to the user.
45
+
26
46
  ### Step 1: Determine Mode
27
47
 
28
48
  If argument is `check` → Mode 3: Check Progress (requires ROADMAP.md)
@@ -271,3 +291,4 @@ Next up: **Milestone Name**
271
291
  3. **Never remove milestones silently** — always confirm with user before removing
272
292
  4. **Completed table tracks history** — every checked milestone gets a date entry
273
293
  5. **NO implementation** — this skill only plans, use `/aif-plan` to start a feature and `/aif-implement` to execute
294
+ 6. **Ownership boundary** — this command owns roadmap structure/content; `/aif-implement` may only mark milestones completed when implementation evidence is clear
@@ -12,6 +12,28 @@ Add short, actionable rules and conventions for the current project. Rules are s
12
12
 
13
13
  ## Workflow
14
14
 
15
+ ### Step 0: Load Skill Context
16
+
17
+ **Read `.ai-factory/skill-context/aif-rules/SKILL.md`** — MANDATORY if the file exists.
18
+
19
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
20
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
21
+
22
+ **How to apply skill-context rules:**
23
+ - Treat them as **project-level overrides** for this skill's general instructions
24
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
25
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
26
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
27
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
28
+ they exist because the project's experience proved the default insufficient
29
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the RULES.md
30
+ format and rule formulation. If a skill-context rule says "rules MUST follow format X" or
31
+ "RULES.md MUST include section Y" — you MUST comply. Generating rules that violate skill-context
32
+ is a bug.
33
+
34
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
35
+ If any rule is violated — fix the output before presenting it to the user.
36
+
15
37
  ### Step 1: Determine Mode
16
38
 
17
39
  ```
@@ -103,3 +125,4 @@ Total rules: [count]
103
125
  3. **No duplicates** — check for existing rules with the same meaning before adding
104
126
  4. **Actionable language** — rules should be clear directives ("Always...", "Never...", "Use...", "Routes must...")
105
127
  5. **RULES.md location** — always `.ai-factory/RULES.md`, create `.ai-factory/` directory if needed
128
+ 6. **Ownership boundary** — this command owns `.ai-factory/RULES.md`; other context artifacts stay read-only unless explicitly requested by the user
@@ -3,6 +3,7 @@ name: aif-security-checklist
3
3
  description: Security audit checklist based on OWASP Top 10 and best practices. Covers authentication, injection, XSS, CSRF, secrets management, and more. Use when reviewing security, before deploy, asking "is this secure", "security check", "vulnerability".
4
4
  argument-hint: "[auth|injection|xss|csrf|secrets|api|infra|prompt-injection|race-condition|ignore <item>]"
5
5
  allowed-tools: Read Glob Grep Write Edit Bash(npm audit) Bash(grep *)
6
+ disable-model-invocation: false
6
7
  ---
7
8
 
8
9
  # Security Checklist
@@ -89,6 +90,30 @@ When audit results are shown, append this section at the end:
89
90
 
90
91
  ---
91
92
 
93
+ ### Project Context
94
+
95
+ **Read `.ai-factory/skill-context/aif-security-checklist/SKILL.md`** — MANDATORY if the file exists.
96
+
97
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
98
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
99
+
100
+ **How to apply skill-context rules:**
101
+ - Treat them as **project-level overrides** for this skill's general instructions
102
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
103
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
104
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
105
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
106
+ they exist because the project's experience proved the default insufficient
107
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including security
108
+ checklists, the Pre-Deployment Checklist, and SECURITY.md. If a skill-context rule says
109
+ "checklist MUST include X" or "audit MUST cover Y" — you MUST augment the checklists accordingly.
110
+ Producing a security report that ignores skill-context rules is a bug.
111
+
112
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
113
+ If any rule is violated — fix the output before presenting it to the user.
114
+
115
+ ---
116
+
92
117
  ## Quick Automated Audit
93
118
 
94
119
  Run the automated security audit script:
@@ -3,6 +3,7 @@ name: aif-skill-generator
3
3
  description: Generate professional Agent Skills for AI agents. Creates complete skill packages with SKILL.md, references, scripts, and templates. Use when creating new skills, generating custom slash commands, or building reusable AI capabilities. Validates against Agent Skills specification.
4
4
  argument-hint: '[skill-name or "search <query>" or URL(s)]'
5
5
  allowed-tools: Read Grep Glob Write Bash(mkdir *) Bash(npx skills *) Bash(python *security-scan*) Bash(rm -rf *) WebFetch WebSearch
6
+ disable-model-invocation: false
6
7
  metadata:
7
8
  author: skill-generator
8
9
  version: "2.1"
@@ -13,6 +14,28 @@ metadata:
13
14
 
14
15
  You are an expert Agent Skills architect. You help users create professional, production-ready skills that follow the [Agent Skills](https://agentskills.io/specification) open standard.
15
16
 
17
+ ### Project Context
18
+
19
+ **Read `.ai-factory/skill-context/aif-skill-generator/SKILL.md`** — MANDATORY if the file exists.
20
+
21
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
22
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
23
+
24
+ **How to apply skill-context rules:**
25
+ - Treat them as **project-level overrides** for this skill's general instructions
26
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
27
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
28
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
29
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
30
+ they exist because the project's experience proved the default insufficient
31
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the generated
32
+ SKILL.md and skill package structure. If a skill-context rule says "generated skills MUST include X"
33
+ or "SKILL.md MUST have section Y" — you MUST augment the output accordingly. Generating a skill
34
+ that violates skill-context rules is a bug.
35
+
36
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
37
+ If any rule is violated — fix the output before presenting it to the user.
38
+
16
39
  ## CRITICAL: Security Scanning
17
40
 
18
41
  **Every skill MUST be scanned for prompt injection before installation or use.**
@@ -43,7 +43,7 @@ fi
43
43
  pass "SKILL.md exists"
44
44
 
45
45
  # Extract frontmatter (between first two --- lines)
46
- FRONTMATTER=$(awk '/^---$/{if(++n==1)next; if(n==2)exit} n==1' "$SKILL_MD")
46
+ FRONTMATTER=$(tr -d '\r' < "$SKILL_MD" | awk '/^---$/{if(++n==1)next; if(n==2)exit} n==1')
47
47
 
48
48
  if [[ -z "$FRONTMATTER" ]]; then
49
49
  error "No YAML frontmatter found (must be between --- markers)"
@@ -88,7 +88,7 @@ else
88
88
  fi
89
89
 
90
90
  # Check description field - handle multiline (read directly from file to avoid quoting issues)
91
- DESC=$(awk '
91
+ DESC=$(tr -d '\r' < "$SKILL_MD" | awk '
92
92
  /^---$/ { n++; next }
93
93
  n == 1 && /^description:/ {
94
94
  found = 1
@@ -105,7 +105,7 @@ DESC=$(awk '
105
105
  n == 1 && found && /^[^[:space:]]/ { exit }
106
106
  n == 2 { exit }
107
107
  END { print desc }
108
- ' "$SKILL_MD")
108
+ ' )
109
109
 
110
110
  if [[ -z "$DESC" ]]; then
111
111
  error "Missing required 'description' field"
@@ -144,7 +144,7 @@ if [[ -n "$ARG_HINT_LINE" ]]; then
144
144
  fi
145
145
 
146
146
  # Count body lines (after second ---)
147
- BODY_LINES=$(awk '/^---$/{if(++n==2){found=1; next}} found' "$SKILL_MD" | wc -l | tr -d ' ')
147
+ BODY_LINES=$(tr -d '\r' < "$SKILL_MD" | awk '/^---$/{if(++n==2){found=1; next}} found' | wc -l | tr -d ' ')
148
148
 
149
149
  if [[ $BODY_LINES -gt 500 ]]; then
150
150
  warn "SKILL.md body exceeds 500 lines ($BODY_LINES). Consider moving content to references/"
@@ -6,7 +6,7 @@ description: >-
6
6
  Use after "/aif-implement" completes, or when user says "verify", "check work", "did we miss anything".
7
7
  argument-hint: "[--strict]"
8
8
  allowed-tools: Read Edit Glob Grep Bash(git *) Bash(npm *) Bash(npx *) Bash(yarn *) Bash(pnpm *) Bash(bun *) Bash(go *) Bash(python *) Bash(php *) Bash(composer *) Bash(cargo *) Bash(make *) Bash(task *) Bash(just *) Bash(mage *) TaskList TaskGet AskUserQuestion Questions
9
- disable-model-invocation: true
9
+ disable-model-invocation: false
10
10
  metadata:
11
11
  author: AI Factory
12
12
  version: "1.0"
@@ -23,6 +23,15 @@ Verify that the completed implementation matches the plan, nothing was missed, a
23
23
 
24
24
  ## Step 0: Load Context
25
25
 
26
+ ### 0.0 Load Ownership and Gate Contract
27
+
28
+ - Read `references/CONTEXT-GATES-AND-OWNERSHIP.md` first.
29
+ - Treat it as the canonical source for:
30
+ - command-to-artifact ownership,
31
+ - read-only behavior for `aif-commit`/`aif-review`/`aif-verify`,
32
+ - normal vs strict context-gate thresholds.
33
+ - If this contract conflicts with older examples in this file, follow the contract.
34
+
26
35
  ### 0.1 Find Plan File
27
36
 
28
37
  Same logic as `/aif-implement`:
@@ -49,6 +58,29 @@ Options:
49
58
  - Read the plan file to understand what was supposed to be implemented
50
59
  - `TaskList` → get all tasks and their statuses
51
60
  - Read `.ai-factory/DESCRIPTION.md` for project context (tech stack, conventions)
61
+ - Read `.ai-factory/ARCHITECTURE.md` for dependency and boundary rules (if present)
62
+ - Read `.ai-factory/RULES.md` for project-specific conventions (if present)
63
+ - Read `.ai-factory/ROADMAP.md` for milestone alignment checks (if present)
64
+
65
+ **Read `.ai-factory/skill-context/aif-verify/SKILL.md`** — MANDATORY if the file exists.
66
+
67
+ This file contains project-specific rules accumulated by `/aif-evolve` from patches,
68
+ codebase conventions, and tech-stack analysis. These rules are tailored to the current project.
69
+
70
+ **How to apply skill-context rules:**
71
+ - Treat them as **project-level overrides** for this skill's general instructions
72
+ - When a skill-context rule conflicts with a general rule written in this SKILL.md,
73
+ **the skill-context rule wins** (more specific context takes priority — same principle as nested CLAUDE.md files)
74
+ - When there is no conflict, apply both: general rules from SKILL.md + project rules from skill-context
75
+ - Do NOT ignore skill-context rules even if they seem to contradict this skill's defaults —
76
+ they exist because the project's experience proved the default insufficient
77
+ - **CRITICAL:** skill-context rules apply to ALL outputs of this skill — including the Verification
78
+ Report template. If a skill-context rule says "verification MUST check X" or "report MUST include
79
+ section Y" — you MUST augment the report accordingly. Generating a verification that ignores
80
+ skill-context rules is a bug.
81
+
82
+ **Enforcement:** After generating any output artifact, verify it against all skill-context rules.
83
+ If any rule is violated — fix the output before presenting it to the user.
52
84
 
53
85
  ### 0.3 Gather Changed Files
54
86
 
@@ -206,6 +238,61 @@ Check if `.ai-factory/DESCRIPTION.md` reflects the current state:
206
238
  - Architecture changes → should be reflected
207
239
  - New integrations → should be documented
208
240
 
241
+ ### 3.5 Context Gates (Architecture / Roadmap / Rules)
242
+
243
+ Apply the canonical contract from `references/CONTEXT-GATES-AND-OWNERSHIP.md`.
244
+
245
+ Evaluate and report each gate explicitly:
246
+
247
+ - **Architecture gate**
248
+ - Pass: implementation follows documented boundaries and dependency rules
249
+ - Warn: architecture mapping is ambiguous or stale
250
+ - Fail: clear violation of explicit architecture constraints
251
+
252
+ - **Rules gate**
253
+ - Pass: implementation follows explicit project rules
254
+ - Warn: relevance/verification is ambiguous
255
+ - Fail: clear violation of explicit rule text
256
+
257
+ - **Roadmap gate**
258
+ - Pass: work aligns with existing milestone direction (prefer `## Roadmap Linkage` from the plan when present)
259
+ - Warn: `.ai-factory/ROADMAP.md` missing, ambiguous mapping, or no milestone linkage for `feat`/`fix`/`perf` scope
260
+ - Fail (strict mode): clear roadmap contradiction after all available roadmap context is considered
261
+
262
+ Normal mode behavior:
263
+ - Architecture/rules clear violations fail verification.
264
+ - Roadmap mismatch and missing milestone linkage are warnings unless contradiction is explicit and severe.
265
+
266
+ Strict mode behavior:
267
+ - Architecture and rules clear violations fail verification.
268
+ - Clear roadmap mismatch fails verification.
269
+ - Missing milestone linkage for `feat`/`fix`/`perf` remains a warning (even when `.ai-factory/ROADMAP.md` exists).
270
+
271
+ Logging/reporting format:
272
+ - Non-blocking findings: `WARN [gate-name] ...`
273
+ - Blocking findings: `ERROR [gate-name] ...`
274
+
275
+ ### 3.6 Context Drift (Optional Remediation)
276
+
277
+ `/aif-verify` is **read-only** for context artifacts. Do not edit or regenerate `.ai-factory/*` files here.
278
+
279
+ If you detect that a context artifact is stale, missing, or ambiguous, report it as a drift finding and provide the owner-command remediation:
280
+
281
+ - `DESCRIPTION.md` drift → suggest `/aif` (or note that `/aif-implement` should have updated it during implementation)
282
+ - `ARCHITECTURE.md` drift → suggest `/aif-architecture`
283
+ - `ROADMAP.md` drift → suggest `/aif-roadmap check` (or `/aif-roadmap <update request>`)
284
+ - `RULES.md` drift → suggest `/aif-rules <rule text>`
285
+
286
+ Ask the user a single optional question **only if** drift was detected and fixing it now would materially improve correctness:
287
+
288
+ ```
289
+ AskUserQuestion: Context drift detected. Capture updates now?
290
+
291
+ Options:
292
+ 1. Yes — show the exact commands to run (recommended)
293
+ 2. No — proceed without updating context
294
+ ```
295
+
209
296
  ---
210
297
 
211
298
  ## Step 4: Verification Report
@@ -348,6 +435,11 @@ When invoked with `--strict`:
348
435
  - **Lint must pass** — zero warnings, zero errors
349
436
  - **No TODOs/FIXMEs** in changed files
350
437
  - **No undocumented environment variables**
438
+ - **Architecture gate must pass** — fail on clear boundary/dependency violations
439
+ - **Rules gate must pass** — fail on clear rule violations
440
+ - **Roadmap gate must pass** — fail on clear roadmap mismatch
441
+ - Missing milestone linkage for `feat`/`fix`/`perf` is a warning even in strict mode
442
+ - Do not fail strict verification solely because milestone linkage is missing
351
443
 
352
444
  Strict mode is recommended before merging to main or creating a pull request.
353
445
 
@@ -0,0 +1,75 @@
1
+ # Context Gates and Artifact Ownership Contract
2
+
3
+ Canonical contract for AI Factory workflow commands. This file defines:
4
+ - which command owns each artifact,
5
+ - which commands consume artifacts as read-only context,
6
+ - and how context gates behave in normal vs strict verification.
7
+
8
+ ## Command-to-Artifact Matrix
9
+
10
+ | Command | Primary write ownership | Read-only context | Approved exceptions |
11
+ |--------------------|------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
12
+ | `aif` | `.ai-factory/DESCRIPTION.md`, `AGENTS.md` (setup map), skill installation and MCP config | Existing project files and context artifacts | May invoke `aif-architecture` to create/update `.ai-factory/ARCHITECTURE.md` during setup |
13
+ | `aif-architecture` | `.ai-factory/ARCHITECTURE.md` | `.ai-factory/DESCRIPTION.md` | May update `DESCRIPTION.md` architecture pointer and `AGENTS.md` context table |
14
+ | `aif-roadmap` | `.ai-factory/ROADMAP.md` | `.ai-factory/DESCRIPTION.md`, `.ai-factory/ARCHITECTURE.md` | `aif-implement` may mark completed milestones after implementation |
15
+ | `aif-rules` | `.ai-factory/RULES.md` | Existing project context | None |
16
+ | `aif-plan` | `.ai-factory/PLAN.md`, `.ai-factory/plans/<branch>.md` | `.ai-factory/DESCRIPTION.md`, `.ai-factory/ARCHITECTURE.md`, `.ai-factory/RESEARCH.md` | `aif-improve` may refine existing plan files |
17
+ | `aif-implement` | Plan progress updates (checkboxes/task status) | `.ai-factory/RULES.md`, `.ai-factory/ARCHITECTURE.md`, `.ai-factory/DESCRIPTION.md`, patches | May update `.ai-factory/DESCRIPTION.md` and `.ai-factory/ARCHITECTURE.md` only when stack/structure changed; may update `.ai-factory/ROADMAP.md` milestone completion |
18
+ | `aif-fix` | `.ai-factory/FIX_PLAN.md` (plan mode), `.ai-factory/patches/*.md` | `.ai-factory/DESCRIPTION.md`, existing patches | None (context artifacts remain read-only by default) |
19
+ | `aif-evolve` | `.ai-factory/evolutions/*.md`, `.ai-factory/skill-context/*` | `.ai-factory/DESCRIPTION.md`, `.ai-factory/patches/*.md` | None |
20
+ | `aif-docs` | `README.md`, `docs/*`, `AGENTS.md` documentation section | Project/context files for factual docs | None |
21
+ | `aif-explore` | `.ai-factory/RESEARCH.md` only | All context and codebase files for analysis | None |
22
+ | `aif-commit` | Git commit object/message only | Context artifacts are read-only gates | No context artifact writes by default |
23
+ | `aif-review` | Review output/comments only | Context artifacts are read-only gates | No context artifact writes by default unless user explicitly asks |
24
+ | `aif-verify` | Verification report output | Context artifacts are read-only gates | May move to fix flow after user confirmation; no default context artifact writes |
25
+
26
+ ## Artifact Update Policy (Recommended)
27
+
28
+ - **Owner writes only:** An artifact should be updated by its owner command.
29
+ - **Implement may do factual deltas:** `aif-implement` may update `.ai-factory/DESCRIPTION.md` and `.ai-factory/ARCHITECTURE.md` only when implementation materially changed stack/structure; it may mark roadmap milestones complete when evidence is clear.
30
+ - **Verify stays read-only:** `aif-verify` reports drift and suggests owner commands; it does not update context artifacts by default.
31
+ - **Rules are explicit:** Only `aif-rules` edits `.ai-factory/RULES.md`. Other commands may propose candidate rules and instruct the user to run `/aif-rules`.
32
+
33
+ ## Context Gates (commit/review/verify)
34
+
35
+ These commands evaluate context consistency against:
36
+ - `.ai-factory/ARCHITECTURE.md`
37
+ - `.ai-factory/ROADMAP.md` (optional, graceful if missing)
38
+ - `.ai-factory/RULES.md` (optional, graceful if missing)
39
+
40
+ Gate outputs must use:
41
+ - `WARN` for non-blocking mismatches or missing optional files
42
+ - `ERROR` for blocking violations
43
+
44
+ ### Architecture Gate
45
+ - **Pass:** Changes follow documented module/layer boundaries.
46
+ - **Warn:** Architecture document appears stale or mapping is ambiguous.
47
+ - **Fail:** Clear boundary/dependency violation against explicit architecture rules.
48
+
49
+ ### Rules Gate
50
+ - **Pass:** Changes comply with explicit project rules.
51
+ - **Warn:** Rule relevance is uncertain or cannot be verified confidently.
52
+ - **Fail:** Clear violation of an explicit rule in `.ai-factory/RULES.md`.
53
+
54
+ ### Roadmap Gate
55
+ - **Pass:** Changes align with an active milestone or approved roadmap direction.
56
+ - **Warn:** `.ai-factory/ROADMAP.md` missing, ambiguous milestone mapping, or no milestone linkage for `feat`/`fix`/`perf` work.
57
+ - **Fail (strict verify only):** Clear mismatch with roadmap direction after all available roadmap context is considered.
58
+
59
+ ## Threshold Decisions (Resolved)
60
+
61
+ ### Verify normal mode
62
+ - Architecture/rules clear violations: **fail**
63
+ - Roadmap mismatch: **warn** unless contradiction is explicit and severe
64
+ - Missing milestone linkage for `feat`/`fix`/`perf`: **warn**
65
+
66
+ ### Verify strict mode
67
+ - Architecture clear violations: **fail**
68
+ - Rules clear violations: **fail**
69
+ - Roadmap clear mismatch: **fail**
70
+ - Missing milestone linkage for `feat`/`fix`/`perf` when `.ai-factory/ROADMAP.md` exists: **warn**
71
+
72
+ ### Commit and review mode
73
+ - Context gates are read-only and non-destructive.
74
+ - Missing roadmap linkage for `feat`/`fix`/`perf`: **warn** by default.
75
+ - Blocking behavior is only allowed when explicitly requested by the user or policy extension.