Skip to content

A Claude Code skill bundle for bug hunting and external red-team work - 82 skills, 15 slash commands, 681 disclosed-report patterns curated across 24 core vulnerability classes, plus enterprise identity + infrastructure attack matrices.

4.4 KB
Raw Blame
#!/usr/bin/env python3
"""
gen_skill_catalog.py — generate docs/skills.md from every skill's frontmatter.

Keeps the public skill catalog in sync with what's actually on disk. Run after
adding/editing skills:

    python3 scripts/gen_skill_catalog.py

Reads name/description/report_count from each skills/<name>/SKILL.md and writes a
searchable, grouped catalog page (Jekyll front matter included for the docs site).
Stdlib only.
"""
import os
import re

REPO = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SKILLS_DIR = os.path.join(REPO, "skills")
OUT = os.path.join(REPO, "docs", "skills.md")

# Grouping by name prefix / known membership. Order defines section order.
GROUPS = [
    ("Hunt — web app vuln classes", lambda n: n.startswith("hunt-")),
    ("Enterprise platform attack", lambda n: n in {
        "m365-entra-attack", "okta-attack", "cloud-iam-deep", "vmware-vcenter-attack",
        "enterprise-vpn-attack", "apk-redteam-pipeline", "ios-redteam-pipeline",
        "supply-chain-attack-recon", "meme-coin-audit", "web3-audit"}),
    ("Recon & OSINT", lambda n: "osint" in n or "recon" in n or n == "security-arsenal"),
    ("Methodology & mindset", lambda n: n in {
        "bb-methodology", "bug-bounty", "bb-local-toolkit", "redteam-mindset"}),
    ("Reporting & validation", lambda n: n in {
        "report-writing", "triage-validation", "bugcrowd-reporting", "evidence-hygiene",
        "redteam-report-template", "mid-engagement-ir-detection"}),
]


def parse_frontmatter(path):
    name = desc = ""
    report_count = None
    with open(path, encoding="utf-8") as fh:
        raw = fh.read()
    if not raw.startswith("---"):
        return None
    lines = raw.split("\n")
    for i in range(1, len(lines)):
        if lines[i].strip() == "---":
            break
        m = re.match(r"^(name|description|report_count):\s*(.*)$", lines[i])
        if m:
            k, v = m.group(1), m.group(2).strip()
            if len(v) >= 2 and v[0] == v[-1] and v[0] in "\"'":
                v = v[1:-1].strip()
            if k == "name":
                name = v
            elif k == "description":
                desc = v
            elif k == "report_count":
                report_count = v
    return {"name": name, "description": desc, "report_count": report_count}


def first_sentence(text, limit=240):
    text = text.strip()
    cut = re.split(r"(?<=[.。])\s", text, maxsplit=1)[0]
    if len(cut) > limit:
        cut = cut[:limit].rsplit(" ", 1)[0] + "…"
    return cut


def main():
    skills = []
    for d in sorted(os.listdir(SKILLS_DIR)):
        sp = os.path.join(SKILLS_DIR, d, "SKILL.md")
        if os.path.isfile(sp):
            fm = parse_frontmatter(sp)
            if fm and fm["name"]:
                skills.append(fm)

    assigned = set()
    sections = []
    for title, pred in GROUPS:
        members = [s for s in skills if s["name"] not in assigned and pred(s["name"])]
        for s in members:
            assigned.add(s["name"])
        if members:
            sections.append((title, members))
    leftover = [s for s in skills if s["name"] not in assigned]
    if leftover:
        sections.append(("Other", leftover))

    total = len(skills)
    with open(OUT, "w", encoding="utf-8") as out:
        out.write("---\n")
        out.write("title: Skill catalog\n")
        out.write("nav_order: 2\n")
        out.write("description: Searchable index of every skill in the bundle.\n")
        out.write("---\n\n")
        out.write("# Skill catalog\n\n")
        out.write(f"All **{total} skills** in the bundle, grouped by domain. "
                  "Each auto-loads when your prompt matches its trigger keywords — "
                  "no need to invoke by name. Use your browser's find (⌘/Ctrl-F) "
                  "or the docs search box.\n\n")
        out.write("> Generated by `scripts/gen_skill_catalog.py` — do not edit by hand.\n\n")
        for title, members in sections:
            out.write(f"## {title} ({len(members)})\n\n")
            out.write("| Skill | What it does | Reports |\n")
            out.write("|---|---|---|\n")
            for s in sorted(members, key=lambda x: x["name"]):
                rc = s["report_count"] or "—"
                desc = first_sentence(s["description"]).replace("|", "\\|")
                out.write(f"| `{s['name']}` | {desc} | {rc} |\n")
            out.write("\n")
    print(f"Wrote {OUT} — {total} skills across {len(sections)} sections.")


if __name__ == "__main__":
    main()