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

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "bmad-method",
4
- "version": "6.3.1-next.16",
4
+ "version": "6.3.1-next.17",
5
5
  "description": "Breakthrough Method of Agile AI-driven Development",
6
6
  "keywords": [
7
7
  "agile",
@@ -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:]))
@@ -0,0 +1,249 @@
1
+ #!/usr/bin/env python3
2
+ # /// script
3
+ # requires-python = ">=3.11"
4
+ # ///
5
+ """Unit tests for list_customizable_skills.py.
6
+
7
+ Exercises the scanner against a synthesized install tree:
8
+ - an agent-only customize.toml
9
+ - a workflow-only customize.toml
10
+ - a customize.toml that exposes both surfaces
11
+ - a skill directory with no customize.toml (ignored)
12
+ - a pre-existing team override in _bmad/custom/
13
+ - malformed TOML (surfaces as an error without aborting)
14
+ - multiple skills roots (e.g. project-local + user-global mix)
15
+
16
+ Run: python3 scripts/tests/test_list_customizable_skills.py
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import importlib.util
22
+ import json
23
+ import subprocess
24
+ import sys
25
+ import tempfile
26
+ import unittest
27
+ from pathlib import Path
28
+
29
+ SCRIPT = Path(__file__).resolve().parent.parent / "list_customizable_skills.py"
30
+
31
+
32
+ def _load_module():
33
+ spec = importlib.util.spec_from_file_location("list_customizable_skills", SCRIPT)
34
+ module = importlib.util.module_from_spec(spec)
35
+ spec.loader.exec_module(module) # type: ignore[union-attr]
36
+ return module
37
+
38
+
39
+ MODULE = _load_module()
40
+
41
+
42
+ def _make_skill(parent: Path, name: str, body: str, skill_md: str | None = None) -> Path:
43
+ skill_dir = parent / name
44
+ skill_dir.mkdir(parents=True, exist_ok=True)
45
+ (skill_dir / "customize.toml").write_text(body, encoding="utf-8")
46
+ if skill_md is not None:
47
+ (skill_dir / "SKILL.md").write_text(skill_md, encoding="utf-8")
48
+ return skill_dir
49
+
50
+
51
+ class ScannerTest(unittest.TestCase):
52
+ def setUp(self):
53
+ self.tmp = tempfile.TemporaryDirectory()
54
+ self.root = Path(self.tmp.name)
55
+ self.skills = self.root / "skills"
56
+ self.skills.mkdir(parents=True)
57
+ self.custom = self.root / "_bmad" / "custom"
58
+ self.custom.mkdir(parents=True)
59
+
60
+ def tearDown(self):
61
+ self.tmp.cleanup()
62
+
63
+ def test_agent_only_skill_detected(self):
64
+ _make_skill(
65
+ self.skills,
66
+ "bmad-agent-pm",
67
+ "[agent]\nicon = \"🧠\"\n",
68
+ "---\nname: bmad-agent-pm\ndescription: Product manager.\n---\n",
69
+ )
70
+ result = MODULE.scan_skills([self.skills], self.root)
71
+ self.assertEqual(len(result["agents"]), 1)
72
+ self.assertEqual(len(result["workflows"]), 0)
73
+ entry = result["agents"][0]
74
+ self.assertEqual(entry["name"], "bmad-agent-pm")
75
+ self.assertEqual(entry["surface"], "agent")
76
+ self.assertEqual(entry["description"], "Product manager.")
77
+ self.assertFalse(entry["has_team_override"])
78
+ self.assertFalse(entry["has_user_override"])
79
+
80
+ def test_workflow_only_skill_detected(self):
81
+ _make_skill(
82
+ self.skills,
83
+ "bmad-create-prd",
84
+ "[workflow]\npersistent_facts = []\n",
85
+ "---\nname: bmad-create-prd\ndescription: 'Create a PRD.'\n---\n",
86
+ )
87
+ result = MODULE.scan_skills([self.skills], self.root)
88
+ self.assertEqual(len(result["agents"]), 0)
89
+ self.assertEqual(len(result["workflows"]), 1)
90
+ entry = result["workflows"][0]
91
+ self.assertEqual(entry["description"], "Create a PRD.")
92
+
93
+ def test_dual_surface_skill_emits_two_entries(self):
94
+ _make_skill(
95
+ self.skills,
96
+ "bmad-dual",
97
+ "[agent]\nicon = \"x\"\n\n[workflow]\npersistent_facts = []\n",
98
+ "---\nname: bmad-dual\ndescription: Dual.\n---\n",
99
+ )
100
+ result = MODULE.scan_skills([self.skills], self.root)
101
+ self.assertEqual(len(result["agents"]), 1)
102
+ self.assertEqual(len(result["workflows"]), 1)
103
+ self.assertEqual(result["agents"][0]["name"], "bmad-dual")
104
+ self.assertEqual(result["workflows"][0]["name"], "bmad-dual")
105
+
106
+ def test_skill_without_customize_toml_ignored(self):
107
+ (self.skills / "bmad-plain").mkdir()
108
+ (self.skills / "bmad-plain" / "SKILL.md").write_text("# plain\n")
109
+ result = MODULE.scan_skills([self.skills], self.root)
110
+ self.assertEqual(len(result["agents"]) + len(result["workflows"]), 0)
111
+ self.assertEqual(result["errors"], [])
112
+
113
+ def test_existing_team_override_flagged(self):
114
+ _make_skill(
115
+ self.skills,
116
+ "bmad-agent-pm",
117
+ "[agent]\nicon = \"x\"\n",
118
+ "---\nname: bmad-agent-pm\ndescription: PM.\n---\n",
119
+ )
120
+ (self.custom / "bmad-agent-pm.toml").write_text("[agent]\n")
121
+ result = MODULE.scan_skills([self.skills], self.root)
122
+ entry = result["agents"][0]
123
+ self.assertTrue(entry["has_team_override"])
124
+ self.assertFalse(entry["has_user_override"])
125
+
126
+ def test_missing_surface_block_reports_error(self):
127
+ _make_skill(self.skills, "bmad-broken", "[not_a_surface]\nfoo = 1\n")
128
+ result = MODULE.scan_skills([self.skills], self.root)
129
+ self.assertEqual(len(result["agents"]) + len(result["workflows"]), 0)
130
+ self.assertEqual(len(result["errors"]), 1)
131
+ self.assertIn("no [agent] or [workflow] block", result["errors"][0])
132
+
133
+ def test_malformed_toml_reports_error_without_aborting(self):
134
+ skill_dir = self.skills / "bmad-bad"
135
+ skill_dir.mkdir()
136
+ (skill_dir / "customize.toml").write_text("this is not [valid toml\n")
137
+ # Plus a good sibling to confirm scanning continues.
138
+ _make_skill(
139
+ self.skills,
140
+ "bmad-good",
141
+ "[agent]\nicon = \"x\"\n",
142
+ "---\nname: bmad-good\ndescription: Good.\n---\n",
143
+ )
144
+ result = MODULE.scan_skills([self.skills], self.root)
145
+ self.assertEqual(len(result["agents"]), 1)
146
+ self.assertEqual(result["agents"][0]["name"], "bmad-good")
147
+ self.assertTrue(any("failed to parse" in e for e in result["errors"]))
148
+
149
+ def test_description_with_double_quotes_stripped(self):
150
+ _make_skill(
151
+ self.skills,
152
+ "bmad-q",
153
+ "[agent]\nicon = \"x\"\n",
154
+ '---\nname: bmad-q\ndescription: "Double-quoted desc."\n---\n',
155
+ )
156
+ result = MODULE.scan_skills([self.skills], self.root)
157
+ self.assertEqual(result["agents"][0]["description"], "Double-quoted desc.")
158
+
159
+ def test_multiple_skills_roots_are_merged(self):
160
+ extra_root = self.root / "extra-skills"
161
+ extra_root.mkdir()
162
+ _make_skill(
163
+ self.skills,
164
+ "bmad-agent-pm",
165
+ "[agent]\nicon = \"x\"\n",
166
+ "---\nname: bmad-agent-pm\ndescription: PM.\n---\n",
167
+ )
168
+ _make_skill(
169
+ extra_root,
170
+ "bmad-agent-dev",
171
+ "[agent]\nicon = \"y\"\n",
172
+ "---\nname: bmad-agent-dev\ndescription: Dev.\n---\n",
173
+ )
174
+ result = MODULE.scan_skills([self.skills, extra_root], self.root)
175
+ names = {a["name"] for a in result["agents"]}
176
+ self.assertEqual(names, {"bmad-agent-pm", "bmad-agent-dev"})
177
+ self.assertEqual(len(result["scanned_roots"]), 2)
178
+
179
+ def test_duplicate_skill_name_across_roots_first_wins(self):
180
+ extra_root = self.root / "extra-skills"
181
+ extra_root.mkdir()
182
+ _make_skill(
183
+ self.skills,
184
+ "bmad-agent-pm",
185
+ "[agent]\nicon = \"primary\"\n",
186
+ "---\nname: bmad-agent-pm\ndescription: Primary.\n---\n",
187
+ )
188
+ _make_skill(
189
+ extra_root,
190
+ "bmad-agent-pm",
191
+ "[agent]\nicon = \"duplicate\"\n",
192
+ "---\nname: bmad-agent-pm\ndescription: Duplicate.\n---\n",
193
+ )
194
+ result = MODULE.scan_skills([self.skills, extra_root], self.root)
195
+ self.assertEqual(len(result["agents"]), 1)
196
+ self.assertEqual(result["agents"][0]["description"], "Primary.")
197
+ self.assertEqual(result["agents"][0]["skills_root"], str(self.skills))
198
+
199
+ def test_missing_skills_root_reports_error(self):
200
+ result = MODULE.scan_skills(
201
+ [self.root / "does-not-exist", self.skills],
202
+ self.root,
203
+ )
204
+ self.assertTrue(any("skills root does not exist" in e for e in result["errors"]))
205
+
206
+ def test_cli_emits_valid_json_and_exits_zero(self):
207
+ _make_skill(
208
+ self.skills,
209
+ "bmad-agent-pm",
210
+ "[agent]\nicon = \"x\"\n",
211
+ "---\nname: bmad-agent-pm\ndescription: PM.\n---\n",
212
+ )
213
+ proc = subprocess.run(
214
+ [
215
+ sys.executable,
216
+ str(SCRIPT),
217
+ "--project-root",
218
+ str(self.root),
219
+ "--skills-root",
220
+ str(self.skills),
221
+ ],
222
+ capture_output=True,
223
+ text=True,
224
+ check=False,
225
+ )
226
+ self.assertEqual(proc.returncode, 0, proc.stderr)
227
+ payload = json.loads(proc.stdout)
228
+ self.assertEqual(len(payload["agents"]), 1)
229
+
230
+ def test_cli_exits_two_on_missing_project_root(self):
231
+ proc = subprocess.run(
232
+ [
233
+ sys.executable,
234
+ str(SCRIPT),
235
+ "--project-root",
236
+ str(self.root / "does-not-exist"),
237
+ "--skills-root",
238
+ str(self.skills),
239
+ ],
240
+ capture_output=True,
241
+ text=True,
242
+ check=False,
243
+ )
244
+ self.assertEqual(proc.returncode, 2)
245
+ self.assertIn("does not exist", proc.stderr)
246
+
247
+
248
+ if __name__ == "__main__":
249
+ unittest.main()
@@ -10,3 +10,4 @@ Core,bmad-editorial-review-structure,Editorial Review - Structure,ES,Use when do
10
10
  Core,bmad-review-adversarial-general,Adversarial Review,AR,"Use for quality assurance or before finalizing deliverables. Code Review in other modules runs this automatically, but also useful for document reviews.",[path],anytime,,,false,,
11
11
  Core,bmad-review-edge-case-hunter,Edge Case Hunter Review,ECH,Use alongside adversarial review for orthogonal coverage — method-driven not attitude-driven.,[path],anytime,,,false,,
12
12
  Core,bmad-distillator,Distillator,DG,Use when you need token-efficient distillates that preserve all information for downstream LLM consumption.,[path],anytime,,,false,adjacent to source document or specified output_path,distillate markdown file(s)
13
+ Core,bmad-customize,BMad Customize,BC,"Use when you want to change how an agent or workflow behaves — add persistent facts, swap templates, insert activation hooks, or customize menus. Scans what's customizable, picks the right scope (agent vs workflow), writes the override to _bmad/custom/, and verifies the merge. No TOML hand-authoring required.",,anytime,,,false,{project-root}/_bmad/custom,TOML override files