Description
The cleanup-legacy.py script in the BMad Builder (bmb) module's setup skill uses an overly broad find_skill_dirs() function that matches any SKILL.md file in the directory tree, including non-installable templates nested inside skill assets.
Specifically, bmad-module-builder/assets/setup-skill-template/SKILL.md is a scaffold template, not an installable skill. But find_skill_dirs() picks it up as setup-skill-template, tries to verify it exists at .claude/skills/setup-skill-template, fails, and aborts the entire cleanup with exit code 1.
Root cause — in bmad-bmb-setup/scripts/cleanup-legacy.py:
def find_skill_dirs(base_path: str) -> list:
for skill_md in root.rglob("SKILL.md"):
skills.append(skill_md.parent.name) # ← catches ANY SKILL.md leaf dir
This catches templates, task definitions, and any other nested SKILL.md files.
Secondary issue: The BMB version of cleanup-legacy.py also does not preserve config.yaml files during directory removal. Per-module config files like _bmad/core/config.yaml and _bmad/suno/config.yaml are needed by bmad-init at runtime, but shutil.rmtree() deletes them along with the legacy skill files.
Fix already exists in bmad-suno-band-manager
The BMad Suno Band Manager module fixed both issues in commit eb226a7. The fix:
-
Scoped find_skill_dirs — only matches SKILL.md at installable positions:
- Direct children:
{name}/SKILL.md
- Skills subfolder:
skills/{name}/SKILL.md
- Everything deeper is skipped
-
Config preservation — backs up config.yaml before shutil.rmtree() and restores it after
Steps to reproduce
- Install BMad with BMB module (
npx bmad-method install)
- Run BMB setup (
/bmad-bmb-setup)
- Setup runs
cleanup-legacy.py --module-code bmb --also-remove _config --skills-dir .claude/skills
- Script finds
bmad-module-builder/assets/setup-skill-template/SKILL.md
- Verification fails:
MISSING: setup-skill-template not found at .claude/skills/setup-skill-template
- Cleanup aborts — legacy directories are not removed
Expected behavior
find_skill_dirs() should only match SKILL.md files at recognized installable positions, skipping templates and other nested SKILL.md files. Cleanup should complete successfully and preserve per-module config.yaml files.
Actual behavior
Cleanup fails with exit code 1 and error: Skills not found at installed location / missing_skills: ["setup-skill-template"].
Which module is this for?
BMad Builder (BMB)
BMad Version
6.2.2
Which AI IDE are you using?
Claude Code
Operating System
Linux (WSL2)
Description
The
cleanup-legacy.pyscript in the BMad Builder (bmb) module's setup skill uses an overly broadfind_skill_dirs()function that matches anySKILL.mdfile in the directory tree, including non-installable templates nested inside skill assets.Specifically,
bmad-module-builder/assets/setup-skill-template/SKILL.mdis a scaffold template, not an installable skill. Butfind_skill_dirs()picks it up assetup-skill-template, tries to verify it exists at.claude/skills/setup-skill-template, fails, and aborts the entire cleanup with exit code 1.Root cause — in
bmad-bmb-setup/scripts/cleanup-legacy.py:This catches templates, task definitions, and any other nested SKILL.md files.
Secondary issue: The BMB version of
cleanup-legacy.pyalso does not preserveconfig.yamlfiles during directory removal. Per-module config files like_bmad/core/config.yamland_bmad/suno/config.yamlare needed bybmad-initat runtime, butshutil.rmtree()deletes them along with the legacy skill files.Fix already exists in bmad-suno-band-manager
The BMad Suno Band Manager module fixed both issues in commit
eb226a7. The fix:Scoped
find_skill_dirs— only matches SKILL.md at installable positions:{name}/SKILL.mdskills/{name}/SKILL.mdConfig preservation — backs up
config.yamlbeforeshutil.rmtree()and restores it afterSteps to reproduce
npx bmad-method install)/bmad-bmb-setup)cleanup-legacy.py --module-code bmb --also-remove _config --skills-dir .claude/skillsbmad-module-builder/assets/setup-skill-template/SKILL.mdMISSING: setup-skill-template not found at .claude/skills/setup-skill-templateExpected behavior
find_skill_dirs()should only match SKILL.md files at recognized installable positions, skipping templates and other nested SKILL.md files. Cleanup should complete successfully and preserve per-moduleconfig.yamlfiles.Actual behavior
Cleanup fails with exit code 1 and error:
Skills not found at installed location/missing_skills: ["setup-skill-template"].Which module is this for?
BMad Builder (BMB)
BMad Version
6.2.2
Which AI IDE are you using?
Claude Code
Operating System
Linux (WSL2)