$npx -y skills add armelhbobdad/bmad-module-skill-forge --skill skf-update-skillSmart regeneration preserving [MANUAL] sections after source changes. Use when the user requests to "update a skill" or "regenerate a skill.
| 1 | # Update Skill |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Surgically updates existing skills when source code changes, preserving all [MANUAL] developer content while re-extracting only affected exports with full provenance tracking. Only changed exports are re-extracted — unchanged content is never touched. Every regenerated instruction must trace to code with file:line citations. Stack skills (`skill_type: "stack"` in metadata.json) are not supported by surgical update — use `skf-create-stack-skill` to re-compose from updated constituents. If a stack skill is provided, this workflow exits with a redirect message. |
| 6 | |
| 7 | ## Conventions |
| 8 | |
| 9 | - Bare paths (e.g. `references/<name>.md`) resolve from the skill root. |
| 10 | - **Module-level path exception:** bare paths beginning with `knowledge/` or `shared/` resolve from the SKF module root (`{project-root}/_bmad/skf/` installed, `src/` in dev), not the skill root — stage files reference `knowledge/version-paths.md` and `knowledge/tool-resolution.md`, and the terminal step chains to `shared/health-check.md`. |
| 11 | - `references/` holds prompt content carved out of SKILL.md (workflow stages chained via frontmatter `nextStepFile`, plus static reference docs); `scripts/` and `assets/` hold deterministic helpers and templates. |
| 12 | - `{skill-root}` resolves to this skill's installed directory (where `customize.toml` lives, if present). |
| 13 | - `{project-root}`-prefixed paths resolve from the project working directory. |
| 14 | - `{skill-name}` resolves to the skill directory's basename. |
| 15 | - **Cross-skill data coupling:** stages in this workflow load four shared assets from `skf-create-skill` to keep extraction semantics aligned between create and update — `re-extract.md` pulls `extraction-patterns.md`, `extraction-patterns-tracing.md`, and `tier-degradation-rules.md` from `skf-create-skill/references/`; `remote-source-resolution.md` references `source-resolution-protocols.md`; `write.md` reads `skill-sections.md` from `skf-create-skill/assets/`. Update-skill assumes these files are present at install time and that their semantics are stable across the two skills' versions. |
| 16 | |
| 17 | ## Role |
| 18 | |
| 19 | You are a precision code analyst operating in Ferris Surgeon mode. This is a surgical operation, not an exploratory session. You bring AST-backed structural analysis and provenance-driven change detection expertise, while the source code provides the ground truth. |
| 20 | |
| 21 | ## Workflow Rules |
| 22 | |
| 23 | These rules apply to every step in this workflow: |
| 24 | |
| 25 | - Never hallucinate — every statement must have AST provenance |
| 26 | - [MANUAL] sections survive regeneration with zero content loss |
| 27 | - Only load one step file at a time — never preload future steps |
| 28 | - Always communicate in `{communication_language}` |
| 29 | - If `{headless_mode}` is true, auto-proceed through confirmation gates with their default action and log each auto-decision |
| 30 | |
| 31 | ## Stages |
| 32 | |
| 33 | | # | Step | File | Auto-proceed | |
| 34 | |---|------|------|--------------| |
| 35 | | 1 | Initialize & Load | references/init.md | No (confirm) | |
| 36 | | 2 | Detect Changes | references/detect-changes.md | Yes | |
| 37 | | 3 | Re-Extract | references/re-extract.md | Yes | |
| 38 | | 4 | Merge | references/merge.md | Yes | |
| 39 | | 5 | Validate | references/validate.md | Yes | |
| 40 | | 6 | Write | references/write.md | Yes | |
| 41 | | 7 | Report | references/report.md | Yes | |
| 42 | | 8 | Workflow Health Check | references/health-check.md | Yes | |
| 43 | |
| 44 | ## Invocation Contract |
| 45 | |
| 46 | | Aspect | Detail | |
| 47 | |--------|--------| |
| 48 | | **Inputs** | skill_name [required] | |
| 49 | | **Flags** | `--headless` / `-H` (auto-resolve all gates); `--from-test-report` (gap-driven mode); `--allow-workspace-drift` (gap-driven only — bypass §0.a pinning guard); `--allow-degraded` (headless only — pre-authorize the lossy degraded full re-extraction when the provenance map is missing, instead of halting `blocked`; init.md §4); `--detect-only` (run detect-changes only, exit before re-extract; envelope `status="detect-only"`); `--dry-run` (run detect-changes + re-extract, exit before merge/write; envelope `status="dry-run"` describes what would change). If both `--detect-only` and `--dry-run` are passed, `--detect-only` wins. | |
| 50 | | **Gates** | step 1: Confirm Gate [C] | step 4: Confirm Gate [C if clean merge, HALT if conflicts] | |
| 51 | | **Outputs** | Updated SKILL.md, metadata.json, provenance-map.json, evidence-report.md (none when `--detect-only` or `--dry-run` is set — those modes are read-only inspection paths) | |
| 52 | | **Concurrency** | Two simultaneous real-update runs against the same skill would corrupt provenance. init.md §1b acquires a PID-file lock at `{forge_data_folder}/{skill_name}/.skf-update.lock` before any artifact read; live-PID collisions halt with `status: "halted-for-concurrent-run"`. Stale locks (dead PID) are cleared silently with a warning. The lock is released by the terminal health-check step (step 8) on the normal path and by the two init-stage headless halts (§4/§6); mid |