skf-refine-architecture
Improve architecture doc using verified skill data and VS feasibility findings. Use when the user requests to "refine skill architecture" or "improve architecture doc."
Install
npx skills add https://github.com/armelhbobdad/bmad-module-skill-forge/tree/main/src/skf-refine-architecture
claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install armelhbobdad-bmad-module-skill-forge@llmmart
git clone https://github.com/armelhbobdad/bmad-module-skill-forge.git
The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole armelhbobdad/bmad-module-skill-forge collection as a plugin from our marketplace. Git is the plain clone.
Skill manifest
Refine Architecture
Overview
Produces a refined architecture document: gaps filled, issues flagged and improvements suggested from the generated skills and an optional VS feasibility report. It never deletes original content, only adds annotations, subsections and suggestions between <!-- RA:BEGIN ... --> and <!-- RA:END --> marker lines; run again on a refined document, it sets its earlier annotations aside and writes one current set.
Conventions
- Bare paths (e.g.
references/<name>.md) resolve from the skill root, inside areferences/file too: only a stage's frontmatternextStepFilenames a file beside it. references/holds the workflow stages, chained by frontmatternextStepFile, and the files they load:finding-storage.md(steps 2 to 5),refinement-rules.mdandexit-codes.md.- Module-level path exception: bare paths beginning with
knowledge/orshared/resolve from the SKF module root ({project-root}/_bmad/skf/installed,src/in dev), not the skill root. - Sibling skills: a path that names another SKF skill's folder (
skf-<name>/...) resolves from the SKF module root, and that skill must be installed with this one. {skill-root}resolves to this skill's installed directory (wherecustomize.tomllives, if present).{project-root}-prefixed paths resolve from the project working directory.{skill-name}resolves to the skill directory's basename.
Role
You are an architecture refinement analyst in Ferris Architect mode; the user brings the architecture vision and the generated skills.
Workflow Rules
- Never speculate — every gap, issue, or improvement must cite specific APIs, types, or function signatures from the generated skills
- Only load one step file at a time — never preload future steps
- Run every subagent in the foreground, passing
run_in_background: falseon every Agent call (Claude Code runs a subagent in the background when the flag is left out), with parallel ones as several such calls in one message, and wait for every long-running command to exit before the next instruction; in a headless run, never end a turn while either still runs, since underclaude -pa run stops when its turn ends. - Always communicate in
{communication_language} - At any interactive prompt, the inputs
cancel,exit,[X],q, or:qexit cleanly with exit code 6 (halt_reason: "user-cancelled") - If
{headless_mode}is true, auto-proceed through confirmation gates with their default action; a gate that picks its default records that decision in the run sink the moment it decides - Every HARD HALT names its exit code,
halt_reasonand phase, and in headless mode prints the envelope the Result Contract below describes - Run state lives in
{run_dir}, not in context; step 6 deletes it when the run finishes, a HALT keeps it
Stages
| # | Step | File | Auto-proceed |
|---|---|---|---|
| 1 | Initialize & Load Inputs | references/init.md | No (input gate) |
| 2 | Gap Analysis | references/gap-analysis.md | Conditional (confirm a derived scope) |
| 3 | Issue Detection | references/issue-detection.md | Yes |
| 4 | Improvements | references/improvements.md | Yes |
| 5 | Compile Refined Architecture | references/compile.md | No (review) |
| 6 | Report | references/report.md | Yes |
| 7 | Workflow Health Check | references/health-check.md | Yes |
Invocation Contract
| Aspect | Detail | ||
|---|---|---|---|
| Inputs | architecture_doc_path [required], vs_report_path [optional] | ||
| Flags | --headless / -H; --architecture-doc <path> and --vs-report-path <path> answer the step 1 prompts (--vs-report-path none refines without a report and skips the search for one); --scope-skills <names> (comma-separated skill names that replace the derived scope, so step 2 asks no scope confirmation) |
||
| Gates | step 1: Input Gate [use args], Resume Gate [R]/[N] (interactive) | step 2: Scope Confirm Gate [C] continue / [X] cancel (when a derived scope drops skills or keeps an ambiguous one, or the document names no skill) | step 5: Review Gate [R] review each refinement / [C] approve and replace the refined document / [X] cancel |
| Outputs | refined-architecture-{arch_project_name}.md at {outputFolderPath} (the document's frontmatter project_name, else config's), promoted from a draft once the step 5 review approves it; an earlier one is first renamed to refined-architecture-{arch_project_name}-{timestamp}.md. Also refine-architecture-result-{YYYYMMDD-HHmmss}.json, its -latest.json copy and, once an approved review drops a finding, .ra-dismissed-{arch_project_name}.json |
||
| Headless | Every gate takes its default when {headless_mode} is true: --scope-skills skips the step 2 scope confirmation, and without --vs-report-path step 1 uses the [VS] report it finds. A caller reads the run's own SKF_REFINE_ARCHITECTURE_RESULT_JSON line. A run that printed no envelope line has no result to read, whatever the process exit code: it was cut off, or could not write its result, and refine-architecture-result-latest.json may then describe an earlier run, so it is never read in its place. |
Result Contract (Headless)
When {headless_mode} is true, a run ends on one SKF_REFINE_ARCHITECTURE_RESULT_JSON: {...} line on stdout, and every HARD HALT one on stderr, built by the shared emitter: references/exit-codes.md gives its fields, the halt_reason values and the halt command.
On Activation
Load config from
{project-root}/_bmad/skf/config.yamland resolve:project_name,user_name,communication_language,document_output_languageskills_output_folder,forge_data_folder,output_folder,sidecar_path
Compute run-scoped variables:
timestamp← the output ofdate -u +%Y%m%d-%H%M%S, run once now.run_dir←{project-root}/_bmad-output/.skf-run/skf-refine-architecture-{timestamp}
Resolve
{headless_mode}: true if--headlessor-Hwas passed as an argument, or ifheadless_mode: truein{sidecar_path}/preferences.yaml. Default: false.Resolve workflow customization. Bind
{resolveCustomizationHelper}←{project-root}/_bmad/skf/shared/scripts/skf-resolve-customization.py, else{project-root}/src/shared/scripts/skf-resolve-customization.py(the first that exists), and run:uv run {resolveCustomizationHelper} --skill {skill-root} --project-root {project-root} --key workflow --factsIt merges the bundled
{skill-root}/customize.tomlwith{project-root}/_bmad/custom/skf-refine-architecture.toml(team overrides, committed) and.user.toml(personal overrides, gitignored). When it exits non-zero, prints no JSON or is missing, print one line,[activation/warn] customization_resolver_unavailable: <reason>(<reason>: its first stderr line,SKF helper skf-resolve-customization.py not foundwhen the script is missing,no JSONwhen it printed none). If the resolver cannot run, read{skill-root}/customize.tomlalone and use its bundled defaults: the{project-root}/_bmad/custom/overrides do not apply to this run. In that case keep the reason as{customization_resolver_unavailable}for init.md §0 to record once it has created{run_dir}.Bind each path scalar, taking the bundled default when the merged value is empty or absent:
{refinementRulesPath}←workflow.refinement_rules_pathif non-empty, elsereferences/refinement-rules.md(house style only: the file's first section names what a copy can change){outputFolderPath}←workflow.output_folder_pathif non-empty, else{output_folder}{onCompleteCommand}←workflow.on_completeif non-empty, else empty
Then run
workflow.activation_steps_prependnow, treatworkflow.persistent_factsas standing context for the run (the bundled default loads everyproject-context.mdunder{project-root}, none in{project-root}/_bmad-output/.skf-run/; if the resolver ran,--factshas applied each!entry, which drops each earlier entry it names, and expanded each glob, so afile:entry names one file); init.md §0 runsworkflow.activation_steps_appendonce its pre-flight has passed.Pre-flight: the emitter. Resolve
{emitEnvelopeHelper}←{project-root}/_bmad/skf/shared/scripts/skf-emit-result-envelope.py, else{project-root}/src/shared/scripts/skf-emit-result-envelope.py(the first that exists), so every halt can print its envelope. If neither exists, HALT (exit code 3,halt_reason: "resolution-failure") at phaseon-activation:emitterand display only: "Refine Architecture cannot run withoutskf-emit-result-envelope.py, which is not installed. Re-install SKF."The halts of init.md §0 (the config, the write probe and the run folder) come before the run folder, so in headless mode each passes its payload on stdin, with
"customization_resolver_unavailable": "<reason>"added when step 4 kept one:uv run {emitEnvelopeHelper} emit-halt --workflow skf-refine-architecture --target stderr <<'SKF_RA_HALT' {"phase": "<phase>", "reason": "<the halt message>", "halt_reason": "<halt_reason>"} SKF_RA_HALTLoad, read the full file, and then execute
references/init.mdto begin the workflow.
Files (bmad-module-skill-forge)
-
references
-
compile.md 18.4 KB
Loading… -
exit-codes.md 6.3 KB
Loading… -
finding-storage.md 3.7 KB
Loading… -
gap-analysis.md 23.4 KB
Loading… -
health-check.md 897 B
Loading… -
improvements.md 4 KB
Loading… -
init.md 28 KB
Loading… -
issue-detection.md 12.9 KB
Loading… -
refinement-rules.md 8.3 KB
Loading… -
report.md 10.5 KB
Loading…
-
-
scripts
-
skf-check-preservation.py 87.1 KB
Loading…
-
-
customize.toml 4.8 KB
Loading… -
SKILL.md 9.4 KB
--- name: skf-refine-architecture description: Refines an architecture document against generated skills and a Verify Stack report. Use when the user requests to "refine the architecture against generated skills" or "refine an architecture doc with a VS report." --- # Refine Architecture ## Overview Produces a refined architecture document: gaps filled, issues flagged and improvements suggested from the generated skills and an optional VS feasibility report. It never deletes original content, only adds annotations, subsections and suggestions between `<!-- RA:BEGIN ... -->` and `<!-- RA:END -->` marker lines; run again on a refined document, it sets its earlier annotations aside and writes one current set. ## Conventions - Bare paths (e.g. `references/<name>.md`) resolve from the skill root, inside a `references/` file too: only a stage's frontmatter `nextStepFile` names a file beside it. - `references/` holds the workflow stages, chained by frontmatter `nextStepFile`, and the files they load: `finding-storage.md` (steps 2 to 5), `refinement-rules.md` and `exit-codes.md`. - **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. - **Sibling skills:** a path that names another SKF skill's folder (`skf-<name>/...`) resolves from the SKF module root, and that skill must be installed with this one. - `{skill-root}` resolves to this skill's installed directory (where `customize.toml` lives, if present). - `{project-root}`-prefixed paths resolve from the project working directory. - `{skill-name}` resolves to the skill directory's basename. ## Role You are an architecture refinement analyst in Ferris Architect mode; the user brings the architecture vision and the generated skills. ## Workflow Rules - Never speculate — every gap, issue, or improvement must cite specific APIs, types, or function signatures from the generated skills - Only load one step file at a time — never preload future steps - Run every subagent in the foreground, passing `run_in_background: false` on every Agent call (Claude Code runs a subagent in the background when the flag is left out), with parallel ones as several such calls in one message, and wait for every long-running command to exit before the next instruction; in a headless run, never end a turn while either still runs, since under `claude -p` a run stops when its turn ends. - Always communicate in `{communication_language}` - At any interactive prompt, the inputs `cancel`, `exit`, `[X]`, `q`, or `:q` exit cleanly with exit code 6 (`halt_reason: "user-cancelled"`) - If `{headless_mode}` is true, auto-proceed through confirmation gates with their default action; a gate that picks its default records that decision in the run sink the moment it decides - Every HARD HALT names its exit code, `halt_reason` and phase, and in headless mode prints the envelope the Result Contract below describes - Run state lives in `{run_dir}`, not in context; step 6 deletes it when the run finishes, a HALT keeps it ## Stages | # | Step | File | Auto-proceed | |---|------|------|--------------| | 1 | Initialize & Load Inputs | references/init.md | No (input gate) | | 2 | Gap Analysis | references/gap-analysis.md | Conditional (confirm a derived scope) | | 3 | Issue Detection | references/issue-detection.md | Yes | | 4 | Improvements | references/improvements.md | Yes | | 5 | Compile Refined Architecture | references/compile.md | No (review) | | 6 | Report | references/report.md | Yes | | 7 | Workflow Health Check | references/health-check.md | Yes | ## Invocation Contract | Aspect | Detail | |--------|--------| | **Inputs** | architecture_doc_path [required], vs_report_path [optional] | | **Flags** | `--headless` / `-H`; `--architecture-doc <path>` and `--vs-report-path <path>` answer the step 1 prompts (`--vs-report-path none` refines without a report and skips the search for one); `--scope-skills <names>` (comma-separated skill names that replace the derived scope, so step 2 asks no scope confirmation) | | **Gates** | step 1: Input Gate [use args], Resume Gate [R]/[N] (interactive) | step 2: Scope Confirm Gate [C] continue / [X] cancel (when a derived scope drops skills or keeps an ambiguous one, or the document names no skill) | step 5: Review Gate [R] review each refinement / [C] approve and replace the refined document / [X] cancel | | **Outputs** | `refined-architecture-{arch_project_name}.md` at `{outputFolderPath}` (the document's frontmatter `project_name`, else config's), promoted from a draft once the step 5 review approves it; an earlier one is first renamed to `refined-architecture-{arch_project_name}-{timestamp}.md`. Also `refine-architecture-result-{YYYYMMDD-HHmmss}.json`, its `-latest.json` copy and, once an approved review drops a finding, `.ra-dismissed-{arch_project_name}.json` | | **Headless** | Every gate takes its default when `{headless_mode}` is true: `--scope-skills` skips the step 2 scope confirmation, and without `--vs-report-path` step 1 uses the [VS] report it finds. A caller reads the run's own `SKF_REFINE_ARCHITECTURE_RESULT_JSON` line. A run that printed no envelope line has no result to read, whatever the process exit code: it was cut off, or could not write its result, and `refine-architecture-result-latest.json` may then describe an earlier run, so it is never read in its place. | ## Result Contract (Headless) When `{headless_mode}` is true, a run ends on one `SKF_REFINE_ARCHITECTURE_RESULT_JSON: {...}` line on **stdout**, and every HARD HALT one on **stderr**, built by the shared emitter: `references/exit-codes.md` gives its fields, the `halt_reason` values and the halt command. ## On Activation 1. Load config from `{project-root}/_bmad/skf/config.yaml` and resolve: - `project_name`, `user_name`, `communication_language`, `document_output_language` - `skills_output_folder`, `forge_data_folder`, `output_folder`, `sidecar_path` 2. **Compute run-scoped variables:** - `timestamp` ← the output of `date -u +%Y%m%d-%H%M%S`, run once now. - `run_dir` ← `{project-root}/_bmad-output/.skf-run/skf-refine-architecture-{timestamp}` 3. **Resolve `{headless_mode}`**: true if `--headless` or `-H` was passed as an argument, or if `headless_mode: true` in `{sidecar_path}/preferences.yaml`. Default: false. 4. **Resolve workflow customization.** Bind `{resolveCustomizationHelper}` ← `{project-root}/_bmad/skf/shared/scripts/skf-resolve-customization.py`, else `{project-root}/src/shared/scripts/skf-resolve-customization.py` (the first that exists), and run: ```bash uv run {resolveCustomizationHelper} --skill {skill-root} --project-root {project-root} --key workflow --facts ``` It merges the bundled `{skill-root}/customize.toml` with `{project-root}/_bmad/custom/skf-refine-architecture.toml` (team overrides, committed) and `.user.toml` (personal overrides, gitignored). When it exits non-zero, prints no JSON or is missing, print one line, `[activation/warn] customization_resolver_unavailable: <reason>` (`<reason>`: its first stderr line, `SKF helper skf-resolve-customization.py not found` when the script is missing, `no JSON` when it printed none). If the resolver cannot run, read `{skill-root}/customize.toml` alone and use its bundled defaults: the `{project-root}/_bmad/custom/` overrides do not apply to this run. In that case keep the reason as `{customization_resolver_unavailable}` for init.md §0 to record once it has created `{run_dir}`. Bind each path scalar, taking the bundled default when the merged value is empty or absent: - `{refinementRulesPath}` ← `workflow.refinement_rules_path` if non-empty, else `references/refinement-rules.md` (house style only: the file's first section names what a copy can change) - `{outputFolderPath}` ← `workflow.output_folder_path` if non-empty, else `{output_folder}` - `{onCompleteCommand}` ← `workflow.on_complete` if non-empty, else empty Then run `workflow.activation_steps_prepend` now, treat `workflow.persistent_facts` as standing context for the run (the bundled default loads every `project-context.md` under `{project-root}`, none in `{project-root}/_bmad-output/.skf-run/`; if the resolver ran, `--facts` has applied each `!` entry, which drops each earlier entry it names, and expanded each glob, so a `file:` entry names one file); init.md §0 runs `workflow.activation_steps_append` once its pre-flight has passed. 5. **Pre-flight: the emitter.** Resolve `{emitEnvelopeHelper}` ← `{project-root}/_bmad/skf/shared/scripts/skf-emit-result-envelope.py`, else `{project-root}/src/shared/scripts/skf-emit-result-envelope.py` (the first that exists), so every halt can print its envelope. If neither exists, HALT (exit code 3, `halt_reason: "resolution-failure"`) at phase `on-activation:emitter` and display only: "Refine Architecture cannot run without `skf-emit-result-envelope.py`, which is not installed. Re-install SKF." The halts of init.md §0 (the config, the write probe and the run folder) come before the run folder, so in headless mode each passes its payload on stdin, with `"customization_resolver_unavailable": "<reason>"` added when step 4 kept one: ```bash uv run {emitEnvelopeHelper} emit-halt --workflow skf-refine-architecture --target stderr <<'SKF_RA_HALT' {"phase": "<phase>", "reason": "<the halt message>", "halt_reason": "<halt_reason>"} SKF_RA_HALT ``` 6. Load, read the full file, and then execute `references/init.md` to begin the workflow.
Comments (0)
Sign in to join the conversation.
Reviews (0)
No reviews yet.
No comments yet.