Skip to content

shepsci/kaggle-skill / skills/kaggle

kaggle

Flagged

Unified Kaggle skill. Use when the user explicitly mentions Kaggle, kaggle.com, a Kaggle URL, Kaggle competitions, Kaggle datasets/models/notebooks, Kaggle forums/discussions/writeups, Kaggle benchmarks, hackathons hosted on Kaggle, Kaggle badges, or Kaggle account setup. Do not use for generic ML, GPU/TPU, notebook, dataset, benchmark, or data-science tasks unless the user clearly ties them to Kaggle.

FileKindSize
SKILL.mdskill md10.3 KB
modules/README.mdmarkdown2.3 KB
modules/badges/README.mdmarkdown1.6 KB
modules/badges/references/badge-catalog.mdmarkdown6.6 KB
modules/badges/scripts/badge_registry.pyscript8.5 KB
modules/badges/scripts/badge_tracker.pyscript4.1 KB
modules/badges/scripts/orchestrator.pyscript5.3 KB
modules/badges/scripts/phase_1_instant_api.pyscript24.0 KB
modules/badges/scripts/phase_2_competition.pyscript13.5 KB
modules/badges/scripts/phase_3_pipeline.pyscript11.7 KB
modules/badges/scripts/phase_4_browser.pyscript2.2 KB
modules/badges/scripts/phase_5_streaks.pyscript5.6 KB
modules/badges/scripts/templates/README_dataset.mdmarkdown573 B
modules/badges/scripts/templates/dataset-metadata.jsonconfig871 B
modules/badges/scripts/templates/kernel-metadata.jsonconfig412 B
modules/badges/scripts/templates/model-instance-metadata.jsonconfig253 B
modules/badges/scripts/templates/model-metadata.jsonconfig355 B
modules/badges/scripts/templates/python_notebook.ipynbother1.3 KB
modules/badges/scripts/templates/r_notebook.ipynbother1.1 KB
modules/badges/scripts/templates/submission_titanic.csvother2.8 KB
modules/badges/scripts/templates/utility_script.pyscript802 B
modules/badges/scripts/utils.pyscript3.9 KB
modules/benchmarks/README.mdmarkdown1.2 KB
modules/benchmarks/references/benchmark-endpoints.mdmarkdown1.6 KB
modules/benchmarks/references/benchmarks-cli.mdmarkdown4.4 KB
modules/competitions/README.mdmarkdown5.8 KB
modules/competitions/hackathons/README.mdmarkdown2.9 KB
modules/competitions/hackathons/references/episode-endpoints.mdmarkdown2.2 KB
modules/competitions/hackathons/references/hackathon-endpoints.mdmarkdown4.6 KB
modules/competitions/hackathons/scripts/fetch_writeup.pyexecutablescript10.5 KB
modules/competitions/hackathons/scripts/hackathon_overview.pyexecutablescript1.5 KB
modules/competitions/hackathons/scripts/list_writeups.pyexecutablescript9.9 KB
modules/competitions/references/competition-categories.mdmarkdown2.1 KB
modules/competitions/references/competition-operations.mdmarkdown5.7 KB
modules/competitions/references/competition-overview.mdmarkdown3.9 KB
modules/competitions/references/competition-research.mdmarkdown3.0 KB
modules/competitions/scripts/competition_brief.pyscript5.4 KB
modules/competitions/scripts/competition_details.pyscript8.2 KB
modules/competitions/scripts/competition_download.pyscript5.1 KB
modules/competitions/scripts/competition_episodes.pyscript9.2 KB
modules/competitions/scripts/competition_leaderboard.pyscript12.3 KB
modules/competitions/scripts/competition_ledger.pyscript3.3 KB
modules/competitions/scripts/competition_pages.pyexecutablescript1.7 KB
modules/competitions/scripts/competition_status.pyscript9.0 KB
modules/competitions/scripts/competition_submit.pyscript8.9 KB
modules/competitions/scripts/competition_validate.pyscript14.2 KB
modules/competitions/scripts/competition_watch.pyscript5.9 KB
modules/competitions/scripts/list_competitions.pyscript13.3 KB
modules/datasets/README.mdmarkdown2.1 KB
modules/datasets/references/kagglehub-datasets.mdmarkdown2.6 KB
modules/datasets/scripts/dataset_download.pyscript4.1 KB
modules/datasets/scripts/dataset_publish.pyscript5.5 KB
modules/discussions/README.mdmarkdown2.1 KB
modules/discussions/references/writeups.mdmarkdown5.8 KB
modules/discussions/scripts/forums.pyscript22.0 KB
modules/discussions/scripts/leaderboard_writeups.pyscript24.8 KB
modules/models/README.mdmarkdown2.6 KB
modules/models/references/kagglehub-models.mdmarkdown1.7 KB
modules/models/scripts/model_download.pyscript4.5 KB
modules/models/scripts/model_publish.pyscript8.7 KB
modules/notebooks/README.mdmarkdown2.6 KB
modules/notebooks/scripts/notebook_push.pyscript5.7 KB
modules/notebooks/scripts/notebook_run.pyscript2.8 KB
modules/notebooks/scripts/notebook_wait.pyscript3.7 KB
modules/references/README.mdmarkdown454 B
modules/references/cli-reference.mdmarkdown13.4 KB
modules/references/kaggle-knowledge.mdmarkdown7.6 KB
modules/references/mcp-reference.mdmarkdown18.9 KB
modules/setup/README.mdmarkdown3.0 KB
modules/setup/references/kaggle-setup.mdmarkdown6.7 KB
modules/setup/scripts/check_all_credentials.pyscript5.7 KB
modules/setup/scripts/doctor.pyscript10.2 KB
modules/setup/scripts/save_credentials.pyscript3.9 KB
scripts/kaggle_skill.pyscript11.5 KB
shared/__init__.pyscript0 B
shared/competition.pyscript20.0 KB
shared/credentials.pyscript9.6 KB
shared/hub.pyscript2.9 KB
shared/kaggle_cli.pyscript20.7 KB
shared/ledger.pyscript3.6 KB
shared/mcp_client.pyscript11.6 KB
shared/net.pyscript6.9 KB
shared/notebook.pyscript4.4 KB
shared/preflight.pyscript5.1 KB
shared/safe_extract.pyscript2.7 KB
shared/script.pyscript11.2 KB
shared/text.pyscript10.5 KB
shared/untrusted.pyscript7.6 KB

shared/untrusted.py

View on GitHub
"""Boundary markers for Kaggle-supplied text.

Everything Kaggle returns that a person outside this skill can author (page
bodies, titles, team names, file names, forum posts, CLI error text) is data,
not instructions. Scripts print it inside a block like::

    <untrusted-content-3f9a1c2b source="kaggle-mcp" tool="list_competition_pages">
    ...
    </untrusted-content-3f9a1c2b>

The tag name carries a random suffix chosen per block, so the content cannot
close its own block: it does not know the suffix. As a second layer, anything
in the content that looks like one of these tags is defanged, and JSON output
escapes ``<`` and ``>`` so no markup survives inside it.

Text is printed as it is written: a dash stays a dash and an emoji stays an
emoji. The exception is what a reader cannot see. Control characters,
zero-width and bidirectional format characters, tag characters and private-use
code points are removed from text and written as ``\\uXXXX`` escapes in JSON,
because hidden text is one way to smuggle instructions past a person who
reviews the output.
"""

from __future__ import annotations

import html
import json
import re
import secrets
import sys
from typing import IO, Any

TAG = "untrusted-content"

_MARKER_RE = re.compile(r"<(\s*/?\s*)untrusted-content", re.IGNORECASE)
# C0 controls other than tab, newline and carriage return.
_CONTROL_RE = re.compile(r"[\x00-\x08\x0b\x0c\x0e-\x1f]")
# A carriage return moves a terminal back to the start of the line, so the
# text after it hides the text before it. It becomes a line break.
_RETURN_RE = re.compile(r"\r\n?")
# What a reader cannot see: DEL and the C1 controls, the soft hyphen, the
# combining grapheme joiner, the Arabic letter mark, the Hangul and Khmer
# fillers, the Mongolian variation selectors and vowel separator, zero-width
# and bidirectional format characters, the byte-order mark, interlinear
# annotation marks, the shorthand and musical format controls, surrogates,
# private-use code points, tag characters and the variation-selector
# supplement.
_HIDDEN = (
    "\x7f-\x9f\u00ad\u034f\u061c\u115f\u1160\u17b4\u17b5\u180b-\u180f\u200b-\u200f"
    "\u202a-\u202e\u2060-\u206f\u3164\ufeff\uffa0\ufff0-\ufffb"
    "\U0001bca0-\U0001bca3\U0001d173-\U0001d17a"
    "\ud800-\udfff\ue000-\uf8ff\U000e0000-\U000e0fff\U000f0000-\U0010ffff"
)
# One variation selector after a character picks how it is drawn (the emoji
# style of a heart). Two or more in a row carry nothing a reader sees, and a
# run of them can spell out bytes, so a run counts as hidden, also when other
# hidden characters sit between the selectors.
_SELECTOR_RUN = f"[\ufe00-\ufe0f](?:[{_HIDDEN}]*[\ufe00-\ufe0f])+"
_HIDDEN_RUN_RE = re.compile(f"(?:[{_HIDDEN}]|{_SELECTOR_RUN})+")
_LINE_SEPARATOR_RE = re.compile("[\u2028\u2029]")
_JSON_ESCAPE_RE = re.compile(f"[<>\u2028\u2029{_HIDDEN}]|{_SELECTOR_RUN}")
# A run this long is not typography (a joiner in an emoji, a stray soft
# hyphen). It is replaced by a note instead of being dropped without a trace.
HIDDEN_RUN_NOTE_AT = 4


def new_nonce() -> str:
    """Return the random suffix for one block."""
    return secrets.token_hex(4)


def _hidden_note(match: re.Match[str]) -> str:
    count = len(match.group(0))
    return f"[{count} hidden characters removed]" if count >= HIDDEN_RUN_NOTE_AT else ""


def strip_hidden(text: str) -> str:
    """Remove control and invisible characters; note a long run of them."""
    text = _CONTROL_RE.sub("", text)
    text = _RETURN_RE.sub("\n", text)
    text = _LINE_SEPARATOR_RE.sub("\n", text)
    return _HIDDEN_RUN_RE.sub(_hidden_note, text)


def neutralize(text: str) -> str:
    """Defang tag lookalikes and remove what cannot be seen in raw text."""
    # Hidden characters go first, so they cannot split a lookalike tag.
    return _MARKER_RE.sub(lambda m: "&lt;" + m.group(1) + TAG, strip_hidden(text))


def _json_escape(match: re.Match[str]) -> str:
    return "".join(_escape_one(ord(char)) for char in match.group(0))


def _escape_one(code: int) -> str:
    if code > 0xFFFF:
        code -= 0x10000
        return f"\\u{0xD800 + (code >> 10):04x}\\u{0xDC00 + (code & 0x3FF):04x}"
    return f"\\u{code:04x}"


def dumps(
    obj: Any, *, indent: int | None = None, sort_keys: bool = False, ensure_ascii: bool = False
) -> str:
    """Serialize to JSON with ``<``, ``>`` and invisible characters escaped.

    Other text is left as written, so titles and names stay readable. The
    result is valid JSON and parses back to the same value.
    """
    text = json.dumps(obj, indent=indent, sort_keys=sort_keys, ensure_ascii=ensure_ascii)
    return _JSON_ESCAPE_RE.sub(_json_escape, text)


def _print(text: str, file: IO[str], *, end: str = "\n", ascii_text: Any = None) -> None:
    """Print, and fall back to escapes on a stream that cannot encode the text."""
    try:
        print(text, end=end, file=file)
    except UnicodeEncodeError:
        if ascii_text is not None:
            text = ascii_text()
        else:
            encoding = getattr(file, "encoding", None) or "ascii"
            text = text.encode(encoding, "backslashreplace").decode(encoding)
        print(text, end=end, file=file)


def _attr(value: Any) -> str:
    collapsed = " ".join(strip_hidden(str(value)).split())
    return html.escape(collapsed, quote=True)


def open_tag(nonce: str, *, source: str, tool: str, **attrs: Any) -> str:
    """Build the opening tag. Attribute values are escaped."""
    parts = [f'source="{_attr(source)}"', f'tool="{_attr(tool)}"']
    for key, value in attrs.items():
        if value is None:
            continue
        parts.append(f'{key.replace("_", "-")}="{_attr(value)}"')
    return f"<{TAG}-{nonce} " + " ".join(parts) + ">"


def close_tag(nonce: str) -> str:
    return f"</{TAG}-{nonce}>"


class Block:
    """Context manager that prints one untrusted-content block.

    The closing tag is printed even when the body raises, so a failure never
    leaves a block open.
    """

    def __init__(self, *, source: str, tool: str, file: IO[str] | None = None, **attrs: Any):
        self.nonce = new_nonce()
        self._source = source
        self._tool = tool
        self._attrs = attrs
        self._file = file

    @property
    def file(self) -> IO[str]:
        return self._file if self._file is not None else sys.stdout

    def __enter__(self) -> "Block":
        print(
            open_tag(self.nonce, source=self._source, tool=self._tool, **self._attrs),
            file=self.file,
        )
        return self

    def write(self, text: str) -> None:
        """Print raw text inside the block."""
        text = neutralize(text)
        _print(text, self.file, end="" if text.endswith("\n") else "\n")

    def write_json(self, obj: Any, *, indent: int | None = None, sort_keys: bool = False) -> None:
        """Print a JSON document inside the block."""
        _print(
            dumps(obj, indent=indent, sort_keys=sort_keys),
            self.file,
            ascii_text=lambda: dumps(obj, indent=indent, sort_keys=sort_keys, ensure_ascii=True),
        )

    def __exit__(self, *exc_info: object) -> None:
        print(close_tag(self.nonce), file=self.file)


def emit_text(
    text: str, *, source: str, tool: str, file: IO[str] | None = None, **attrs: Any
) -> None:
    """Print raw text as one block."""
    with Block(source=source, tool=tool, file=file, **attrs) as block:
        block.write(text)


def emit_json(
    obj: Any,
    *,
    source: str,
    tool: str,
    indent: int | None = None,
    sort_keys: bool = False,
    file: IO[str] | None = None,
    **attrs: Any,
) -> None:
    """Print a JSON document as one block."""
    with Block(source=source, tool=tool, file=file, **attrs) as block:
        block.write_json(obj, indent=indent, sort_keys=sort_keys)
deprecation-and-migrationaddyosmani/agent-skillsManages deprecation and migration. Use when removing old systems, APIs, or features. Use when migrating users from one implementation to another. Use when migrating a database schema in production, such as renaming or dropping a column without downtime (expand/contract). Use when deciding whether to maintain or sunset existing code.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
performance-optimizationaddyosmani/agent-skillsOptimizes application performance across frontend, backend, queries, and databases. Use when performance requirements exist, when you suspect performance regressions, when Core Web Vitals or load times need improvement, when N+1 query patterns need fixing, or when profiling reveals bottlenecks.Stars: 119kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall
agent-cost-reportthedotmack/claude-memBelievable agent cost report for any period, default the last 7 full days PT, not counting today. Measured tokens from Claude Code transcripts priced at OpenRouter list prices (ESTIMATED), measured provider spend when a sanctioned source exists, note-taker cost separate, Timing-style HTML/PDF plus report.json, line-items.csv, evidence.json.Stars: 118kUpdated Claude CodeCodexVerifiedInstall