aif-done
Finalize a verified OpenSpec-native change or legacy AI Factory-only plan, prepare commit/PR summaries, and drive evidence-backed follow-ups.
Install
mkdir -p .claude/skills/aif-done && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/15948" && unzip -o skill.zip -d .claude/skills/aif-done && rm skill.zipInstalls to .claude/skills/aif-done
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Finalize a verified OpenSpec-native change or legacy AI Factory-only plan, prepare commit/PR summaries, and drive evidence-backed follow-ups.About this skill
AIF Done
AIFHub/Handoff finalization skill. Finalizes a verified OpenSpec-native change or a legacy AI Factory-only plan, drafts commit and PR summaries, drives evidence-backed governance follow-ups, and can run or recommend evolution follow-ups.
This skill does not duplicate /aif-verify — it runs after a passing verification (PASS or PASS-with-notes).
Resolve mode from .ai-factory/config.yaml:
- Use OpenSpec-native mode when
aifhub.artifactProtocol: openspec. - Use Legacy AI Factory-only mode otherwise.
OpenSpec-native mode
OpenSpec-native mode finalizes the verified change state through scripts/openspec-done-finalizer.mjs. It is the only OpenSpec-native archive/finalization step after /aif-verify passes.
Preconditions
- Resolve exactly one active change or explicit
<change-id>. - Read QA evidence from
.ai-factory/qa/<change-id>/. - Treat verification as passing only when QA evidence clearly records a final PASS or PASS-with-notes for this change.
- Require the latest final fenced
aif-gate-resultblock inverify.mdto be valid JSON with"gate": "verify"andstatusofpassorwarn. - If verification has not run or verdict is
fail, stop and suggest/aif-verifyor/aif-fix. - If the verify gate result is missing, invalid, or
fail, stop and suggest rerunning/aif-verify <change-id>or/aif-fix <change-id>. - Refuse unverified changes; do not accept
Code verification: PENDINGas final verification. - Check dirty working tree state before archive and either fail or record it only when explicit dirty-state recording is requested.
Canonical Context
Read canonical OpenSpec artifacts:
openspec/specs/**openspec/changes/<change-id>/proposal.mdopenspec/changes/<change-id>/design.mdopenspec/changes/<change-id>/tasks.mdopenspec/changes/<change-id>/specs/**/spec.md
Read generated rules as derived guidance when present:
.ai-factory/rules/generated/openspec-merged-<change-id>.md.ai-factory/rules/generated/openspec-change-<change-id>.md.ai-factory/rules/generated/openspec-base.md
Runtime state and QA evidence live outside canonical changes:
.ai-factory/state/<change-id>/.ai-factory/qa/<change-id>/
Archive Policy
- Archive through
archiveOpenSpecChange(changeId, options)fromscripts/openspec-runner.mjs; this corresponds toopenspec archive <change-id> --yes. - Use
archiveOpenSpecChange(changeId)for normal finalization. - Use
archiveOpenSpecChange(changeId, { skipSpecs: true })for docs/tooling-only finalization; this corresponds toopenspec archive <change-id> --yes --skip-specs --no-color. - Support the user-facing
--skip-specspath while still writing final QA evidence and final summaries. - If OpenSpec CLI is missing or unsupported and archive is required, fail with an explicit OpenSpec CLI requirement.
- Do not archive in
/aif-verify;/aif-verifydoes not archive and only records verification evidence. - Do not use legacy
.ai-factory/specsarchive in OpenSpec-native mode. - OpenSpec-native mode does not use legacy
.ai-factory/specsarchive. - Do not silently archive OpenSpec changes through legacy
.ai-factory/specs. - Do not write runtime-only output into
openspec/changes/<change-id>/. - Do not directly mutate
openspec/specs/**or manually move OpenSpec change folders.
OpenSpec-Native Output
Normal output must report:
- selected
change-id; - verification status and refusal reason when unverified;
- dirty working tree state;
- archive result;
- canonical artifacts inspected;
- generated rules state when relevant;
- runtime state and QA evidence paths;
- final evidence under
.ai-factory/qa/<change-id>/; - final summaries under
.ai-factory/state/<change-id>/; - commit/PR summary draft;
- next steps:
/aif-mode sync,/aif-commit, and optional/aif-evolve.
Post-Finalization Handoff
After successful finalization:
- Recommend
/aif-mode syncto refresh derived artifacts after archive. - Recommend
/aif-commitas the next AI Factory command. - Optionally recommend
/aif-evolvewhen durable learning evidence exists. - Do not create commits automatically.
- Do not create PRs automatically.
/aif-donedoes not replace/aif-commit.
Legacy AI Factory-only mode
Legacy AI Factory-only mode preserves the verified plan finalization contract based on .ai-factory/plans/<plan-id>/ and .ai-factory/specs/<plan-id>/.
Precondition
- Active plan must have a passing verification state (
passorpass-with-notes). - If verification has not run or verdict is
fail, this skill stops and suggests running/aif-verifyfirst.
Workflow
Step 1: Validate Precondition
- Resolve the active plan (same resolution logic as
/aif-implement). - Read
status.yamland checkverification.verdict. - If verdict is missing or not
pass/pass-with-notes:- Stop with message: "Plan has not passed verification. Run
/aif-verifyfirst."
- Stop with message: "Plan has not passed verification. Run
- Check workspace state:
- If
git statusshows uncommitted changes outside the current plan scope:- Stop and ask the user to confirm or clean up.
- Only plan-related changes (files touched by the plan's implementation) are acceptable without confirmation.
- If
Step 2: Archive Plan
- Resolve archive path:
.ai-factory/specs/<plan-id>/. - Idempotency check: If
.ai-factory/specs/<plan-id>/already exists:- Treat the run as a refresh/finalize-again pass.
- Rebuild
spec.md, refresh the index entry, and regenerate commit/PR/follow-up outputs from current plan evidence. - If the archive came from legacy
/aif-verifyauto-archive behavior, adopt it instead of failing or blindly re-copying. - Inform the user that finalization is refreshing an existing archive.
- If archive does not exist:
- Copy plan folder contents (minus
status.yamlexecution metadata) into the archive. - Archive the companion plan file as
plan.mdalongside the folder artifacts.
- Copy plan folder contents (minus
- Create or update
spec.mdsummarizing what was implemented, if part of the current contract. - Update
.ai-factory/specs/index.yamlwith the new entry.
Step 3: Prepare Commit Message
- Analyze all changes made under this plan.
- Draft a conventional commit message summarizing the implementation.
- Present the draft to the user for review.
Step 4: Prepare PR Summary (if applicable)
- Check if a feature branch exists (branch != main/master).
- If
ghCLI is available:- Draft PR title and body based on plan scope and implementation evidence.
- Present the draft; do not create the PR automatically.
- If
ghis not available:- Output manual PR instructions with the drafted title and body.
Step 5: Apply Evidence-Driven Follow-ups
- Check plan for evidence of:
- roadmap milestone completion or maturity movement;
- new architecture decisions, boundaries, or modules;
- new or modified durable project rules;
- evolution candidates worth feeding into
/aif-evolve.
- Apply follow-ups only when the evidence exists:
- Roadmap -> update through the roadmap owner or return an exact
/aif-roadmaphandoff. - Architecture -> update through the architecture owner or return an exact
/aif-architecturehandoff. - Rules -> update the project rules owner path or return an exact handoff if direct update is not safe in the current runtime.
- Roadmap -> update through the roadmap owner or return an exact
- If the current runtime cannot safely perform the owner update, do not silently skip it — return the exact next command/instruction instead.
- Run
/aif-evolvewhen the user explicitly asked for integrated finalization and the runtime can chain the action; otherwise propose it as the next step. - Never invent governance changes that are not supported by plan evidence.
Step 6: Mark Plan Done
- Update
status.yaml:- Set
status: done. - Record finalization timestamp.
- Set
- Output completion summary:
- Archive path.
- Commit message draft.
- PR summary draft (or manual instructions).
- Governance updates performed or exact handoffs prepared.
/aif-evolveaction taken or recommended.
Ownership Boundary
| Artifact | Owner | This Skill |
|---|---|---|
openspec/changes/<change-id>/ | OpenSpec-native workflow | Reads before archive; OpenSpec CLI owns lifecycle mutation |
.ai-factory/qa/<change-id>/ | /aif-verify and aif-done | Reads verification evidence; writes done.md, openspec-archive.json, and raw archive output |
.ai-factory/state/<change-id>/ | OpenSpec-native runtime and aif-done | Reads traces; writes final-summary.md |
.ai-factory/specs/<plan-id>/ | aif-done legacy mode only | Creates or refreshes on legacy finalization |
.ai-factory/specs/index.yaml | aif-done | Updates |
.ai-factory/plans/<plan-id>/status.yaml | aif-done | Updates status: done |
| Commit/PR drafts | aif-done | Outputs to user |
.ai-factory/ROADMAP.md | roadmap owner | Update only with plan-backed evidence; otherwise hand off |
.ai-factory/RULES.md | project rules owner | Update only for durable plan-backed rules; otherwise hand off |
.ai-factory/ARCHITECTURE.md | architecture owner | Update only with plan-backed evidence; otherwise hand off |
Rules
- Never finalize a plan that has not passed verification.
- In OpenSpec-native mode, never finalize an unverified change.
- In OpenSpec-native mode, archive only through
archiveOpenSpecChange; never use custom OpenSpec archive logic. - In OpenSpec-native mode, never silently archive through legacy
.ai-factory/specs. - Never invent governance changes without evidence from the verified plan.
- When governance updates belong to another owner, use the owning path or return an exact handoff instead of silently skipping the change.
- Never auto-create a PR — always present drafts for user approval.
- Never create commits from
/aif-done; hand commit creation to/aif-commitor the user's
Content truncated.