src/skills/x-close-feature/SKILL.md
Closes a feature: validates all stories are MERGED into feature/XXXX, syncs develop, opens the final PR to develop, and generates the memory summary.
npx skillsauth add edercnj/claude-environment x-close-featureInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Closes a feature whose stories were implemented one by one onto the integration branch
feature/XXXX (each via /x-implement-story <story> --target-branch feature/XXXX --auto-merge merge).
This skill is the only feature-level step that remains after the implementation orchestrator was
removed: it does NOT iterate stories, plan, or run reviews — those live entirely at story level
(x-implement-story Phase 3 / x-implement-task Phase 3.7).
It performs four bounded steps: (1) confirm every story of the feature is MERGED into the integration
branch, (2) sync develop into feature/XXXX, (3) open the final PR feature/XXXX → develop, and
(4) generate the feature memory summary.
Aggregated integrity gate = CI of the final PR. This skill intentionally does NOT re-run an aggregated test/coverage gate locally. The integration safety net is the CI that runs on the final PR opened in Phase 3. Per-story evidence (coverage, reviews, tech-lead GO) was already enforced by
x-implement-storybefore each story PR merged intofeature/XXXX.
/x-close-feature 0049 — validate, sync develop, open final PR, write summary
/x-close-feature 0049 --dry-run — run Phases 0-1 and PREVIEW Phases 2-3 without side effects
/x-close-feature 0049 --auto-merge squash — enable auto-merge (squash) on the final PR
/x-close-feature 0049 --skip-summary — skip the best-effort memory summary (Phase 4)
| Flag | Type | Default | Description |
|------|------|---------|-------------|
| FEATURE-ID | String (4-digit) | — | Positional, required. |
| --dry-run | Boolean | false | Validate (Phase 0-1) and preview the sync + PR body without merging, pushing, or creating the PR. |
| --auto-merge | Enum | none | Auto-merge strategy for the FINAL PR: merge\|squash\|rebase\|none. Default none keeps the feature→develop merge a human decision. |
| --skip-summary | Boolean | false | Skip Phase 4 (memory summary). |
Single-line JSON to stdout:
| Field | Description |
|-------|-------------|
| featureId | 4-digit identifier |
| featureBranch | feature/XXXX |
| allStoriesMerged | Boolean — Phase 1 result |
| developSynced | Boolean — Phase 2 result (mergeSha when a sync commit was created; noOp when already current) |
| finalPrUrl / finalPrNumber | Final PR feature/XXXX → develop (Phase 3); null on --dry-run |
| memorySummaryPath | .aikittools/memory/feature-XXXX-summary.md or null (Phase 4) |
Delegation Map (RULE-005 — zero inline orchestration shell):
| Concern | Skill | Phase |
|---------|-------|-------|
| Develop → feature sync | x-merge-branches | 2 |
| Final PR (feature → develop) | x-create-pr | 3 |
| Feature memory summary | inlined (§Feature Summary Procedure, SF1–SF5) | 4 |
| Phase | Name | Status | Bypass flag |
|-------|------|--------|-------------|
| 0 | Validate args + resolve feature dir | MANDATORY | — |
| 1 | Stories-Merged Gate | MANDATORY | — |
| 2 | Sync develop into feature branch | MANDATORY | --dry-run (preview only) |
| 3 | Final PR (feature → develop) | MANDATORY | --dry-run (preview only) |
| 4 | Feature memory summary (best-effort) | OPTIONAL | --skip-summary |
TaskCreate(subject: "FEAT-XXXX › Phase 0 - Validate", activeForm: "Validating feature closeout args")
Parse FEATURE-ID; require 4 digits, else exit 1 ARGS_INVALID.
Resolve the feature container: glob .aikittools/features/feature-XXXX-*/ (fallback .aikittools/features/feature-XXXX/). Absent → exit 2 FEATURE_DIR_MISSING.
Set featureBranch = feature/XXXX.
TaskUpdate(id: phase0TaskId, status: "completed")
TaskCreate(subject: "FEAT-XXXX › Phase 1 - Stories Merged", activeForm: "Checking all stories merged")
Read-only check: every story of the feature must be MERGED into the integration branch before the feature can be closed. Cross-reference two sources:
execution-state.json in the feature container — every story entry must report a terminal merged
status (MERGED / SUCCESS). The state file keeps its internal schema (--type feature node — unchanged).IMPLEMENTATION-MAP.md story index — confirm no story listed in the map is missing from the merged set.If any story is not merged → abort exit 3 STORIES_NOT_MERGED, printing the pending list:
STORIES_NOT_MERGED: the following stories must be implemented and merged into feature/XXXX first:
- story-XXXX-YYYY (<status>)
Run /x-implement-story story-XXXX-YYYY --target-branch feature/XXXX --auto-merge merge for each (start with the foundation story story-XXXX-0001).
Detailed jq/git resolution lives in references/full-protocol.md §Phase 1.
TaskUpdate(id: phase1TaskId, status: "completed")
TaskCreate(subject: "FEAT-XXXX › Phase 2 - Sync develop", activeForm: "Syncing develop into feature branch")
Bring the integration branch up to date with develop so the final PR is conflict-free:
Skill(skill: "x-merge-branches", model: "haiku", args: "--source develop --target <featureBranch> --strategy merge")
conflicts:true → abort exit 5 SYNC_CONFLICTS (resolve manually, then re-run).
noOp:true → developSynced=true (already current); proceed.
On --dry-run: skip the call; report the intended sync only.
TaskUpdate(id: phase2TaskId, status: "completed")
TaskCreate(subject: "FEAT-XXXX › Phase 3 - Final PR", activeForm: "Opening final PR to develop")
🔒 EXECUTION INTEGRITY (Rule 24): the
x-create-prcall below is a MANDATORY TOOL CALL (unless--dry-run).
Skill(skill: "x-create-pr", args: "--feature-id <ID> --head <featureBranch> --target-branch develop --auto-merge <strategy> --label feature-integration")
The CI that runs on this PR is the aggregated integration gate for the feature.
--auto-merge defaults to none (human merges feature → develop).
On --dry-run: render and print the PR body/title only; do not create the PR.
Non-zero exit from x-create-pr → exit 6 FINAL_PR_FAILED.
TaskUpdate(id: phase3TaskId, status: "completed")
TaskCreate(subject: "FEAT-XXXX › Phase 4 - Summary", activeForm: "Writing feature memory summary")
When governance.ai-memory is active and NOT --skip-summary, execute o §Feature Summary
Procedure (SF1–SF5) de
references/full-protocol.md, passando --feature-id <ID>. O
procedimento é determinístico: gera .aikittools/memory/feature-XXXX-summary.md e atualiza
.aikittools/memory/_index.yaml.
Exit handling: 0 = summary written; 7 = manual refinement present (human override) → proceed; any other non-zero → WARN and proceed (never blocks closeout).
TaskUpdate(id: phase4TaskId, status: "completed")
Skill-specific codes below. Canonical cross-skill exit-code families (
DEP_*dependency-unresolved,STATE_*state-file,RULE_*) live in_shared/exit-codes-common.md.
| Exit | Code | Condition |
|------|------|-----------|
| 0 | OK | Final PR created (summary best-effort) |
| 1 | ARGS_INVALID | FEATURE-ID absent or not 4 digits |
| 2 | FEATURE_DIR_MISSING | .aikittools/features/feature-XXXX*/ absent |
| 3 | STORIES_NOT_MERGED | Phase 1: one or more stories not merged into the feature branch |
| 5 | SYNC_CONFLICTS | Phase 2: x-merge-branches reported a conflict (exit 10) |
| 6 | FINAL_PR_FAILED | Phase 3: x-create-pr returned non-zero |
| Skill | Relationship | Context |
|-------|--------------|---------|
| x-implement-story | predecessor (per story) | Each story is implemented standalone onto feature/XXXX via --target-branch feature/XXXX --auto-merge merge (featureId auto-derived from storyId). Start with the foundation story story-XXXX-0001. |
| x-create-feature | upstream | Plans/refines the feature and its stories; ends pointing at story-by-story implementation then this closeout. |
| x-merge-branches | called (Phase 2) | develop → feature/XXXX sync. |
| x-create-pr | called (Phase 3) | Opens the final feature/XXXX → develop PR (CI = aggregated gate). |
| Feature Summary (Phase 4) | inlined | Best-effort memory summary; protocolo SF1–SF5 em references/full-protocol.md. |
| x-fix-pr | sibling | Per-PR remediation if the final PR's CI fails. |
Read src/knowledge/shared/governance-baselines/tool-call-grammar/knowledge.md
Minimum viable contract above. Detailed execution-state.json/IMPLEMENTATION-MAP resolution for the
Stories-Merged gate (Phase 1), the --dry-run preview semantics, and worked examples live in
references/full-protocol.md per ADR-0012 (skill body slim-by-default).
development
Documentation freshness gate: validates 6 dimensions (readme, api, adr, etc.) per PR.
testing
Conditional dep-policy gate: CVEs, licenses, versions, freshness; SARIF + report.
documentation
Incrementally updates the service or system architecture document; never regenerative.
development
Scans code and git history for leaked credentials, API keys, and tokens; SARIF output.