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/laya/brain.py

View on GitHub
import math
import re
import sys
from typing import Any
from urllib.parse import urlparse

from anything_to_skill.laya import client
from anything_to_skill.laya.questions import agree, ask_probs
from anything_to_skill.sources.web.frontier import Link

# One 100-way "which link?" choice put every option in the uncalibrated `choice:11+`
# bucket and was min-max normalised, so on the postgres docs sql-create* pages scored 0.94
# and performance-tips 0.0. Each page instead gets its own two-option question (the
# calibrated `choice:2` bucket) in both orders, like the videos below. Asking with the
# page first and the goal last ranked best (AUC 0.74 against 0.69 the other way round).
PAGE_INSTRUCTIONS = 'Does this page match the goal?'
PAGE_MATCH = ['The page matches the goal.', 'The page does not match the goal.']
# Measured on the recorded 143-video channel listing (scripts/tests/fixtures): asking
# whether the *video* is about the topic, with the title first, ranks on-goal videos
# higher than 'does the title match the topic?' (AUC 0.72 vs 0.67 for an AI goal, 0.94
# vs 0.73 for a TypeScript goal).
VIDEO_INSTRUCTIONS = 'Is this video about the topic?'
VIDEO_ON_TOPIC = ['The video is about the topic.', 'The video is not about the topic.']
CANDIDATES_PER_SIGNAL = 100
ANCHOR_CHARS = 50
PATH_CHARS = 40
TITLE_CHARS = 70
_PATH_SEPARATORS = re.compile(r'[-_/.]+')
_EXTENSION = re.compile(r'\.(html?|php|aspx?|md)$', re.I)


def _describe(link: Link) -> str:
    """What is known of a page before fetching it: anchor text, URL path words, heading."""
    path = _PATH_SEPARATORS.sub(' ', _EXTENSION.sub('', urlparse(link.url).path)).strip()
    parts = [
        link.anchor.strip()[:ANCHOR_CHARS],
        path[-PATH_CHARS:],
        link.heading.strip()[:ANCHOR_CHARS],
    ]
    return ' | '.join(p for p in parts if p) or link.url[:PATH_CHARS]


def _match_prob(
    name: str, state: str, instructions: str, options: list[str]
) -> tuple[float, bool]:
    """(mean p(first option) over both option orders, whether the orders agreed)."""
    forward, backward = ask_probs(state, {name: (instructions, options)})[name]
    return (forward[0] + backward[0]) / 2, agree(forward, backward) is not None


def _video_title(entry: dict[str, Any]) -> str:
    title = ' '.join(str(entry.get('title') or '').split())[:TITLE_CHARS]
    return title or str(entry.get('url', ''))[:PATH_CHARS]


class LayaScorer:
    """LinkScorer backed by Laya: p(page matches the goal), averaged over both option orders.

    Raises LayaUnavailableError at construction so the caller can fall back to rules; any later
    failure only yields neutral scores, since a wrong ranking changes fetch order and never
    content. The raw probability is kept (no collapsing of order disagreement to a constant),
    so an unsure page still sits between a confident match and a confident miss.
    """

    def __init__(self, goal: str) -> None:
        self.goal = goal
        client.get_router()
        self._warned = False

    def score(
        self,
        goal: str,
        page_title: str,  # noqa: ARG002 - the linking page says nothing about the candidate
        heading_path: str,  # noqa: ARG002
        candidates: list[Link],
    ) -> list[float]:
        try:
            scores = [
                _match_prob(
                    'page',
                    f'Page: {_describe(link)}\nGoal: {goal or self.goal}',
                    PAGE_INSTRUCTIONS,
                    PAGE_MATCH,
                )[0]
                for link in candidates
            ]
        except Exception as exc:  # noqa: BLE001 - benign by design, see class docstring
            if not self._warned:
                print(
                    f'laya brain: falling back to neutral scores ({exc})', file=sys.stderr
                )
                self._warned = True
            return [0.5] * len(candidates)
        return scores


class LayaVideoRanker:
    """Judges channel or playlist entries against the goal one at a time. Unlike LayaScorer,
    a failure raises: the ranking decides which videos get fetched, so the caller falls
    back to keyword selection instead of accepting neutral scores.

    A 20-way choice would put every option in the checkpoint's uncalibrated `choice:11+`
    bucket and, past the shortlist, score the rest 0. Each candidate instead gets its own
    two-option question (the calibrated `choice:2` bucket) asked in both orders, and the
    candidates are the union of the best keyword and embedding matches, so an on-topic
    title is judged even when the embedding misses it.
    """

    def __init__(self, goal: str) -> None:
        self.goal = goal
        client.get_router()

    def candidates(self, options: list[str], hits: list[int]) -> list[int]:
        """Indexes worth judging: top keyword matches plus nearest embeddings."""
        if len(options) <= 2 * CANDIDATES_PER_SIGNAL:
            return list(range(len(options)))
        by_keywords = sorted(
            (i for i, h in enumerate(hits) if h > 0), key=lambda i: (-hits[i], i)
        )[:CANDIDATES_PER_SIGNAL]
        return sorted({*by_keywords, *self._nearest(options, CANDIDATES_PER_SIGNAL)})

    def _nearest(self, options: list[str], k: int) -> list[int]:
        query, *rows = (
            [float(x) for x in v] for v in client.embed_fn()([self.goal, *options])
        )
        norm = math.sqrt(sum(x * x for x in query)) or 1.0
        sims = [
            sum(a * b for a, b in zip(query, row, strict=True))
            / (norm * (math.sqrt(sum(x * x for x in row)) or 1.0))
            for row in rows
        ]
        return sorted(range(len(rows)), key=lambda i: -sims[i])[:k]

    def score(
        self, entries: list[dict[str, Any]], hits: list[int]
    ) -> tuple[list[float | None], list[bool]]:
        """(on-topic probability per entry, orders agreed per entry).

        None means the entry was not judged. The score is the raw probability averaged over
        both option orders: collapsing disagreement to 0.5 put every unsure video above the
        confidently off-topic ones (mean ~0.33) and tied them, hiding real differences.
        """
        options = [_video_title(e) for e in entries]
        scores: list[float | None] = [None] * len(entries)
        agreed = [False] * len(entries)
        for i in self.candidates(options, hits):
            scores[i], agreed[i] = _match_prob(
                'video',
                f'Video title: {options[i]}\nTopic: {self.goal}',
                VIDEO_INSTRUCTIONS,
                VIDEO_ON_TOPIC,
            )
        return scores, agreed

    def judge(self, evidence: list[str]) -> list[float]:
        """On-topic probability of each evidence text (description, chapters or a transcript
        excerpt). Same two-option question as `score`, so stage scores are comparable."""
        return [
            _match_prob(
                'video', f'{text}\nTopic: {self.goal}', VIDEO_INSTRUCTIONS, VIDEO_ON_TOPIC
            )[0]
            for text in evidence
        ]
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