Skip to content

MacHu-GWU/sqlalchemy_upsert_kit-project / .claude/skills/pywf-oss-base

pywf-oss-base

Flagged

Shared conventions, references, and scripts of the pywf-oss skills for pywf open-source Python libraries: setup, layout, code style, tests, user docs and the agent skills that hold API and maintenance knowledge, CI and hosting, release, dependencies, and secrets. Load it before ad-hoc work on modules, tests, or docs in such a repo, for a question about these conventions, or when unsure which pywf-oss skill fits a job.

FileKindSize
SKILL.mdskill md6.5 KB
assets/community-skills.tomlconfig2.4 KB
assets/notebook-page-template.ipynbother1.1 KB
assets/raw-rst-cell.jsonconfig255 B
references/00-authoring-references.mdmarkdown6.3 KB
references/01-secrets.mdmarkdown3.0 KB
references/02-machine-setup.mdmarkdown3.2 KB
references/03-mise.mdmarkdown2.1 KB
references/04-python-versions.mdmarkdown1.8 KB
references/05-uv-dependencies.mdmarkdown2.0 KB
references/06-ruff.mdmarkdown1.9 KB
references/07-repo-layout.mdmarkdown2.3 KB
references/08-package-files.mdmarkdown3.9 KB
references/09-code-style.mdmarkdown5.6 KB
references/10-test-layout.mdmarkdown4.1 KB
references/11-test-writing.mdmarkdown2.1 KB
references/12-coverage.mdmarkdown1.1 KB
references/13-sphinx.mdmarkdown5.6 KB
references/14-docfly.mdmarkdown2.2 KB
references/15-furo.mdmarkdown1.4 KB
references/16-sphinx-design.mdmarkdown5.8 KB
references/17-nbsphinx.mdmarkdown5.0 KB
references/18-knowledge-channels.mdmarkdown3.8 KB
references/19-github-actions.mdmarkdown3.7 KB
references/20-codecov.mdmarkdown1.3 KB
references/21-readthedocs.mdmarkdown1.7 KB
references/22-versioning-and-changelog.mdmarkdown3.0 KB
references/23-release.mdmarkdown1.3 KB
references/24-dependency-upgrades.mdmarkdown3.2 KB
references/25-python-release-cycle.mdmarkdown1.4 KB
references/26-community-skills.mdmarkdown5.0 KB
references/27-skill-family-workflow.mdmarkdown6.5 KB
scripts/check_doc_xrefs.pyscript3.4 KB
scripts/check_one_import_per_line.pyscript4.2 KB
scripts/check_skill_family.pyscript6.5 KB
scripts/check_test_layout.pyscript6.2 KB
scripts/install_community_skill.pyscript8.6 KB
scripts/update_skill_index.pyscript4.1 KB

scripts/check_skill_family.py

View on GitHub
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Check a base + invoker skill family against the rules in 00-authoring-references.md."""

from __future__ import annotations

import argparse
import re
import sys
from pathlib import Path

RE_FRONTMATTER = re.compile(r"\A---\n(.*?)\n---\n", re.DOTALL)
RE_REF_CITE = re.compile(r"(?<![\w-])(\d{2})-[a-z0-9-]+\.md")
RE_FENCE = re.compile(r"^(```|~~~)")
SCANNED_SUFFIXES = {".md", ".py", ".json", ".ipynb"}


def frontmatter(text: str) -> str | None:
    """Return the YAML frontmatter body, or None when the file has none."""
    match = RE_FRONTMATTER.match(text)
    return match.group(1) if match else None


def field(fm: str, name: str) -> str | None:
    """Return the raw value of a top-level frontmatter field."""
    match = re.search(rf"^{name}:\s*(.*)$", fm, re.MULTILINE)
    return match.group(1).strip() if match else None


def is_double_quoted(value: str | None) -> bool:
    """True for a single double-quoted string with no inner double quotes."""
    return (
        bool(value)
        and value.startswith('"')
        and value.endswith('"')
        and value.count('"') == 2
    )


def count_h1(text: str) -> int:
    """Count level-1 Markdown headings outside fenced code blocks."""
    in_fence = False
    count = 0
    for line in text.splitlines():
        if RE_FENCE.match(line.strip()):
            in_fence = not in_fence
        elif not in_fence and line.startswith("# "):
            count += 1
    return count


def check_skills(skills_dir: Path, prefix: str, errors: list[str]) -> None:
    """Frontmatter of every SKILL.md, and every ../<prefix>-base/... path an invoker cites."""
    re_base_path = re.compile(rf"\.\./{re.escape(prefix)}-base/[A-Za-z0-9_./*-]+")
    for skill in sorted(skills_dir.glob(f"{prefix}-*")):
        skill_md = skill / "SKILL.md"
        if not skill_md.exists():
            errors.append(f"{skill.name}: missing SKILL.md")
            continue
        text = skill_md.read_text(encoding="utf-8")
        fm = frontmatter(text)
        if fm is None:
            errors.append(f"{skill_md}: no frontmatter")
            continue
        if field(fm, "name") != skill.name:
            errors.append(
                f"{skill_md}: name is {field(fm, 'name')!r}, expected {skill.name!r}"
            )
        if not is_double_quoted(field(fm, "description")):
            errors.append(f"{skill_md}: description must be one double-quoted string")
        if field(fm, "disable-model-invocation") is not None:
            errors.append(
                f"{skill_md}: skills are model-invocable; remove disable-model-invocation"
            )
        for raw in sorted(set(re_base_path.findall(text))):
            rel = raw.rstrip(".,)")
            if "*" in rel:
                found = list(skill.glob(rel))
            else:
                found = [skill / rel] if (skill / rel).exists() else []
            if not found:
                errors.append(f"{skill_md}: path does not resolve: {rel}")


def check_references(skills_dir: Path, prefix: str, errors: list[str]) -> None:
    """Reference shape, cited references exist, and no reference cites a later one."""
    ref_dir = skills_dir / f"{prefix}-base" / "references"
    existing = {p.name for p in ref_dir.glob("*.md")}
    for path in sorted(skills_dir.glob(f"{prefix}-*/**/*.md")):
        text = path.read_text(encoding="utf-8")
        is_reference = path.parent == ref_dir
        if is_reference:
            fm = frontmatter(text)
            if fm is None or not is_double_quoted(field(fm, "description")):
                errors.append(
                    f"{path.name}: needs frontmatter with one double-quoted description"
                )
            if count_h1(text) != 1:
                errors.append(
                    f"{path.name}: needs exactly one H1, found {count_h1(text)}"
                )
        own = path.name[:2] if is_reference else None
        for match in RE_REF_CITE.finditer(text):
            cited = match.group(0)
            if cited not in existing:
                errors.append(
                    f"{path.relative_to(skills_dir)}: cites missing reference {cited}"
                )
                continue
            if own is not None and cited[:2] > own:
                errors.append(
                    f"{path.name}: cites later reference {cited} (cite backward only)"
                )


def check_forbidden(
    skills_dir: Path, prefix: str, forbid: list[str], errors: list[str]
) -> None:
    """No project-specific name appears anywhere in the family."""
    if not forbid:
        return
    for path in sorted(skills_dir.glob(f"{prefix}-*/**/*")):
        if not path.is_file() or path.suffix not in SCANNED_SUFFIXES:
            continue
        text = path.read_text(encoding="utf-8")
        for name in forbid:
            if name in text:
                line_no = text[: text.index(name)].count("\n") + 1
                errors.append(
                    f"{path.relative_to(skills_dir)}:{line_no}: forbidden name {name!r}"
                )


def _main(
    skills_dir: Path, prefix: str = "pywf-oss", forbid: list[str] | None = None
) -> int:
    """Run every check and print one line per problem.

    Returns 0 when the family is consistent, 1 when any problem is found.
    """
    if not (skills_dir / f"{prefix}-base").is_dir():
        print(f"ERROR: {skills_dir}/{prefix}-base not found", file=sys.stderr)
        return 1
    errors: list[str] = []
    check_skills(skills_dir, prefix, errors)
    check_references(skills_dir, prefix, errors)
    check_forbidden(skills_dir, prefix, forbid or [], errors)
    for error in errors:
        print(error)
    print(f"{len(errors)} problem(s)")
    return 1 if errors else 0


def main(argv: list[str] | None = None) -> int:
    parser = argparse.ArgumentParser(
        prog="check_skill_family",
        description="Check a base + invoker skill family against its authoring rules.",
    )
    parser.add_argument(
        "--skills_dir",
        type=Path,
        default=Path(__file__).resolve().parent.parent.parent,
        help="folder holding the skills (default: the folder that holds this script's skill)",
    )
    parser.add_argument(
        "--prefix", default="pywf-oss", help="skill family prefix (default: pywf-oss)"
    )
    parser.add_argument(
        "--forbid",
        action="append",
        default=[],
        help="a project-specific name that must not appear; repeat for several",
    )
    args = parser.parse_args(argv)
    return _main(skills_dir=args.skills_dir, prefix=args.prefix, forbid=args.forbid)


if __name__ == "__main__":
    sys.exit(main())
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 471kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall