Skip to content

[BUG] BMB cleanup-legacy.py find_skill_dirs matches nested SKILL.md files (e.g. setup-skill-template) #2175

@zarlor

Description

@zarlor

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:

  1. 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
  2. Config preservation — backs up config.yaml before shutil.rmtree() and restores it after

Steps to reproduce

  1. Install BMad with BMB module (npx bmad-method install)
  2. Run BMB setup (/bmad-bmb-setup)
  3. Setup runs cleanup-legacy.py --module-code bmb --also-remove _config --skills-dir .claude/skills
  4. Script finds bmad-module-builder/assets/setup-skill-template/SKILL.md
  5. Verification fails: MISSING: setup-skill-template not found at .claude/skills/setup-skill-template
  6. 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions