bmad-method 6.3.1-next.16 → 6.3.1-next.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/package.json +1 -1
  2. package/src/bmm-skills/1-analysis/bmad-document-project/workflows/deep-dive-instructions.md +1 -0
  3. package/src/bmm-skills/1-analysis/bmad-document-project/workflows/full-scan-instructions.md +1 -0
  4. package/src/bmm-skills/1-analysis/bmad-prfaq/customize.toml +22 -0
  5. package/src/bmm-skills/1-analysis/bmad-prfaq/references/verdict.md +4 -0
  6. package/src/bmm-skills/1-analysis/research/bmad-domain-research/customize.toml +22 -0
  7. package/src/bmm-skills/1-analysis/research/bmad-domain-research/domain-steps/step-06-research-synthesis.md +6 -0
  8. package/src/bmm-skills/1-analysis/research/bmad-market-research/customize.toml +26 -0
  9. package/src/bmm-skills/1-analysis/research/bmad-market-research/steps/step-06-research-completion.md +6 -0
  10. package/src/bmm-skills/1-analysis/research/bmad-technical-research/customize.toml +26 -0
  11. package/src/bmm-skills/1-analysis/research/bmad-technical-research/technical-steps/step-06-research-synthesis.md +6 -0
  12. package/src/bmm-skills/2-plan-workflows/bmad-create-prd/customize.toml +28 -1
  13. package/src/bmm-skills/2-plan-workflows/bmad-create-prd/steps-c/step-12-complete.md +6 -0
  14. package/src/bmm-skills/2-plan-workflows/bmad-create-ux-design/customize.toml +28 -1
  15. package/src/bmm-skills/2-plan-workflows/bmad-create-ux-design/steps/step-14-complete.md +6 -0
  16. package/src/bmm-skills/2-plan-workflows/bmad-edit-prd/customize.toml +29 -1
  17. package/src/bmm-skills/2-plan-workflows/bmad-edit-prd/steps-e/step-e-04-complete.md +2 -0
  18. package/src/bmm-skills/2-plan-workflows/bmad-validate-prd/customize.toml +29 -1
  19. package/src/bmm-skills/2-plan-workflows/bmad-validate-prd/steps-v/step-v-13-report-complete.md +1 -0
  20. package/src/bmm-skills/3-solutioning/bmad-check-implementation-readiness/customize.toml +28 -1
  21. package/src/bmm-skills/3-solutioning/bmad-check-implementation-readiness/steps/step-06-final-assessment.md +6 -0
  22. package/src/bmm-skills/3-solutioning/bmad-create-architecture/customize.toml +28 -1
  23. package/src/bmm-skills/3-solutioning/bmad-create-architecture/steps/step-08-complete.md +6 -0
  24. package/src/bmm-skills/3-solutioning/bmad-create-epics-and-stories/customize.toml +28 -1
  25. package/src/bmm-skills/3-solutioning/bmad-create-epics-and-stories/steps/step-04-final-validation.md +6 -0
  26. package/src/bmm-skills/3-solutioning/bmad-generate-project-context/customize.toml +28 -1
  27. package/src/bmm-skills/3-solutioning/bmad-generate-project-context/steps/step-03-complete.md +6 -0
  28. package/src/bmm-skills/4-implementation/bmad-correct-course/SKILL.md +1 -0
  29. package/src/bmm-skills/4-implementation/bmad-correct-course/customize.toml +28 -1
  30. package/src/bmm-skills/4-implementation/bmad-create-story/SKILL.md +1 -0
  31. package/src/bmm-skills/4-implementation/bmad-create-story/customize.toml +28 -1
  32. package/src/bmm-skills/4-implementation/bmad-qa-generate-e2e-tests/SKILL.md +6 -0
  33. package/src/bmm-skills/4-implementation/bmad-qa-generate-e2e-tests/customize.toml +28 -1
  34. package/src/bmm-skills/4-implementation/bmad-retrospective/SKILL.md +1 -1
  35. package/src/bmm-skills/4-implementation/bmad-retrospective/customize.toml +28 -1
  36. package/src/core-skills/bmad-customize/SKILL.md +111 -0
  37. package/src/core-skills/bmad-customize/scripts/list_customizable_skills.py +231 -0
  38. package/src/core-skills/bmad-customize/scripts/tests/test_list_customizable_skills.py +249 -0
  39. package/src/core-skills/module-help.csv +1 -0
@@ -276,3 +276,9 @@ Your project context will help ensure high-quality, consistent implementation ac
276
276
  This is the final step of the Generate Project Context workflow. The user now has a comprehensive, optimized project context file that will ensure consistent, high-quality implementation across all AI agents working on the project.
277
277
 
278
278
  The project context file serves as the critical "rules of the road" that agents need to implement code consistently with the project's standards and patterns.
279
+
280
+ ## On Complete
281
+
282
+ Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete`
283
+
284
+ If the resolved `workflow.on_complete` is non-empty, follow it as the final terminal instruction before exiting.
@@ -295,6 +295,7 @@ Activation is complete. Begin the workflow below.
295
295
 
296
296
  <action>Report workflow completion to user with personalized message: "Correct Course workflow complete, {user_name}!"</action>
297
297
  <action>Remind user of success criteria and next steps for Developer agent</action>
298
+ <action>Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete` — if the resolved value is non-empty, follow it as the final terminal instruction before exiting.</action>
298
299
  </step>
299
300
 
300
301
  </workflow>
@@ -1,14 +1,41 @@
1
1
  # DO NOT EDIT -- overwritten on every update.
2
2
  #
3
- # Workflow customization surface for bmad-correct-course.
3
+ # Workflow customization surface for bmad-correct-course. Mirrors the
4
+ # agent customization shape under the [workflow] namespace.
4
5
 
5
6
  [workflow]
6
7
 
8
+ # --- Configurable below. Overrides merge per BMad structural rules: ---
9
+ # scalars: override wins • arrays (persistent_facts, activation_steps_*): append
10
+ # arrays-of-tables with `code`/`id`: replace matching items, append new ones.
11
+
12
+ # Steps to run before the standard activation (config load, greet).
13
+ # Overrides append. Use for pre-flight loads, compliance checks, etc.
14
+
7
15
  activation_steps_prepend = []
16
+
17
+ # Steps to run after greet but before the workflow begins.
18
+ # Overrides append. Use for context-heavy setup that should happen
19
+ # once the user has been acknowledged.
20
+
8
21
  activation_steps_append = []
9
22
 
23
+ # Persistent facts the workflow keeps in mind for the whole run
24
+ # (standards, compliance constraints, stylistic guardrails).
25
+ # Distinct from the runtime memory sidecar — these are static context
26
+ # loaded on activation. Overrides append.
27
+ #
28
+ # Each entry is either:
29
+ # - a literal sentence, e.g. "All sprint changes require PO sign-off before execution."
30
+ # - a file reference prefixed with `file:`, e.g. "file:{project-root}/docs/standards.md"
31
+ # (glob patterns are supported; the file's contents are loaded and treated as facts).
32
+
10
33
  persistent_facts = [
11
34
  "file:{project-root}/**/project-context.md",
12
35
  ]
13
36
 
37
+ # Scalar: executed when the workflow reaches Step 6 (Workflow Completion),
38
+ # after the Sprint Change Proposal is finalized and handoff is confirmed. Override wins.
39
+ # Leave empty for no custom post-completion behavior.
40
+
14
41
  on_complete = ""
@@ -411,6 +411,7 @@ Activation is complete. Begin the workflow below.
411
411
 
412
412
  **The developer now has everything needed for flawless implementation!**
413
413
  </output>
414
+ <action>Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete` — if the resolved value is non-empty, follow it as the final terminal instruction before exiting.</action>
414
415
  </step>
415
416
 
416
417
  </workflow>
@@ -1,14 +1,41 @@
1
1
  # DO NOT EDIT -- overwritten on every update.
2
2
  #
3
- # Workflow customization surface for bmad-create-story.
3
+ # Workflow customization surface for bmad-create-story. Mirrors the
4
+ # agent customization shape under the [workflow] namespace.
4
5
 
5
6
  [workflow]
6
7
 
8
+ # --- Configurable below. Overrides merge per BMad structural rules: ---
9
+ # scalars: override wins • arrays (persistent_facts, activation_steps_*): append
10
+ # arrays-of-tables with `code`/`id`: replace matching items, append new ones.
11
+
12
+ # Steps to run before the standard activation (config load, greet).
13
+ # Overrides append. Use for pre-flight loads, compliance checks, etc.
14
+
7
15
  activation_steps_prepend = []
16
+
17
+ # Steps to run after greet but before the workflow begins.
18
+ # Overrides append. Use for context-heavy setup that should happen
19
+ # once the user has been acknowledged.
20
+
8
21
  activation_steps_append = []
9
22
 
23
+ # Persistent facts the workflow keeps in mind for the whole run
24
+ # (standards, compliance constraints, stylistic guardrails).
25
+ # Distinct from the runtime memory sidecar — these are static context
26
+ # loaded on activation. Overrides append.
27
+ #
28
+ # Each entry is either:
29
+ # - a literal sentence, e.g. "All stories must include testable acceptance criteria."
30
+ # - a file reference prefixed with `file:`, e.g. "file:{project-root}/docs/standards.md"
31
+ # (glob patterns are supported; the file's contents are loaded and treated as facts).
32
+
10
33
  persistent_facts = [
11
34
  "file:{project-root}/**/project-context.md",
12
35
  ]
13
36
 
37
+ # Scalar: executed when the workflow reaches Step 6 (Update sprint status and finalize),
38
+ # after the story file is saved and sprint-status.yaml is updated. Override wins.
39
+ # Leave empty for no custom post-completion behavior.
40
+
14
41
  on_complete = ""
@@ -168,3 +168,9 @@ If the project needs:
168
168
  Save summary to: `{default_output_file}`
169
169
 
170
170
  **Done!** Tests generated and verified. Validate against `./checklist.md`.
171
+
172
+ ## On Complete
173
+
174
+ Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete`
175
+
176
+ If the resolved `workflow.on_complete` is non-empty, follow it as the final terminal instruction before exiting.
@@ -1,14 +1,41 @@
1
1
  # DO NOT EDIT -- overwritten on every update.
2
2
  #
3
- # Workflow customization surface for bmad-qa-generate-e2e-tests.
3
+ # Workflow customization surface for bmad-qa-generate-e2e-tests. Mirrors the
4
+ # agent customization shape under the [workflow] namespace.
4
5
 
5
6
  [workflow]
6
7
 
8
+ # --- Configurable below. Overrides merge per BMad structural rules: ---
9
+ # scalars: override wins • arrays (persistent_facts, activation_steps_*): append
10
+ # arrays-of-tables with `code`/`id`: replace matching items, append new ones.
11
+
12
+ # Steps to run before the standard activation (config load, greet).
13
+ # Overrides append. Use for pre-flight loads, compliance checks, etc.
14
+
7
15
  activation_steps_prepend = []
16
+
17
+ # Steps to run after greet but before the workflow begins.
18
+ # Overrides append. Use for context-heavy setup that should happen
19
+ # once the user has been acknowledged.
20
+
8
21
  activation_steps_append = []
9
22
 
23
+ # Persistent facts the workflow keeps in mind for the whole run
24
+ # (standards, compliance constraints, stylistic guardrails).
25
+ # Distinct from the runtime memory sidecar — these are static context
26
+ # loaded on activation. Overrides append.
27
+ #
28
+ # Each entry is either:
29
+ # - a literal sentence, e.g. "All tests must follow the project's existing test framework patterns."
30
+ # - a file reference prefixed with `file:`, e.g. "file:{project-root}/docs/standards.md"
31
+ # (glob patterns are supported; the file's contents are loaded and treated as facts).
32
+
10
33
  persistent_facts = [
11
34
  "file:{project-root}/**/project-context.md",
12
35
  ]
13
36
 
37
+ # Scalar: executed when the workflow reaches Step 5 (Create Summary),
38
+ # after all tests pass and the summary document is saved. Override wins.
39
+ # Leave empty for no custom post-completion behavior.
40
+
14
41
  on_complete = ""
@@ -1486,7 +1486,7 @@ Alice (Product Owner): "See you at epic planning!"
1486
1486
  Charlie (Senior Dev): "Time to knock out that prep work."
1487
1487
 
1488
1488
  </output>
1489
-
1489
+ <action>Run: `python3 {project-root}/_bmad/scripts/resolve_customization.py --skill {skill-root} --key workflow.on_complete` — if the resolved value is non-empty, follow it as the final terminal instruction before exiting.</action>
1490
1490
  </step>
1491
1491
 
1492
1492
  </workflow>
@@ -1,14 +1,41 @@
1
1
  # DO NOT EDIT -- overwritten on every update.
2
2
  #
3
- # Workflow customization surface for bmad-retrospective.
3
+ # Workflow customization surface for bmad-retrospective. Mirrors the
4
+ # agent customization shape under the [workflow] namespace.
4
5
 
5
6
  [workflow]
6
7
 
8
+ # --- Configurable below. Overrides merge per BMad structural rules: ---
9
+ # scalars: override wins • arrays (persistent_facts, activation_steps_*): append
10
+ # arrays-of-tables with `code`/`id`: replace matching items, append new ones.
11
+
12
+ # Steps to run before the standard activation (config load, greet).
13
+ # Overrides append. Use for pre-flight loads, compliance checks, etc.
14
+
7
15
  activation_steps_prepend = []
16
+
17
+ # Steps to run after greet but before the workflow begins.
18
+ # Overrides append. Use for context-heavy setup that should happen
19
+ # once the user has been acknowledged.
20
+
8
21
  activation_steps_append = []
9
22
 
23
+ # Persistent facts the workflow keeps in mind for the whole run
24
+ # (standards, compliance constraints, stylistic guardrails).
25
+ # Distinct from the runtime memory sidecar — these are static context
26
+ # loaded on activation. Overrides append.
27
+ #
28
+ # Each entry is either:
29
+ # - a literal sentence, e.g. "All retrospectives must produce SMART action items with named owners."
30
+ # - a file reference prefixed with `file:`, e.g. "file:{project-root}/docs/standards.md"
31
+ # (glob patterns are supported; the file's contents are loaded and treated as facts).
32
+
10
33
  persistent_facts = [
11
34
  "file:{project-root}/**/project-context.md",
12
35
  ]
13
36
 
37
+ # Scalar: executed when the workflow reaches Step 12 (Final Summary and Handoff),
38
+ # after the retrospective document is saved and sprint-status is updated. Override wins.
39
+ # Leave empty for no custom post-completion behavior.
40
+
14
41
  on_complete = ""
@@ -0,0 +1,111 @@
1
+ ---
2
+ name: bmad-customize
3
+ description: Authors and updates customization overrides for installed BMad skills. Use when the user says 'customize bmad', 'override a skill', 'change agent behavior', or 'customize a workflow'.
4
+ ---
5
+
6
+ # BMad Customize
7
+
8
+ Translate the user's intent into a correctly-placed TOML override file under `{project-root}/_bmad/custom/` for a customizable agent or workflow skill. Discover, route, author, write, verify.
9
+
10
+ Scope v1: per-skill `[agent]` overrides (`bmad-agent-<role>.toml` / `.user.toml`) and per-skill `[workflow]` overrides (`bmad-<workflow>.toml` / `.user.toml`). Central config (`{project-root}/_bmad/custom/config.toml`) is out of scope — point users at the [How to Customize BMad guide](https://docs.bmad-method.org/how-to/customize-bmad/).
11
+
12
+ When the target's `customize.toml` doesn't expose what the user wants, say so plainly. Don't invent fields.
13
+
14
+ ## Preflight
15
+
16
+ - No `{project-root}/_bmad/` → BMad isn't installed. Say so, stop.
17
+ - `{project-root}/_bmad/scripts/resolve_customization.py` missing → continue, but Step 6 verify falls back to manual merge.
18
+ - Both present → proceed.
19
+
20
+ ## Activation
21
+
22
+ Load `_bmad/config.toml` and `_bmad/config.user.toml` from `{project-root}` for `user_name` (default `BMad`) and `communication_language` (default `English`). Greet. If the user's invocation already names a target skill AND a specific change, jump to Step 3.
23
+
24
+ ## Step 1: Classify intent
25
+
26
+ - **Directed** — specific skill + specific change → Step 3.
27
+ - **Exploratory** — "what can I customize?" → Step 2.
28
+ - **Audit/iterate** — wants to review or change something already customized → Step 2, lead with skills that have existing overrides; read the existing override in Step 3 before composing.
29
+ - **Cross-cutting** — could live on multiple surfaces → Step 3, choose agent vs workflow explicitly with the user.
30
+
31
+ ## Step 2: Discovery
32
+
33
+ ```
34
+ python3 {skill-root}/scripts/list_customizable_skills.py --project-root {project-root}
35
+ ```
36
+
37
+ Use `--extra-root <path>` (repeatable) if the user has skills installed in additional locations.
38
+
39
+ Group the returned `agents` and `workflows` for the user; for each show name, description, whether `has_team_override` or `has_user_override` is true. Surface any `errors[]`. For audit/iterate intents, lead with already-overridden entries.
40
+
41
+ Empty list: show `scanned_roots`, ask whether skills live elsewhere (offer `--extra-root`); otherwise stop.
42
+
43
+ ## Step 3: Determine the right surface
44
+
45
+ Read the target's `customize.toml`. Top-level `[agent]` or `[workflow]` block defines the surface.
46
+
47
+ If a team or user override already exists, read it first and summarize what's already overridden before composing.
48
+
49
+ **Cross-cutting intent — walk both surfaces with the user:**
50
+ - Every workflow a given agent runs → agent surface (e.g. `bmad-agent-pm.toml` with `persistent_facts`, `principles`).
51
+ - One workflow only → workflow surface (e.g. `bmad-create-prd.toml` with `activation_steps_prepend`).
52
+ - Several specific workflows → multiple workflow overrides in sequence, not an agent override.
53
+
54
+ **Single-surface heuristic:**
55
+ - Workflow-level: template swap, output path, step-specific behavior, or a named scalar already exposed (`*_template`, `on_complete`). Surgical, reliable.
56
+ - Agent-level: persona, communication style, org-wide facts, menu changes, behavior that should apply to every workflow the agent dispatches.
57
+
58
+ When ambiguous, present both with tradeoff, recommend one, let the user decide.
59
+
60
+ Intent outside the exposed surface (step logic, ordering, anything not in `customize.toml`): say so; offer `activation_steps_prepend`/`append` or `persistent_facts` as approximations, or recommend `bmad-builder` to create a custom skill.
61
+
62
+ ## Step 4: Compose the override
63
+
64
+ Translate plain-English into TOML against the target's `customize.toml` fields. If an existing override was read, frame the change as additive.
65
+
66
+ Merge semantics:
67
+ - **Scalars** (`icon`, `role`, `*_template`, `on_complete`) — override wins.
68
+ - **Append arrays** (`persistent_facts`, `activation_steps_prepend`/`append`, `principles`) — team/user entries append in order.
69
+ - **Keyed arrays of tables** (menu items with `code` or `id`) — matching keys replace, new keys append.
70
+
71
+ Overrides are sparse: only the fields being changed. Never copy the whole `customize.toml`.
72
+
73
+ **Template swap** (`*_template` scalar): offer to copy the default template to `{project-root}/_bmad/custom/{skill-name}-{purpose}-template.md`, point the override at the new path, offer to help edit it.
74
+
75
+ ## Step 5: Team or user placement
76
+
77
+ Under `{project-root}/_bmad/custom/`:
78
+ - `{skill-name}.toml` — team, committed. Policies, org conventions, compliance.
79
+ - `{skill-name}.user.toml` — user, gitignored. Personal tone, private facts, shortcuts.
80
+
81
+ Default by character (policy → team, personal → user), confirm before writing.
82
+
83
+ ## Step 6: Show, confirm, write, verify
84
+
85
+ 1. Show the full TOML. If the file exists, show a diff. Never silently overwrite.
86
+ 2. Wait for explicit yes.
87
+ 3. Write. Create `{project-root}/_bmad/custom/` if needed.
88
+ 4. Verify:
89
+ ```
90
+ python3 {project-root}/_bmad/scripts/resolve_customization.py --skill <install-path> --key <agent-or-workflow>
91
+ ```
92
+ Show the merged output, point out the changed fields.
93
+
94
+ **Resolver missing or fails:** read whichever layers exist — `<install-path>/customize.toml` (base), `{project-root}/_bmad/custom/{skill-name}.toml` (team), `{project-root}/_bmad/custom/{skill-name}.user.toml` (user) — apply base → team → user with the same merge rules (scalars override, tables deep-merge, `code`/`id`-keyed arrays merge by key, all other arrays append), describe how the changed fields resolve.
95
+
96
+ **Verify shows override didn't land** (field unchanged, merge conflict, file not picked up): re-enter Step 4 with the verify output as context. Usually wrong field name, wrong merge mode (scalar vs array), or wrong scope.
97
+ 5. Summarize what changed, where the file lives, how to iterate. Remind the user to commit team overrides.
98
+
99
+ ## Complete when
100
+
101
+ - Override file written (or user explicitly aborted).
102
+ - User has seen resolver output (or manual fallback merge summary).
103
+ - User has acknowledged the summary.
104
+
105
+ Otherwise the skill isn't done — finish or tell the user they're exiting incomplete.
106
+
107
+ ## When this skill can't help
108
+
109
+ - **Central config** (`{project-root}/_bmad/custom/config.toml`) — see the [How to Customize BMad guide](https://docs.bmad-method.org/how-to/customize-bmad/).
110
+ - **Step logic, ordering, behavior not in `customize.toml`** — open a feature request, or use `bmad-builder` to create a custom skill. Offer to help with either.
111
+ - **Skills without a `customize.toml`** — not customizable.
@@ -0,0 +1,231 @@
1
+ #!/usr/bin/env python3
2
+ # /// script
3
+ # requires-python = ">=3.11"
4
+ # ///
5
+ """Enumerate customizable BMad skills installed alongside this one.
6
+
7
+ Scans a skills directory (by default: the directory this script's own skill
8
+ lives in, derived from __file__), finds every sibling directory containing a
9
+ `customize.toml`, classifies each as agent and/or workflow based on its
10
+ top-level blocks, reads the skill's SKILL.md frontmatter description for a
11
+ one-liner, and checks whether override files already exist in
12
+ `{project-root}/_bmad/custom/`.
13
+
14
+ Skills in BMad are loaded either from a project-local location (e.g. the
15
+ project's `.claude/skills/` or `.cursor/skills/`) or from a user-global
16
+ location (e.g. `~/.claude/skills/`). We do not hardcode those paths — the
17
+ running skill's own location is the source of truth for sibling discovery.
18
+ `--extra-root` is available for the rare case where skills live in multiple
19
+ locations on the same machine.
20
+
21
+ Output: JSON to stdout. Non-empty `errors[]` in the payload is non-fatal
22
+ by contract — the scanner surfaces malformed TOML, missing roots, and
23
+ skills with no customization block as data for the caller to display,
24
+ and still exits 0. Exit 2 is reserved for invocation errors (e.g.
25
+ missing or unreadable `--project-root`) where no useful payload can be
26
+ produced.
27
+ """
28
+
29
+ from __future__ import annotations
30
+
31
+ import argparse
32
+ import json
33
+ import re
34
+ import sys
35
+ import tomllib
36
+ from pathlib import Path
37
+
38
+ # Top-level TOML blocks that indicate a customization surface.
39
+ SURFACE_KEYS = ("agent", "workflow")
40
+
41
+ FRONTMATTER_RE = re.compile(r"^---\s*\n(.*?)\n---\s*\n", re.DOTALL)
42
+
43
+
44
+ def default_skills_root() -> Path:
45
+ """Derive the skills root from this script's location.
46
+
47
+ Layout assumption: {skills_root}/bmad-customize/scripts/list_customizable_skills.py.
48
+ So the skills root is three parents up from this file.
49
+ """
50
+ return Path(__file__).resolve().parent.parent.parent
51
+
52
+
53
+ def read_frontmatter_description(skill_md: Path) -> str:
54
+ """Extract the `description:` value from a SKILL.md YAML frontmatter block.
55
+
56
+ Returns an empty string if the file is missing, unreadable, or has no
57
+ description field. Intentionally permissive — this is metadata for a
58
+ human-facing list, not a validation target.
59
+ """
60
+ if not skill_md.is_file():
61
+ return ""
62
+ try:
63
+ text = skill_md.read_text(encoding="utf-8")
64
+ except (OSError, UnicodeDecodeError):
65
+ return ""
66
+ m = FRONTMATTER_RE.match(text)
67
+ if not m:
68
+ return ""
69
+ for line in m.group(1).splitlines():
70
+ stripped = line.strip()
71
+ if stripped.startswith("description:"):
72
+ value = stripped[len("description:") :].strip()
73
+ # Strip surrounding quotes if present.
74
+ if (value.startswith("'") and value.endswith("'")) or (
75
+ value.startswith('"') and value.endswith('"')
76
+ ):
77
+ value = value[1:-1]
78
+ return value
79
+ return ""
80
+
81
+
82
+ def load_customize(toml_path: Path) -> dict | None:
83
+ """Return the parsed TOML, or None if unreadable."""
84
+ try:
85
+ with toml_path.open("rb") as f:
86
+ return tomllib.load(f)
87
+ except (OSError, tomllib.TOMLDecodeError):
88
+ return None
89
+
90
+
91
+ def scan_skills(
92
+ skills_roots: list[Path],
93
+ project_root: Path,
94
+ ) -> dict:
95
+ """Scan each skills root for directories that contain a customize.toml."""
96
+ agents: list[dict] = []
97
+ workflows: list[dict] = []
98
+ errors: list[str] = []
99
+ scanned_roots: list[str] = []
100
+ seen_names: set[str] = set()
101
+ custom_dir = project_root / "_bmad" / "custom"
102
+
103
+ for root in skills_roots:
104
+ if not root.is_dir():
105
+ errors.append(f"skills root does not exist: {root}")
106
+ continue
107
+ scanned_roots.append(str(root))
108
+
109
+ for skill_dir in sorted(p for p in root.iterdir() if p.is_dir()):
110
+ customize_toml = skill_dir / "customize.toml"
111
+ if not customize_toml.is_file():
112
+ continue
113
+
114
+ data = load_customize(customize_toml)
115
+ if data is None:
116
+ errors.append(f"failed to parse {customize_toml}")
117
+ continue
118
+
119
+ skill_name = skill_dir.name
120
+ # If a skill with this name was already found in an earlier
121
+ # root, skip it — roots are scanned in the order provided, so
122
+ # the first occurrence wins.
123
+ if skill_name in seen_names:
124
+ continue
125
+ seen_names.add(skill_name)
126
+
127
+ description = read_frontmatter_description(skill_dir / "SKILL.md")
128
+ team_override = custom_dir / f"{skill_name}.toml"
129
+ user_override = custom_dir / f"{skill_name}.user.toml"
130
+
131
+ entry_base = {
132
+ "name": skill_name,
133
+ "install_path": str(skill_dir),
134
+ "skills_root": str(root),
135
+ "description": description,
136
+ "has_team_override": team_override.is_file(),
137
+ "has_user_override": user_override.is_file(),
138
+ "team_override_path": str(team_override),
139
+ "user_override_path": str(user_override),
140
+ }
141
+
142
+ # A skill may expose an agent surface, a workflow surface, or
143
+ # both. Emit one entry per surface so the caller can group cleanly.
144
+ surfaces_found = [k for k in SURFACE_KEYS if k in data]
145
+ if not surfaces_found:
146
+ errors.append(
147
+ f"no [agent] or [workflow] block in {customize_toml}"
148
+ )
149
+ continue
150
+ for surface in surfaces_found:
151
+ entry = dict(entry_base)
152
+ entry["surface"] = surface
153
+ if surface == "agent":
154
+ agents.append(entry)
155
+ else:
156
+ workflows.append(entry)
157
+
158
+ return {
159
+ "project_root": str(project_root),
160
+ "scanned_roots": scanned_roots,
161
+ "custom_dir": str(custom_dir),
162
+ "agents": agents,
163
+ "workflows": workflows,
164
+ "errors": errors,
165
+ }
166
+
167
+
168
+ def parse_args(argv: list[str]) -> argparse.Namespace:
169
+ parser = argparse.ArgumentParser(
170
+ description=(
171
+ "List customizable BMad skills installed alongside this one, "
172
+ "grouped by surface (agent vs workflow), with override status "
173
+ "looked up against {project-root}/_bmad/custom/."
174
+ )
175
+ )
176
+ parser.add_argument(
177
+ "--project-root",
178
+ required=True,
179
+ help="Absolute path to the project root (the folder containing _bmad/).",
180
+ )
181
+ parser.add_argument(
182
+ "--skills-root",
183
+ default=None,
184
+ help=(
185
+ "Override the primary skills directory to scan. Defaults to the "
186
+ "directory this script's own skill lives in."
187
+ ),
188
+ )
189
+ parser.add_argument(
190
+ "--extra-root",
191
+ action="append",
192
+ default=[],
193
+ metavar="PATH",
194
+ help=(
195
+ "Additional skills directory to include (repeatable). Useful "
196
+ "when skills live in multiple locations on the same machine "
197
+ "(e.g. project-local plus a user-global install)."
198
+ ),
199
+ )
200
+ return parser.parse_args(argv)
201
+
202
+
203
+ def main(argv: list[str]) -> int:
204
+ args = parse_args(argv)
205
+ project_root = Path(args.project_root).expanduser().resolve()
206
+ if not project_root.is_dir():
207
+ print(
208
+ f"error: project-root does not exist or is not a directory: {project_root}",
209
+ file=sys.stderr,
210
+ )
211
+ return 2
212
+
213
+ primary = (
214
+ Path(args.skills_root).expanduser().resolve()
215
+ if args.skills_root
216
+ else default_skills_root()
217
+ )
218
+ extras = [Path(p).expanduser().resolve() for p in args.extra_root]
219
+ # Deduplicate in order of appearance.
220
+ roots: list[Path] = []
221
+ for root in [primary, *extras]:
222
+ if root not in roots:
223
+ roots.append(root)
224
+
225
+ result = scan_skills(roots, project_root)
226
+ print(json.dumps(result, indent=2, sort_keys=True))
227
+ return 0
228
+
229
+
230
+ if __name__ == "__main__":
231
+ sys.exit(main(sys.argv[1:]))