$npx -y skills add armelhbobdad/bmad-module-skill-forge --skill skf-refine-architectureImprove architecture doc using verified skill data and VS feasibility findings. Use when the user requests to "refine skill architecture" or "improve architecture doc.
| 1 | # Refine Architecture |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Takes an original architecture document + generated skills + optional VS feasibility report, and produces a refined architecture with gaps filled, issues flagged, and improvements suggested — all backed by specific API evidence from the generated skills. This workflow enhances the original architecture — it never deletes original content, only adds annotations, subsections, and suggestions. |
| 6 | |
| 7 | ## Conventions |
| 8 | |
| 9 | - Bare paths (e.g. `references/<name>.md`) resolve from the skill root. |
| 10 | - `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. |
| 11 | - `{skill-root}` resolves to this skill's installed directory (where `customize.toml` lives, if present). |
| 12 | - `{project-root}`-prefixed paths resolve from the project working directory. |
| 13 | - `{skill-name}` resolves to the skill directory's basename. |
| 14 | |
| 15 | ## Role |
| 16 | |
| 17 | You are an architecture refinement analyst operating in Ferris Architect mode. You bring expertise in API surface analysis, integration gap detection, and evidence-backed architecture improvement, while the user brings their architecture vision and generated skills. Every suggestion must cite specific APIs from the generated skills — evidence-backed suggestions, not speculation. |
| 18 | |
| 19 | ## Workflow Rules |
| 20 | |
| 21 | These rules apply to every step in this workflow: |
| 22 | |
| 23 | - Never speculate — every gap, issue, or improvement must cite specific APIs, types, or function signatures from the generated skills |
| 24 | - Only load one step file at a time — never preload future steps |
| 25 | - If any instruction references a subprocess or tool you lack, achieve the outcome in your main context thread |
| 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 | Initialize & Load Inputs | references/init.md | No (confirm) | |
| 35 | | 2 | Gap Analysis | references/gap-analysis.md | Yes | |
| 36 | | 3 | Issue Detection | references/issue-detection.md | Yes | |
| 37 | | 4 | Improvements | references/improvements.md | Yes | |
| 38 | | 5 | Compile Refined Architecture | references/compile.md | No (review) | |
| 39 | | 6 | Report | references/report.md | Yes | |
| 40 | | 7 | Workflow Health Check | references/health-check.md | Yes | |
| 41 | |
| 42 | ## Invocation Contract |
| 43 | |
| 44 | | Aspect | Detail | |
| 45 | |--------|--------| |
| 46 | | **Inputs** | architecture_doc_path [required], vs_report_path [optional] | |
| 47 | | **Flags** | `--headless` / `-H` (auto-resolve all gates); `--architecture-doc <path>` (skip step 1 prompt for the required input); `--vs-report-path <path>` (skip step 1 prompt for the optional VS report); `--scope-skills <names>` (comma-separated in-scope skill names; overrides scope derivation in gap analysis) | |
| 48 | | **Gates** | step 1: Input Gate [use args] | step 5: Review Gate [C] continue / [X] cancel | step 6: Exit menu [R] review / [X] exit | |
| 49 | | **Outputs** | `refined-architecture-{arch_project_name}.md` at `{outputFolderPath}` (`{arch_project_name}` = the architecture doc's frontmatter `project_name`, else config `project_name` — resolved in init.md), plus `refine-architecture-result-{timestamp}.json` and `refine-architecture-result-latest.json` | |
| 50 | | **Headless** | All gates auto-resolve with default action when `{headless_mode}` is true. Per-flag args (`--architecture-doc`, `--vs-report-path`) consumed at the gates that would otherwise prompt. | |
| 51 | | **Exit codes** | See "Exit Codes" below | |
| 52 | |
| 53 | ## Exit Codes |
| 54 | |
| 55 | Every HARD HALT in this workflow exits with a stable code so headless automators can branch on the failure class without grepping message text: |
| 56 | |
| 57 | | Code | Meaning | Raised by | |
| 58 | | ---- | -------------------- | -------------------------------------------------------------------------------------------- | |
| 59 | | 0 | success | step 7 (terminal) | |
| 60 | | 2 | input-missing / input-invalid | step 1 §1 (headless missing `architecture-doc` arg, or invalid path) → `input-missing`; non-existent file → `input-invalid` | |
| 61 | | 3 | resolution-failure | On-Activation §5 (`output_folder` or `forge_data_folder` unconfigured) | |
| 62 | | 4 | write-failure | On-Activation §5 pre-flight write probe; step 1 §3c (RA state file write failed); step 5 §6 (refined-architecture write failed); step 6 §3 (result-contract write failed) | |
| 63 | | 5 | state-conflict | |