Skip to content

m3taz-ahmed/aizee / skills/bmad-toolsmith

bmad-toolsmith

Verified

Smithy the Toolsmith builds and maintains BMad skills, agents and modules. Use when the user asks for Smithy or says "build a skill", "make an agent", "scaffold a skill", "turn my session logs into a skill", "fix this skill", "convert this prompt to a skill", "review this skill", "optimize this skill", "cut this skill down", "make this skill BMad compliant", "package a module", "validate my module" or "migrate my old module". Not for running evals (`bmad-eval`) or overriding an installed skill (`bmad-customize`).

FileKindSize
SKILL.mdskill md3.6 KB
approaches/eval-first.mdmarkdown1.3 KB
approaches/eval-loop.mdmarkdown2.4 KB
approaches/from-logs.mdmarkdown1.7 KB
approaches/lean.mdmarkdown1.7 KB
approaches/scaffold.mdmarkdown1.3 KB
approaches/skill-creator-loop.mdmarkdown1.2 KB
bmod.tomlconfig118 B
canon.mdmarkdown10.5 KB
customize.tomlconfig4.8 KB
discover.mdmarkdown5.5 KB
evals/triggers.jsonconfig3.3 KB
lenses/lens-architecture.mdmarkdown2.9 KB
lenses/lens-contract.mdmarkdown1.4 KB
lenses/lens-customization.mdmarkdown2.4 KB
lenses/lens-determinism.mdmarkdown1.8 KB
lenses/lens-leanness.mdmarkdown3.1 KB
lenses/lens-trigger.mdmarkdown2.4 KB
lenses/standards.mdmarkdown5.2 KB
modes/convert.mdmarkdown2.1 KB
modes/cut-roles.mdmarkdown3.3 KB
modes/cut.mdmarkdown3.3 KB
modes/edit.mdmarkdown1.3 KB
modes/migrate.mdmarkdown3.3 KB
modes/package.mdmarkdown2.6 KB
modes/review.mdmarkdown1.3 KB
modes/validate.mdmarkdown1.8 KB
scripts/count_tokens.pyscript3.6 KB
scripts/cut_check.pyscript5.1 KB
scripts/init_skill.pyscript13.3 KB
scripts/prepass.pyscript7.5 KB
scripts/process_template.pyscript4.8 KB
scripts/read_session_log.pyscript9.8 KB
scripts/registry.pyscript5.9 KB
scripts/scan_legacy_module.pyscript7.7 KB
scripts/scan_paths.pyscript9.2 KB
scripts/scan_scripts.pyscript6.6 KB
scripts/tests/test_count_tokens.pyscript4.1 KB
scripts/tests/test_cut_check.pyscript3.1 KB
scripts/tests/test_init_skill.pyscript9.7 KB
scripts/tests/test_memory_agent_scripts.pyscript8.6 KB
scripts/tests/test_prepass.pyscript8.3 KB
scripts/tests/test_process_template.pyscript4.7 KB
scripts/tests/test_read_session_log.pyscript7.3 KB
scripts/tests/test_registry.pyscript6.0 KB
scripts/tests/test_scan_legacy_module.pyscript8.2 KB
scripts/tests/test_scan_paths.pyscript7.7 KB
scripts/tests/test_scan_scripts.pyscript4.1 KB
shapes/agent/assets/SKILL-template.mdmarkdown2.0 KB
shapes/agent/assets/capability-template.mdmarkdown582 B
shapes/agent/assets/customize-template.tomlconfig1.9 KB
shapes/agent/assets/sample-capability.mdmarkdown887 B
shapes/agent/shape.mdmarkdown3.2 KB
shapes/memory-agent/assets/BOND-template.mdmarkdown392 B
shapes/memory-agent/assets/CAPABILITIES-template.mdmarkdown1017 B
shapes/memory-agent/assets/CREED-template.mdmarkdown2.1 KB
shapes/memory-agent/assets/HOW-I-REMEMBER-template.mdmarkdown3.3 KB
shapes/memory-agent/assets/PERSONA-template.mdmarkdown705 B
shapes/memory-agent/assets/PULSE-template.mdmarkdown849 B
shapes/memory-agent/assets/SKILL-template-bootloader.mdmarkdown4.2 KB
shapes/memory-agent/assets/customize-template.tomlconfig1.2 KB
shapes/memory-agent/assets/first-breath-config-template.mdmarkdown4.5 KB
shapes/memory-agent/assets/first-breath-template.mdmarkdown9.3 KB
shapes/memory-agent/assets/init-sanctum-template.pyscript5.7 KB
shapes/memory-agent/assets/intake-capability-template.mdmarkdown975 B
shapes/memory-agent/assets/wake-template.pyscript6.8 KB
shapes/memory-agent/shape.mdmarkdown5.0 KB
shapes/multi-skill-module/assets/help-template.mdmarkdown623 B
shapes/multi-skill-module/assets/member-bmod-template.tomlconfig490 B
shapes/multi-skill-module/assets/record-SKILL-template.mdmarkdown374 B
shapes/multi-skill-module/assets/record-bmod-template.tomlconfig802 B
shapes/multi-skill-module/assets/retired-template.tomlconfig287 B
shapes/multi-skill-module/assets/roster-template.tomlconfig567 B
shapes/multi-skill-module/shape.mdmarkdown4.3 KB
shapes/plain-skill/assets/SKILL-template.mdmarkdown2.0 KB
shapes/plain-skill/assets/customize-template.tomlconfig1.0 KB
shapes/plain-skill/shape.mdmarkdown2.9 KB
shapes/rendered-agent/assets/SKILL-template.mdmarkdown1.0 KB
shapes/rendered-agent/assets/capability.mdmarkdown1.1 KB
shapes/rendered-agent/assets/customize-template.tomlconfig2.6 KB
shapes/rendered-agent/assets/workflow.mdmarkdown1.8 KB
shapes/rendered-agent/shape.mdmarkdown3.8 KB
shapes/rendered-skill/assets/SKILL-template.mdmarkdown1.0 KB
shapes/rendered-skill/assets/customize-template.tomlconfig990 B
shapes/rendered-skill/assets/step.mdmarkdown688 B
shapes/rendered-skill/assets/workflow.mdmarkdown1004 B
shapes/rendered-skill/shape.mdmarkdown2.2 KB
shapes/script-utility/assets/SKILL-template.mdmarkdown859 B
shapes/script-utility/assets/script-template.pyscript1.5 KB
shapes/script-utility/assets/test-template.pyscript1.2 KB
shapes/script-utility/shape.mdmarkdown1.6 KB
shapes/single-skill-module/assets/bmod-template.tomlconfig696 B
shapes/single-skill-module/assets/help-template.mdmarkdown177 B
shapes/single-skill-module/shape.mdmarkdown2.5 KB
ship.mdmarkdown6.4 KB

scripts/scan_paths.py

View on GitHub
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.11"
# ///
"""scan_paths: lint a skill's Markdown files, and its eval JSON for absolute paths, for path conventions.

Rules, each a `rule` value in the findings:
  bare-script-call   `uv run scripts/x.py` or `uv run ./scripts/x.py`; a skill's own scripts run as
                     `uv run {skill-root}/scripts/x.py` because the agent's working directory is the project
  installed-path     `{installed_path}` or an `installed_path` definition, a pre-skill leftover
  absolute-path      /Users/, /home/, C:\\ or ~/ paths, which do not travel between machines
  cross-skill-ref    a path into another skill's folder (skills/<other>/..., .claude/skills/<other>/..., or
                     a ../ path that leaves this skill); to use another skill, invoke it by name
  missing-file       a backticked skill-relative path (`references/x.md`) that does not exist from the file's
                     folder or the skill root, when its first folder does exist (otherwise it is prose);
                     files under assets/ and files named sample-* are not checked, they describe emitted output
  old-module-format  a `module.yaml` or `module-help.csv` mention; modules are described by bmod.toml now
  python-call        `python x.py`, `python3 -m x` or `pip install`; every script runs as `uv run <path>`,
                     which reads the script's PEP 723 header for its dependencies

Fenced code blocks are checked for bare-script-call, installed-path, absolute-path, old-module-format and python-call
(a wrong example teaches the wrong call) and skipped for the two reference-resolution rules.

Usage:
  scan_paths.py <skill-folder> [--allow RULE ...]

--allow suppresses a rule by name, for a skill that documents the old format on purpose
(`--allow old-module-format`).

Output, one JSON object on stdout:
  {"skill": str, "files_scanned": int, "findings": [{"path", "line", "rule", "text", "fix"}, ...]}
Exit 0 when clean, 1 when there are findings, 2 on a usage error.
"""

from __future__ import annotations

import argparse
import json
import re
import sys
from pathlib import Path, PurePosixPath, PureWindowsPath

SKIP_DIRS = {".git", "__pycache__", "node_modules", ".venv", "venv"}
EXAMPLE_DIR = "assets"
EXAMPLE_PREFIX = "sample-"

BARE_SCRIPT_RE = re.compile(r"\buv\s+run\b[^`\n]*?\s(?:\./)?scripts/\S+")
INSTALLED_PATH_RE = re.compile(r"\{installed_path\}|\binstalled_path\s*[:=]")
# `~/.bmad/` is BMad's own per-user folder, the same path on every machine.
ABS_PATH_RE = re.compile(r"(?:/Users/|/home/|\b[A-Za-z]:[\\/]|(?<![\w.])~/(?!\.bmad/))\S*")
OLD_FORMAT_RE = re.compile(r"\bmodule\.yaml\b|\bmodule-help\.csv\b")
PYTHON_CALL_RE = re.compile(r"(?<![\w/.-])(?:python3?|pip3?)\s+(?:-m\s+\S+|\S+\.py\b|install\b)")
BACKTICK_REF_RE = re.compile(r"`([^`\s]+/[^`\s]+\.(?:md|yaml|yml|toml|json|csv|txt|xml|py|html))`")
SKILL_DIR_RE = re.compile(r"(?:^|/)(?:skills|\.claude/skills|\.agents/skills|_bmad)/([a-z0-9][a-z0-9-]*)/")
# Runtime folders under _bmad that are not skills.
RULES = {
    "bare-script-call",
    "installed-path",
    "absolute-path",
    "cross-skill-ref",
    "missing-file",
    "old-module-format",
    "python-call",
}
BMAD_RUNTIME_DIRS = {"scripts", "config", "custom", "memory", "render", "_config", "knowledge"}


def finding(path: str, line: int, rule: str, text: str, fix: str) -> dict:
    return {"path": path, "line": line, "rule": rule, "text": text.strip()[:200], "fix": fix}


def blank_fences(content: str) -> str:
    """Blank fenced code blocks but keep their newlines so line numbers stay aligned."""
    return re.sub(r"```.*?```", lambda m: re.sub(r"[^\n]", "", m.group(0)), content, flags=re.DOTALL)


def line_of(content: str, offset: int) -> int:
    return content.count("\n", 0, offset) + 1


def iter_md_files(skill_root: Path):
    for path in sorted(skill_root.rglob("*.md")):
        parts = path.relative_to(skill_root).parts
        if any(part in SKIP_DIRS or part.startswith(".") for part in parts):
            continue
        yield path


def is_example(rel: Path) -> bool:
    return EXAMPLE_DIR in rel.parts[:-1] or rel.name.startswith(EXAMPLE_PREFIX)


def scan_regex_rules(content: str, rel: str) -> list[dict]:
    findings = []
    for regex, rule, fix in (
        (BARE_SCRIPT_RE, "bare-script-call", "write `uv run {skill-root}/scripts/<name>.py`"),
        (INSTALLED_PATH_RE, "installed-path", "remove installed_path; use a path relative to this file"),
        (ABS_PATH_RE, "absolute-path", "use {project-root}, {skill-root} or a config value"),
        (OLD_FORMAT_RE, "old-module-format", "describe the module in bmod.toml; see the migrate mode"),
        (
            PYTHON_CALL_RE,
            "python-call",
            "run it as `uv run <path>`; dependencies come from the script's PEP 723 header",
        ),
    ):
        for match in regex.finditer(content):
            findings.append(finding(rel, line_of(content, match.start()), rule, match.group(0), fix))
    return findings


def scan_references(content: str, rel: Path, skill_root: Path) -> list[dict]:
    findings = []
    stripped = blank_fences(content)
    skill_name = skill_root.name
    file_dir = (skill_root / rel).parent
    for match in BACKTICK_REF_RE.finditer(stripped):
        raw = match.group(1)
        line = line_of(stripped, match.start())
        other = SKILL_DIR_RE.search(raw)
        if other and other.group(1) != skill_name and other.group(1) not in BMAD_RUNTIME_DIRS:
            findings.append(
                finding(
                    rel.as_posix(),
                    line,
                    "cross-skill-ref",
                    raw,
                    f'do not reach into `{other.group(1)}`; write "invoke the `{other.group(1)}` skill"',
                )
            )
            continue
        if any(ch in raw for ch in "*<{"):
            continue
        if raw.startswith("../"):
            target = (file_dir / raw).resolve()
            if skill_root.resolve() not in target.parents and target != skill_root.resolve():
                findings.append(finding(rel.as_posix(), line, "cross-skill-ref", raw, "a skill's files stay inside it"))
            continue
        if raw.startswith(("/", "./", "_bmad/", "@")) or is_example(rel):
            continue
        roots = [file_dir, skill_root]
        if any((root / raw).exists() for root in roots):
            continue
        first_dir = raw.split("/")[0]
        if any((root / first_dir).is_dir() for root in roots):
            findings.append(
                finding(rel.as_posix(), line, "missing-file", raw, "fix the path or remove the dead reference")
            )
    return findings


def scan_skill(skill_root: Path, allow: tuple[str, ...] = ()) -> dict:
    findings: list[dict] = []
    count = 0
    for path in iter_md_files(skill_root):
        count += 1
        rel = path.relative_to(skill_root)
        content = path.read_text(encoding="utf-8", errors="replace")
        findings.extend(scan_regex_rules(content, rel.as_posix()))
        findings.extend(scan_references(content, rel, skill_root))
    # Eval cases name fixtures; an absolute path there breaks the run for everyone else.
    for path in sorted((skill_root / "evals").glob("*.json")):
        count += 1
        content = path.read_text(encoding="utf-8", errors="replace")
        try:
            data = json.loads(content)
        except json.JSONDecodeError:
            continue
        cases = data.get("cases", []) if isinstance(data, dict) else data
        entries = [str(f) for c in cases if isinstance(c, dict) for f in c.get("files") or []]
        for entry in entries:
            # The same test the eval runner applies: any absolute or home path is refused there.
            if "://" in entry or not (
                entry.startswith("~") or PurePosixPath(entry).is_absolute() or PureWindowsPath(entry).is_absolute()
            ):
                continue
            findings.append(
                finding(
                    path.relative_to(skill_root).as_posix(),
                    line_of(content, max(content.find(json.dumps(entry)), 0)),
                    "absolute-path",
                    entry,
                    "use a path relative to the cases file or the project root, or a GitHub file URL pinned to a commit",
                )
            )
    findings = [f for f in findings if f["rule"] not in allow]
    findings.sort(key=lambda f: (f["path"], f["line"], f["rule"]))
    return {"skill": skill_root.name, "files_scanned": count, "findings": findings}


def main(argv: list[str] | None = None) -> int:
    p = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
    p.add_argument("skill", type=Path, help="skill folder to scan")
    p.add_argument("--allow", action="append", default=[], metavar="RULE", help="suppress a rule by name (repeatable)")
    args = p.parse_args(argv)
    if not args.skill.is_dir():
        p.error(f"not a directory: {args.skill}")
    unknown = sorted(set(args.allow) - RULES)
    if unknown:
        p.error(f"unknown rule(s): {', '.join(unknown)}; rules: {', '.join(sorted(RULES))}")
    result = scan_skill(args.skill, tuple(args.allow))
    print(json.dumps(result, indent=2))
    return 1 if result["findings"] else 0


if __name__ == "__main__":
    sys.exit(main())
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall