Skip to content

mgiovani/ai-arsenal / skills/anything-to-skill

anything-to-skill

Verified

Turns a docs site, local folder, PDF or book, YouTube video, playlist or channel, or a topic into a source-grounded, token-efficient agent skill (hub SKILL.md, sectioned references, INDEX, evals), and can compact it into a lean expert skill. Use for "make a skill from these docs", "turn this channel into a skill". Not for a skill from your own description (use create-skill), improving one (use improve-skill) or finding third-party skills (use find-skills).

FileKindSize
SKILL.mdskill md29.0 KB
assets/templates/SKILL.md.tmplother53 B
assets/templates/evals.json.tmplother41 B
assets/templates/trigger-eval.json.tmplother9 B
evals/evals.jsonconfig6.2 KB
evals/trigger-eval.jsonconfig1.9 KB
references/compaction.mdmarkdown5.8 KB
references/evals.mdmarkdown2.9 KB
references/extending.mdmarkdown2.6 KB
references/generated-skill-layout.mdmarkdown7.1 KB
references/interview.mdmarkdown2.7 KB
references/judge.mdmarkdown3.5 KB
references/sources.mdmarkdown11.1 KB
scripts/a2s.pyexecutablescript520 B
scripts/anything_to_skill/__init__.pyscript0 B
scripts/anything_to_skill/cli.pyscript17.5 KB
scripts/anything_to_skill/compact/__init__.pyscript0 B
scripts/anything_to_skill/compact/brief.pyscript8.2 KB
scripts/anything_to_skill/compact/freeze.pyscript3.5 KB
scripts/anything_to_skill/compact/gate.pyscript2.8 KB
scripts/anything_to_skill/compact/layout.pyscript1.6 KB
scripts/anything_to_skill/compact/swap.pyscript3.8 KB
scripts/anything_to_skill/compact/verify.pyscript15.4 KB
scripts/anything_to_skill/core/__init__.pyscript0 B
scripts/anything_to_skill/core/models.pyscript3.1 KB
scripts/anything_to_skill/core/sanitize.pyscript2.1 KB
scripts/anything_to_skill/core/ssrf.pyscript1.8 KB
scripts/anything_to_skill/core/store.pyscript13.8 KB
scripts/anything_to_skill/core/tokens.pyscript147 B
scripts/anything_to_skill/core/workspace.pyscript4.7 KB
scripts/anything_to_skill/emit/__init__.pyscript0 B
scripts/anything_to_skill/emit/link.pyscript612 B
scripts/anything_to_skill/emit/templates.pyscript398 B
scripts/anything_to_skill/emit/verify.pyscript9.7 KB
scripts/anything_to_skill/emit/write.pyscript21.0 KB
scripts/anything_to_skill/laya/__init__.pyscript0 B
scripts/anything_to_skill/laya/apply.pyscript3.1 KB
scripts/anything_to_skill/laya/brain.pyscript6.9 KB
scripts/anything_to_skill/laya/client.pyscript2.2 KB
scripts/anything_to_skill/laya/factcheck.pyscript10.5 KB
scripts/anything_to_skill/laya/judge.pyscript6.8 KB
scripts/anything_to_skill/laya/questions.pyscript2.1 KB
scripts/anything_to_skill/plan/__init__.pyscript0 B
scripts/anything_to_skill/plan/brief.pyscript8.1 KB
scripts/anything_to_skill/plan/index.pyscript912 B
scripts/anything_to_skill/plan/pack.pyscript16.6 KB
scripts/anything_to_skill/plan/priority.pyscript5.0 KB
scripts/anything_to_skill/plan/tree.pyscript19.1 KB
scripts/anything_to_skill/scan/__init__.pyscript0 B
scripts/anything_to_skill/scan/credentials.pyscript1.1 KB
scripts/anything_to_skill/scan/injection.pyscript1.9 KB
scripts/anything_to_skill/scan/quotes.pyscript8.4 KB
scripts/anything_to_skill/scan/unicode.pyscript691 B
scripts/anything_to_skill/sources/__init__.pyscript1.2 KB
scripts/anything_to_skill/sources/local/__init__.pyscript0 B
scripts/anything_to_skill/sources/local/convert.pyscript4.6 KB
scripts/anything_to_skill/sources/local/detect.pyscript178 B
scripts/anything_to_skill/sources/local/run.pyscript4.5 KB
scripts/anything_to_skill/sources/local/walk.pyscript1.1 KB
scripts/anything_to_skill/sources/web/__init__.pyscript0 B
scripts/anything_to_skill/sources/web/browser.pyscript4.2 KB
scripts/anything_to_skill/sources/web/detect.pyscript144 B
scripts/anything_to_skill/sources/web/discover.pyscript21.4 KB
scripts/anything_to_skill/sources/web/extract.pyscript13.0 KB
scripts/anything_to_skill/sources/web/fetch.pyscript8.7 KB
scripts/anything_to_skill/sources/web/frontier.pyscript9.5 KB
scripts/anything_to_skill/sources/web/run.pyscript12.6 KB
scripts/anything_to_skill/sources/web/throttle.pyscript7.3 KB
scripts/anything_to_skill/sources/youtube/__init__.pyscript0 B
scripts/anything_to_skill/sources/youtube/asr.pyscript1.5 KB
scripts/anything_to_skill/sources/youtube/captions.pyscript2.4 KB
scripts/anything_to_skill/sources/youtube/detect.pyscript313 B
scripts/anything_to_skill/sources/youtube/frames.pyscript3.8 KB
scripts/anything_to_skill/sources/youtube/funnel.pyscript7.4 KB
scripts/anything_to_skill/sources/youtube/listing.pyscript5.8 KB
scripts/anything_to_skill/sources/youtube/run.pyscript21.5 KB
scripts/anything_to_skill/sources/youtube/vtt.pyscript3.3 KB
scripts/convert_docling.pyexecutablescript513 B
scripts/crawl_brain.pyexecutablescript637 B
scripts/ingest_local.pyexecutablescript463 B
scripts/ingest_web.pyexecutablescript593 B
scripts/ingest_youtube.pyexecutablescript533 B
scripts/judge.pyexecutablescript481 B
scripts/transcribe.pyexecutablescript689 B
scripts/verify_laya.pyexecutablescript925 B
scripts/youtube_brain.pyexecutablescript598 B

scripts/anything_to_skill/emit/verify.py

View on GitHub
import argparse
import importlib.util
import json
import re
import sys
from dataclasses import asdict, replace
from pathlib import Path
from typing import Any

from anything_to_skill.core.models import Finding
from anything_to_skill.core.store import Store
from anything_to_skill.core.tokens import count
from anything_to_skill.core.workspace import Workspace
from anything_to_skill.emit.write import (
    GENERIC_DESCRIPTION,
    _frontmatter_description,
    skill_name,
)
from anything_to_skill.scan import credentials, injection, quotes, unicode

MAX_SKILL_LINES = 500
MAX_REF_TOKENS = 8000
ALLOWED_KEYS = {'name', 'description'}
QUICK_VALIDATE = (
    Path(__file__).resolve().parents[4] / 'create-skill' / 'scripts' / 'quick_validate.py'
)
_ROUTE = re.compile(r'(?:references|assets|evals)/[\w\-./]*[\w/]')
# An eval assertion about what the agent read or which file it named grades the process:
# a run without the skill fails it for free while content assertions pass without the skill.
_PROCESS = re.compile(
    r'\b(?:references|evals)/[\w\-./]*[\w/]|\b(?:INDEX|SOURCES|SKILL)\.md\b|'
    r'^\W*(?:reads?|opens?|loads?|consults?|refers? to|cites?|'
    r'names? the (?:source|reference|file)|(?:uses?|invokes?) the [\w-]* ?skill)\b',
    re.I,
)
_IMAGE = re.compile(r'!\[[^\]]*\]\(([^)\s]+)\)')
_INDEX_PATH = re.compile(r'^[\s\-*`]*([\w\-./]+\.md)\b')
# Authored files carry claims, so their code and quotes are re-checked against the corpus.
_AUTHORED = re.compile(
    r'^(?:SKILL\.md|references/best-practices\.md|references/examples/.+\.md)$'
)


def add_args(parser: argparse.ArgumentParser) -> None:
    parser.add_argument(
        '--laya', action='store_true', help='also run advisory Laya fact-check'
    )
    parser.add_argument('--dir', help='skill directory (default: the init --out answer)')


def _skill_dir(ws: Workspace, override: str | None) -> Path:
    with ws.open_store() as store:
        out = override or store.get_meta('out')
        name = skill_name(ws, store.get_meta('name'))
    path = Path(out).expanduser() if out else Path('.agents/skills') / name
    return path if path.is_absolute() else Path.cwd() / path


def _frontmatter_keys(text: str) -> list[str] | None:
    m = re.match(r'^---\n(.*?)\n---', text, re.DOTALL)
    if not m:
        return None
    return re.findall(r'^([A-Za-z0-9_-]+):', m.group(1), re.MULTILINE)


def _routing(rel: str, text: str, root: Path, severity: str) -> list[Finding]:
    """Every path mentioned in SKILL.md, and every file INDEX.md lists, must exist."""
    findings = []
    if rel == 'SKILL.md':
        for path in sorted(set(_ROUTE.findall(text))):
            if not (root / path).exists():
                findings.append(
                    Finding('route-missing', f'{path} does not exist', None, severity)
                )
    elif rel == 'references/INDEX.md':
        for i, line in enumerate(text.splitlines(), 1):
            m = _INDEX_PATH.match(line)
            if m and not any(
                (root / base / m.group(1)).is_file() for base in ('', 'references')
            ):
                findings.append(
                    Finding('index-missing', f'{m.group(1)} does not exist', i, 'warn')
                )
    return findings


def process_assertions(raw: str, severity: str) -> list[Finding]:
    """Assertions that check file reads or paths instead of the content of the answer."""
    try:
        cases = json.loads(raw)['evals']
    except (ValueError, KeyError, TypeError):
        return []
    return [
        Finding(
            'eval-process-assertion',
            f'eval {c.get("id")!r}: assertion is about files or process, not answer content: {a[:70]!r}',
            None,
            severity,
        )
        for c in cases
        if isinstance(c, dict)
        for a in c.get('assertions', [])
        if isinstance(a, str) and _PROCESS.search(a)
    ]


def _images(rel: str, text: str, root: Path, severity: str) -> list[Finding]:
    return [
        Finding('image-missing', f'{target} does not exist', None, severity)
        for target in sorted(set(_IMAGE.findall(text)))
        if '://' not in target and not (root / rel).parent.joinpath(target).is_file()
    ]


def _quick_validate(skill: Path) -> dict[str, Any]:
    if not QUICK_VALIDATE.exists():
        return {'skipped': 'create-skill/scripts/quick_validate.py not found'}
    spec = importlib.util.spec_from_file_location('a2s_quick_validate', QUICK_VALIDATE)
    module = importlib.util.module_from_spec(spec)  # type: ignore[arg-type]
    spec.loader.exec_module(module)  # type: ignore[union-attr]
    valid, errors, warnings = module.validate_skill(skill)
    return {'valid': valid, 'errors': errors, 'warnings': warnings}


def _check_file(
    rel: str, text: str, root: Path, store: Store, corpus: dict[int, str]
) -> list[Finding]:
    hard = rel == 'SKILL.md'
    findings = unicode.scan(text) + injection.scan(text)
    if not hard:
        findings = [replace(f, severity='warn') for f in findings]
    findings += credentials.scan(text)
    if _AUTHORED.match(rel):
        findings += quotes.verify(text, store, corpus)
        findings += quotes.verify_links(text, (root / rel).parent)
    findings += _routing(rel, text, root, 'hard' if hard else 'warn')
    findings += _images(rel, text, root, 'hard' if hard else 'warn')
    if rel == 'evals/evals.json':
        findings += process_assertions(text, 'warn')
    if hard:
        keys = _frontmatter_keys(text)
        if keys is None:
            findings.append(
                Finding('frontmatter', 'SKILL.md has no frontmatter', 1, 'hard')
            )
        elif extra := sorted(set(keys) - ALLOWED_KEYS):
            findings.append(
                Finding(
                    'frontmatter',
                    f'unexpected frontmatter keys: {", ".join(extra)}',
                    1,
                    'hard',
                )
            )
        description, _ = _frontmatter_description(text)
        if description and GENERIC_DESCRIPTION.match(description):
            findings.append(
                Finding(
                    'description-generic',
                    'description is the generic default; write one in authored/SKILL.md frontmatter',
                    2,
                    'warn',
                )
            )
        lines = text.count('\n') + 1
        if lines >= MAX_SKILL_LINES:
            findings.append(
                Finding(
                    'limits',
                    f'SKILL.md has {lines} lines (max {MAX_SKILL_LINES - 1})',
                    None,
                    'hard',
                )
            )
    elif rel.startswith('references/') and (tokens := count(text)) > MAX_REF_TOKENS:
        findings.append(
            Finding('limits', f'{tokens} tokens (max {MAX_REF_TOKENS})', None, 'warn')
        )
    return findings


def run(ws: Workspace, args: argparse.Namespace) -> int:
    """`a2s.py verify`: scans, quote check, limits, quick_validate; non-zero on hard fails."""
    root = _skill_dir(ws, args.dir)
    if ws.full_dir.is_dir() and not (root / 'references' / 'SOURCES.md').exists():
        print(
            'verify: this skill was compacted; use `a2s.py compact-verify`, or `compact --revert` first',
            file=sys.stderr,
        )
        return 2
    if not (root / 'SKILL.md').is_file():
        print(
            f'verify: no SKILL.md under {root}; run `a2s.py emit` first', file=sys.stderr
        )
        return 2
    rows: list[dict[str, Any]] = []

    def add(rel: str, findings: list[Finding]) -> None:
        rows.extend({'file': rel, **asdict(f)} for f in findings)

    with ws.open_store() as store:
        corpus = quotes.load_corpus(store)
        for path in sorted(root.rglob('*')):
            rel = path.relative_to(root).as_posix()
            if path.is_file() and path.suffix in ('.md', '.json'):
                add(rel, _check_file(rel, path.read_text('utf-8'), root, store, corpus))

    name_in_dir = root.name
    fm_name = re.search(
        r'^name:\s*(\S+)', (root / 'SKILL.md').read_text('utf-8'), re.MULTILINE
    )
    if fm_name and fm_name.group(1) != name_in_dir:
        add(
            'SKILL.md',
            [
                Finding(
                    'name-dir',
                    f'name {fm_name.group(1)!r} differs from directory {name_in_dir!r}',
                    1,
                    'warn',
                )
            ],
        )

    qv = _quick_validate(root)
    add(
        'SKILL.md',
        [Finding('quick_validate', e, None, 'hard') for e in qv.get('errors', [])],
    )
    add(
        'SKILL.md',
        [Finding('quick_validate', w, None, 'warn') for w in qv.get('warnings', [])],
    )

    laya: Any = None
    if args.laya:
        ws.verify_path.unlink(missing_ok=True)
        try:
            from anything_to_skill.laya import factcheck  # noqa: PLC0415

            add('(laya)', factcheck.run(ws))
            if ws.verify_path.exists():
                laya = json.loads(ws.verify_path.read_text('utf-8')).get('laya')
        except Exception as exc:  # noqa: BLE001
            add(
                '(laya)',
                [Finding('laya-unavailable', f'fact-check skipped: {exc}', None, 'warn')],
            )

    hard = sum(r['severity'] == 'hard' for r in rows)
    report = {
        'skill_dir': str(root),
        'ok': hard == 0,
        'hard': hard,
        'warn': len(rows) - hard,
        'quick_validate': qv,
        'findings': rows,
        'laya': laya,
    }
    ws.verify_path.write_text(json.dumps(report, indent=2), encoding='utf-8')
    for r in rows:
        if r['severity'] == 'hard':
            print(
                f'HARD {r["file"]}:{r["line"] or "-"} {r["rule"]}: {r["message"]}',
                file=sys.stderr,
            )
    print(f'verify: {hard} hard, {report["warn"]} warn -> {ws.verify_path}')
    return 1 if hard else 0
canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill.Stars: 198kUpdated Claude CodeCodexVerifiedInstall