Plan Files and Bundles
AI Factory uses markdown files and ultra plan bundles to track implementation:
Paths below show the default .ai-factory/ layout. config.yaml can relocate plan, fix, patch, reference, security, evolution, and loop-state artifacts while keeping the same ownership.
| Source | Plan File | After Completion |
|---|---|---|
/aif-plan fast |
paths.plan (default: .ai-factory/PLAN.md) |
Offer to delete |
/aif-plan full |
paths.plans/<stem>.md (default; stem = Handoff branch → git branch → description slug, per /aif-plan Step 1.2.a) |
Keep (user decides) |
/aif-plan full (workflow.plan_id_format: sequential) |
paths.plans/<NNNN>_<stem>.md (4-digit, capped at 9999; NNNN is derived from existing numbered plans in the directory) |
Keep (user decides) |
/aif-plan ultra |
paths.plans/<stem>/index.md plus phase-NN-*.md |
Keep (user decides) |
/aif-plan ultra (workflow.plan_id_format: sequential) |
paths.plans/<NNNN>_<stem>/index.md plus phase files |
Keep (user decides) |
Ultra Plan Bundle
Ultra is intended for planning with a stronger model and implementation with a smaller model. The planner commits implementation decisions into a bundle:
Ultra is additive and strictly opt-in. Updating AI Factory does not migrate
existing plan files or change fast/full artifact shapes. A leading ultra token
or workflow.plan_mode: ultra selects a bundle; an explicit fast or full
overrides the configured default.
.ai-factory/plans/feature-billing-ledger/
├── index.md
├── phase-01-ledger-domain.md
├── phase-02-persistence-migration.md
└── phase-03-service-integration.md
index.md is the manifest and only progress ledger. It owns the original
request, settings, research/roadmap context, phase table of contents,
cross-phase dependencies, task checkboxes, commit plan, and definition of done.
It also contains the exact machine-readable marker
<!-- aif:plan-mode:ultra -->. The marker is never localized; consumers use it
instead of the human-readable Mode label when discovering bundle directories.
Each phase file specifies exact code evidence, paths and symbols, ordered edits, interfaces, data flow, errors and logging, test policy, risks, acceptance criteria, and verification commands.
Task checkboxes are deliberately not duplicated in phase files.
/aif-implement reads index.md, then the complete phase file for the active
task, and updates progress only in index.md. /aif-improve and /aif-verify
read the full linked bundle. An explicit @<path> may point to the directory or
its index.md.
paths.plans remains the only config path; ultra does not add a parallel path
setting. workflow.plan_id_format applies to the bundle directory name.
Sequential allocation counts both numbered full-plan files and numbered ultra
directories whose index.md contains the stable marker. Numbered directories
without the marker do not consume plan IDs.
Archive Lifecycle
When plans accumulate, /aif-archive moves completed plans to paths.archive/plans/ (default: .ai-factory/archive/plans/):
paths.plans/<plan>.md → (all tasks [x]) → paths.archive/plans/<plan>.md
paths.plans/<plan>/ → (index tasks [x]) → paths.archive/plans/<plan>/
- Original file/directory names are preserved (including sequential
NNNN_prefix) - Full plans receive
archived: YYYY-MM-DDin YAML frontmatter; ultra entrypoints receive<!-- aif:archived:YYYY-MM-DD -->immediately after the stable ultra marker - Archived plans are excluded from plan discovery by
/aif-implement,/aif-verify,/aif-improve - Sequential numbering counts active full files and marked ultra directories in
paths.plans/, not unrelated numbered directories or the archive
Roadmap snapshots: /aif-archive --roadmap trims closed milestones from ROADMAP.md into dated snapshots under paths.archive/roadmap/.
Read-only Plan Overview
/aif-plan-overview [@path | plan-name | --archived] explains an existing plan
without changing it. Discovery is explicit path → branch/sequential full or ultra
artifact → sole named plan → fast → fix, with ambiguity reported. Names can search
active and archived roots; automatic discovery excludes archives, including a
relocated archive nested under the plans directory.
An ultra overview reads the full index and only linked phase titles/Objectives/ Files to Change sections. Phase bodies and unlinked files are not preloaded. Progress comes from task checkboxes in the entrypoint and is not execution evidence. Missing sections remain missing rather than inferred from application code.
The file map uses source Files: declarations or phase file tables. It preserves
explicit actions/references, merges duplicate paths, expands {a,b}, and leaves
wildcards/generated placeholders literal. Unknown or multiple actions remain visible.
The optional stdlib formatter runs with isolated imports and no bytecode writes; it reads only JSON stdin and does not inspect/create project files. Flat workflows receive it through the existing references asset mechanism. Without Python, the same map is rendered manually. Counts describe planned paths, not verified files.
The suggested continuation is implementation, fix ownership, or verification for completed tasks; archived plans remain historical. No command is invoked, no plan is rewritten, and no Handoff/TaskList/branch state changes occur.
Artifact Ownership Quick Map
To avoid ownership conflicts, artifact writers are command-scoped:
| Artifact | Primary owner command | Notes |
|---|---|---|
.ai-factory/DESCRIPTION.md |
/aif |
/aif-implement may update only when implementation context actually changed |
.ai-factory/ARCHITECTURE.md |
/aif-architecture |
/aif-implement may update structure notes when implementation changes structure |
.ai-factory/ROADMAP.md |
/aif-roadmap |
/aif-implement may mark completed milestones with evidence |
paths.rules_file (default: .ai-factory/RULES.md), paths.rules/<area>.md, rules.<area> |
/aif-rules |
top-level conventions plus area-rule files and registration |
paths.research (default .ai-factory/RESEARCH.md) or derived <parent>/research/<english-slug>/ bundle |
/aif-explore |
regular single file or ultra bundle (token or config) with conditional supporting artifacts |
paths.plan, paths.plans/<id>.md, paths.plans/<id>/index.md + phases |
/aif-plan |
/aif-improve refines existing single-file plans and ultra bundles |
paths.fix_plan and paths.patches/*.md |
/aif-fix |
defaults shown; actual paths come from paths.fix_plan and paths.patches |
.ai-factory/skill-context/* |
/aif-evolve |
project-specific skill overrides; /aif-transfer delegates approved anonymized inputs |
paths.evolutions/*.md, paths.evolutions/patch-cursor.json |
/aif-evolve |
/aif-transfer delegates logs through evolve but never reads or advances the patch cursor |
paths.archive/plans/*, paths.archive/roadmap/*.md |
/aif-archive |
archived plan files/bundles and dated roadmap snapshots |
Quality commands (/aif-commit, /aif-review, /aif-verify) treat these files as read-only context by default.
Artifact Metadata
ai-factory audit-artifacts reads lightweight YAML frontmatter from markdown artifacts. The schema is intentionally small: it gives teams enough traceability to catch broken links and stale downstream artifacts without requiring a full artifact-management system.
---
id: spec-auth-login
type: spec
status: accepted
owners: [platform]
depends_on:
- adr-auth-session
affects:
- plan-auth-login
- docs-auth
supersedes:
- adr-auth-jwt
---
Supported fields:
| Field | Required | Meaning |
|---|---|---|
id |
Yes | Stable unique identifier. Prefer lowercase kebab-case with a type prefix, for example spec-auth-login, adr-auth-session, plan-password-reset, docs-api-auth, or tests-checkout-flow. Keep it stable when files move. |
type |
Recommended | Artifact kind. Recommended values: spec, requirement, plan, adr, architecture, roadmap, docs, tests, qa, code, rules, research, patch. |
status |
Recommended | Lifecycle state. Recommended values: draft, proposed, accepted, active, in_progress, done, deprecated, obsolete, superseded. |
owners / owner |
Recommended | Team, role, or person responsible for review when the artifact is affected. Prefer team owners such as platform, frontend, backend, security, infra, qa, docs, or product. |
depends_on |
Optional | Upstream artifacts this artifact relies on. Use it when the current artifact cannot be safely changed without checking another artifact. audit-artifacts checks for unknown references and dependency cycles. |
affects |
Optional | Downstream artifacts that should be reviewed when this artifact changes. Use it to make PR impact review explicit. |
implements |
Optional | Requirements, specs, or decisions implemented by this artifact. Common for code and plan artifacts. |
verifies |
Optional | Requirements, specs, or decisions verified by this artifact. Common for tests and qa artifacts. |
documents |
Optional | Requirements, specs, or decisions described by this artifact. Common for docs artifacts. |
supersedes |
Optional | Older artifacts replaced by this artifact. Common for ADRs and specs. Mark the older artifact status: superseded when possible. |
Relationship guidance:
depends_onpoints upstream: a plan may depend on a spec, an ADR, and architecture guidance.affectspoints downstream: a changed ADR may affect architecture, plans, tests, and docs that need review.implements,verifies, anddocumentsprovide reverse traceability for implementation, test, and documentation coverage.supersedeskeeps history while making the newer source of truth explicit.
The command accepts scalar values, inline arrays, or YAML-style lists:
depends_on: adr-auth-session
affects: [plan-auth-login, docs-auth]
verifies:
- spec-auth-login
Run the audit locally before opening a PR:
ai-factory audit-artifacts
ai-factory audit-artifacts .ai-factory docs/requirements.md
ai-factory audit-artifacts --strict
ai-factory audit-artifacts --json
Default discovery scans .ai-factory, docs, README.md, and AGENTS.md when those paths exist. Recursive default discovery skips noisy or generated subdirectories such as qa, evolution, and evolutions; pass those paths explicitly when you want to audit them.
This default is intentionally default-layout first; projects that relocate artifact directories through config.yaml should pass those paths explicitly until the command becomes config-aware.
Positional paths are explicit audit targets. Missing or outside-project explicit targets are failures so CI cannot pass after a typo or file rename. Missing default targets are skipped because many projects do not have every default file. Symlinked targets are canonicalized with realpath; a symlink that resolves outside the project is not scanned. For default targets this is a warning, and for explicit targets it is a failure.
Finding severity and exit behavior:
| Finding | Severity |
|---|---|
| Explicit missing or outside-project target | Fail |
Duplicate id |
Fail |
| Unknown relation target | Fail |
| Self-reference | Fail |
depends_on cycle |
Fail |
Missing type, status, or owner / owners |
Warn |
| Spec with no dependency/impact links | Warn |
Spec without incoming implements, verifies, or documents coverage |
Warn |
Accepted ADR without affects links |
Warn |
| Default symlink target resolving outside the project | Warn |
Exit codes:
passexits0.warnexits0by default.failexits non-zero.--stricttreats warnings as failures and exits non-zero.
--json is intended for CI or future PR automation. Its output shape is:
{
"status": "pass|warn|fail",
"artifacts": 2,
"markdown_without_metadata": 0,
"findings": [
{
"level": "fail|warn",
"file": ".ai-factory/spec.md",
"id": "spec-auth-login",
"message": "depends_on references unknown artifact \"adr-missing\"."
}
]
}
When a PR changes an artifact with downstream links, include an impact note that records the decision for each affected artifact:
## Artifact Impact
Changed:
- adr-auth-session
Reviewed:
- architecture-auth: updated
- spec-auth-login: reviewed-ok
- tests-auth-session: deferred, follow-up #123
Audit:
- ai-factory audit-artifacts: pass
Research Artifacts (Optional)
.ai-factory/RESEARCH.md is a persisted exploration artifact. Use it to capture constraints, decisions, and open questions during /aif-explore so you can /clear and still feed the same context into /aif-plan.
Explicit /aif-explore ultra <topic> instead uses
.ai-factory/research/<english-topic-slug>/INDEX.md plus a compatible
RESEARCH.md. C4, ADR, and dependency graph files are conditional. The root is
derived from the parent of configured paths.research, so relocating that file
also relocates ultra bundles without a second config key. See
Research and System Analysis.
When research influences a plan, /aif-plan copies the relevant Active Summary from the selected legacy or bundled RESEARCH.md into ## Research Context. The canonical Source: line wraps the exact path in backticks so spaces and brackets remain parseable. That embedded copy is the committed requirements snapshot for implementation and verification.
Downstream skills compare its SHA256 revision and warn on drift instead of applying newer research or sibling bundle artifacts to an older plan; Updated: is a legacy fallback only when no hash exists.
Plans created before revision markers were introduced may contain a Source: or Reference: line to RESEARCH.md without Updated: or SHA256: metadata. Downstream skills intentionally treat that as an unverified research link and emit a legacy compatibility WARN [research-drift]; they still execute against the embedded plan context instead of silently applying the current Active Summary.
Typical structure:
## Active Summary (input for /aif-plan)— compact, up-to-date snapshot## Sessions— append-only history (keep prior notes verbatim)
Before either regular or ultra research is saved as current context,
/aif-explore runs its content-coherence gate. The later SHA256 in a plan detects
revision drift; it does not replace this earlier semantic check.
Opt-in project hypothesis cards stay
outside the summary markers in RESEARCH.md. Only explicitly accepted actions
or experiments become tasks. Their material planning facts, including exact
hypothesis/source/experiment revisions and current outcome, must be promoted
into a self-contained Active Summary before planning.
The hash tracks that summary, not all observations; implementation completion does not confirm the hypothesis or silently update the plan's committed Research Context.
Original Request
When the user supplies a request to /aif-plan, the plan includes ## Original Request with the request preserved as raw source input.
Command parsing removes only recognized command tokens in command positions:
the leading fast, full, or ultra mode token, recognized flags such as
--parallel and --list, and --cleanup <branch> when that command path is
used. Matching words inside the user's actual request are not removed.
After command tokens are removed, /aif-plan trims only outer whitespace introduced by parsing. It preserves internal whitespace, line breaks, wording, casing, and punctuation exactly. Downstream plan rewrites, including /aif-improve, must preserve ## Original Request verbatim and must not translate, summarize, normalize, or rewrite it even when generated plan artifact prose uses another language.artifacts value.
This section is omitted only when the plan is created solely from RESEARCH.md without an explicit user request; in that case ## Research Context is the committed source.
Meaning Preservation in Requirement Rewrites
When /aif-plan turns requirements into tasks or /aif-improve rewords them,
the editorial rewrite must preserve modal meaning and obligation levels,
conditions, exceptions, negations, numbers and units, identifiers, links, and
uncertainty. RFC 2119 keywords remain verbatim. Check, verify, confirm, and
validate remain distinct unless the source defines them as equivalent.
For example, "check the config only while the service is stopped" does not authorize stopping the service. Permission does not imply completion, a recommendation does not become mandatory, and an unknown cause stays unknown. Clearer wording cannot increase confidence or change the contract.
The rewrite gets an explicit Meaning preservation: PASS or FAIL before
presentation of the plan or readability results. The Meaning preservation:
label and PASS / FAIL / N/A verdict tokens stay fixed across languages;
explanations follow the configured output language.
Failed comparisons must be
repaired or restored before
the rewrite is presented as ready; missing source or unresolved ambiguity
fails the gate. /aif-improve checks proposed edits even without +check and
rechecks before saving. Explicitly approved behavioral changes remain separate
from editorial changes.
/aif-docs applies the same gate to documentation
rewrites, including translation, splitting, and consolidation. When no
requirements were rewritten, the verdict is N/A — no requirements rewritten.
Roadmap Linkage (Optional)
If .ai-factory/ROADMAP.md exists, /aif-plan may include a ## Roadmap Linkage section in the plan file.
This makes milestone alignment explicit for /aif-implement completion marking and /aif-verify roadmap gates.
A selected group is saved in fast/full plans and ultra index.md as one primary
Milestone: plus one quoted Also completes: line per additional milestone. Names/IDs
are preserved, including commas inside quoted names. /aif-improve retains the group;
implementation and verification assess completion of each linked milestone separately.
Completed plans with still-open links remain pending reconciliation even after archiving.
The English linkage/task headings and labels in examples are structural; artifact language still applies. Advisors and completion/verification recognize clear localized equivalents while preserving exact milestone names/IDs and task IDs. Roadmap-next's copyable request carries the source path and every selection in an explicit ordered list; joining names into a prose description alone is insufficient.
Example plan file:
# Implementation Plan: User Authentication
Branch: feature/user-authentication
Created: 2024-01-15
## Original Request
Add user authentication with OAuth
## Settings
- Testing: no
- Logging: verbose
- Docs: yes # /aif-implement shows mandatory docs checkpoint, then routes through /aif-docs
## Research Context (optional)
Source: `.ai-factory/RESEARCH.md` (Active Summary, Updated: YYYY-MM-DD HH:MM, SHA256: <active-summary-sha256>)
Goal: Add OAuth + email login
Constraints: Must support existing session middleware
Decisions: Use JWT for API auth
Open questions: Do we need refresh tokens?
## Commit Plan
- **Commit 1** (tasks 1-3): "feat: add user model and types"
- **Commit 2** (tasks 4-6): "feat: implement auth service"
## Tasks
### Phase 1: Setup
- [ ] Task 1: Create User model
- [ ] Task 2: Add auth types
### Phase 2: Implementation
- [x] Task 3: Implement registration
- [ ] Task 4: Implement login
Self-Improvement Patches
AI Factory has a built-in learning loop. Every bug fix creates a patch — a structured knowledge artifact that helps AI avoid the same mistakes in the future.
/aif-fix → finds bug → fixes it → creates patch → /aif-evolve distills new patches into skill-context → smarter future runs
How it works:
/aif-fixfixes a bug and creates a patch file inpaths.patches/YYYY-MM-DD-HH.mm.md- Each patch documents: Problem, Root Cause, Solution, Prevention, and Tags
/aif-evolvereads patches incrementally usingpaths.evolutions/patch-cursor.json(first run reads all). Targets are project-scoped by default; existing user-global skills require explicit--global. See ownership and destinations- Before approval, candidate rules are compared with the current effective instructions on the same problem and control cases; only validated revisions enter active skill-context
- Evolution logs retain exact candidate versions, cases, results, extra cost, regressions, and all outcomes, including no improvement or insufficient data; report-only saves do not advance the cursor by default
- Workflow skills (
/aif-implement,/aif-fix,/aif-improve) prefer skill-context rules. When their individual context file is absent, they still read the latest ten patches (or fewer if available), even when global/build context exists; a shared rule alone does not establish that patch lessons were distilled.
Applicable learned context includes optional global/build layers, not just individual files. Existing individual files need no migration. See shared context and precedence.
Example patch (paths.patches/2026-02-07-14.30.md):
# Null reference in UserProfile when user has no avatar
**Date:** 2026-02-07 14:30
**Files:** src/components/UserProfile.tsx
**Severity:** medium
## Problem
TypeError: Cannot read property 'url' of undefined when rendering UserProfile.
## Root Cause
`user.avatar` is optional in DB but accessed without null check.
## Solution
Added optional chaining: `user.avatar?.url` with fallback.
## Prevention
- Always null-check optional DB fields in UI
- Add "empty state" test cases
## Tags
`#null-check` `#react` `#optional-field`
The more you use /aif-fix, the smarter AI becomes on your project. Patches accumulate and create a project-specific knowledge base.
Periodic evolution -- run /aif-evolve to analyze new patches, compare candidate rules, and approve demonstrated improvements:
/aif-evolve # Analyze patches + project → improve project skills
This closes the full learning loop: fix → patch → evolve → better skills → fewer bugs → smarter fixes.
To reuse lessons from a similar AI Factory project without merging its history into the
current one, run /aif-transfer <source-project-path>. It reads the source patches in
place, keeps only prevention points verified against the current project, removes source
identity, and delegates approved rules to /aif-evolve. It never copies source patches
into paths.patches or changes the current patch cursor.
Skill Acquisition Strategy
AI Factory follows this strategy for skills:
For each recommended skill:
1. Search skills.sh: npx skills search <name>
2. If found → Install: npx skills install --agent <agent> <name>
3. Security scan → detect Python 3, then run security-scan.py <path>
- BLOCKED? → remove, warn user, skip
- WARNINGS? → show to user, ask confirmation
4. If not found → Generate: /aif-skill-generator <name>
5. Has reference docs? → Learn: /aif-skill-generator <url1> [url2]...
Never reinvent existing skills - always check skills.sh first. Never trust external skills blindly - always scan before use. When reference documentation is available, use Learn Mode to generate skills from real sources.
See Also
- Development Workflow — how plan files fit into the development loop
- Research and System Analysis — ultra research bundle structure and selection
- Core Skills — full reference for
/aif-fix,/aif-evolve, and other skills