$npx -y skills add armelhbobdad/bmad-module-skill-forge --skill skf-export-skillPackage for distribution and inject context into CLAUDE.md/AGENTS.md/.cursorrules. Use when the user requests to "export" or "package a skill.
| 1 | # Export Skill |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Packages a completed skill as an agentskills.io-compliant package, generates context snippets, and updates the managed section in CLAUDE.md/.cursorrules/AGENTS.md for platform-aware context injection. It is the sole publishing gate — create-skill/update-skill produce drafts; only export writes platform context files and distribution packages. |
| 6 | |
| 7 | ## Conventions |
| 8 | |
| 9 | - Bare paths (e.g. `references/<name>.md`) resolve from the skill root. |
| 10 | - **Module-level path exception:** bare `knowledge/` and `shared/` paths resolve from the SKF module root (`{project-root}/_bmad/skf/` installed, `src/` in dev), not the skill root (e.g. `knowledge/version-paths.md`, `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:** `assets/managed-section-format.md` (loaded by drop-skill and rename-skill's `execute.md`) and `references/update-context.md` §4a (v2 manifest schema enforced by `skf-manifest-ops.py`) are the source of truth for those contracts — schema-breaking changes here need coordinated updates across those skills. |
| 16 | |
| 17 | ## Role |
| 18 | |
| 19 | You are a delivery and packaging specialist collaborating with a skill developer, pairing your skill-packaging, ecosystem-compliance, and context-injection expertise with their completed skill and distribution requirements. |
| 20 | |
| 21 | ## Workflow Rules |
| 22 | |
| 23 | These rules apply to every step in this workflow: |
| 24 | |
| 25 | - Only load one step file at a time — never preload future steps |
| 26 | - Always communicate in `{communication_language}` |
| 27 | - At any interactive prompt, the inputs `cancel`, `exit`, `[X]`, `q`, or `:q` exit cleanly with exit code 6 (`halt_reason: "user-cancelled"`) |
| 28 | - If `{headless_mode}` is true, auto-proceed through confirmation gates with their default action and log each auto-decision |
| 29 | |
| 30 | ## Stages |
| 31 | |
| 32 | | # | Step | File | Auto-proceed | |
| 33 | |---|------|------|--------------| |
| 34 | | 1 | Load Skill | references/load-skill.md | No (confirm) | |
| 35 | | 2 | Package | references/package.md | Yes | |
| 36 | | 3 | Generate Snippet | references/generate-snippet.md | Yes | |
| 37 | | 4 | Update Context | references/update-context.md | No (confirm) | |
| 38 | | 5 | Token Report | references/token-report.md | Yes | |
| 39 | | 6 | Summary | references/summary.md | Yes | |
| 40 | | 7 | Workflow Health Check | references/health-check.md | Yes | |
| 41 | |
| 42 | ## Invocation Contract |
| 43 | |
| 44 | | Aspect | Detail | |
| 45 | |--------|--------| |
| 46 | | **Inputs** | `skill_name` [one or more, required unless `--all`] | |
| 47 | | **Flags** | `--headless` / `-H` (auto-resolve all gates); `--all` (export every non-deprecated skill in `.export-manifest.json`); `--dry-run` (stage everything but write nothing — context files, manifest, and snippet are previewed only; the run completes read-only through the terminal step; `status="dry-run"`) | |
| 48 | | **Gates** | step 1: single Confirm Gate [C] for the whole batch | step 4: single Confirm Gate [C] for the whole batch | |
| 49 | | **Outputs** | Updated `.export-manifest.json` (every skill in the batch), updated context files (CLAUDE.md/AGENTS.md/.cursorrules), per-skill `context-snippet.md`, per-run result contract `export-skill-result-{timestamp}.json` and `export-skill-result-latest.json` | |
| 50 | | **Multi-skill mode** | Activated when more than one skill is selected (via `--all`, multi-selection, or multi-argument invocation). See `references/load-skill.md` §1c for the per-step iteration map. | |
| 51 | | **Headless** | All gates auto-resolve with default action when `{headless_mode}` is true. Each auto-resolved gate appends a `{gate, default_action, taken_action, reason}` entry to `headless_decisions[]`, surfaced in step 6's `SKF_EXPORT_RESULT_JSON` envelope so non-interactive runs can be audited post-hoc. | |
| 52 | | **Exit codes** | See "Exit Codes" below | |
| 53 | |
| 54 | ## Exit Codes |
| 55 | |
| 56 | Every HARD HALT in this workflow exits with a stable code so headless automators can branch on the failure class without grepping message text: |
| 57 | |
| 58 | | Code | Meaning | Raised by (halt site → `halt_reason`) | |
| 59 | | ---- | -------------------- | -------------------------------------------------------------------------------------------- | |
| 60 | | 0 | success | step 7 (terminal); also `status="dry-run"` when `--dry-run` is set | |
| 61 | | 2 | input-missing | step 1 §1 — headless run with no `skill_name` and no `--all` (a non-interactive run cannot answer the skill-selection menu) → `input-missing` | |
| 62 | | 3 | reso |