target-leakage-detection

target-leakage-detection is a skill for Claude Code from StamKavid/last-ds-mile. It costs 93 tokens per session (1,132 once invoked), scanned A, original, MIT.

A check for target leakage: information in a feature that comes from the answer, the future, or the test data. A feature is an input column used by a model.

In plain words
What is it for?
Use it when a first score seems implausibly high, one feature dominates the model, or features use aggregates, rolling windows, or joins that may include future records.
Why use it?
Leakage can make a model's test score look much better than its real-world performance.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the last-ds-mile plugin — 29 skills, 17 commands, 3 agents, 4 hooks shipped together

Good fit Use it when a first score seems implausibly high, one feature dominates the model, or features use aggregates, rolling windows, or joins that may include future records.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/stamkavid/last-ds-mile/target-leakage-detection
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add StamKavid/last-ds-mile --skill target-leakage-detection
Clone the repo
git clone --depth 1 https://github.com/StamKavid/last-ds-mile

Made for: Claude Code.

Or install last-ds-mile, the plugin that ships this one along with the rest of its 29 skills, 17 commands, 3 agents, 4 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for target-leakage-detection

README.md
[![agentmods](https://agentmods.dev/badge/skills/stamkavid/last-ds-mile/target-leakage-detection/github.svg)](https://agentmods.dev/skills/stamkavid/last-ds-mile/target-leakage-detection)
Your own site
<a href="https://agentmods.dev/skills/stamkavid/last-ds-mile/target-leakage-detection"><img src="https://agentmods.dev/badge/skills/stamkavid/last-ds-mile/target-leakage-detection/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for target-leakage-detection

Your own site · 80×15
<a href="https://agentmods.dev/skills/stamkavid/last-ds-mile/target-leakage-detection"><img src="https://agentmods.dev/badge/skills/stamkavid/last-ds-mile/target-leakage-detection.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 93 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,132 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00093 $0.01132
Opus 5 $0.00046 $0.00566
Sonnet 5 $0.00019 $0.00226
Haiku 4.5 $0.00009 $0.00113

Measured 12d ago against content hash 63d1842cf654, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

target-leakage-detection scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 12d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/target-leakage-detection/SKILL.md · 73 lines

How it starts

The opening of the file, as written. The whole thing — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.

target-leakage-detection

Overview

Leakage is the single most common way a DS project's offline metric lies about real world performance. This skill gives concrete detection techniques for the four ways it usually happens, rather than a vague "watch out for leakage" reminder.

When to Use

  • A metric looks implausibly good on the first real attempt (see ds-method's Red Flags).
  • Building a feature from an aggregate, a rolling window, or a join that could include future rows.
  • A single feature dominates importance rankings in /ds-explain or an ad hoc check.
  • NOT for: choosing a validation split (that's ds-validate) — this skill is about what's inside a feature, not how data is split.

Core Process

  1. For every candidate feature, ask the "would this value have been known at prediction time" question from /ds-prep — but here go one level deeper: check the actual computation, not just the column name.
  2. Run the four checks in the table below against every feature that wasn't hand- verified already. For a full pipeline sweep (many features, or a pre-ship check rather than one suspicious feature), delegate to the leakage-auditor agent instead of running the sweep inline — it does the same four checks adversarially and keeps the intermediate trace-through out of this stage's context. Its findings come tagged Confirmed / Likely / Worth checking — remove or fix the feature for Confirmed and Likely findings before proceeding; record a Worth-checking finding in the stage doc as a flagged, unresolved item rather than blocking on it.
  3. If a check fires, don't quietly drop the feature — trace it to its source (a join? an aggregate? a leaked label?) and record what was fixed.

Techniques/Patterns — four leakage types and how to catch each

Leakage type How it slips in Detection technique Fix
Post-outcome feature A column is only populated after the target is known (e.g. "cancellation_reason" when predicting churn, "days_to_close" when predicting whether a deal closes) Ask each feature's owner/source system when it's populated relative to the target event, not just what it's named Drop it, or replace with a version computed strictly before the target event
Full-dataset aggregate ("time-traveling feature") A rolling mean/sum/rank computed once over the whole dataset instead of per-row as-of-date Recompute the same aggregate using only rows with an earlier timestamp than the row being predicted, and diff against the original — if they differ, the original leaked Recompute as an as-of, expanding/rolling-window aggregate
Train/test contamination The same real-world entity (customer, house, patient) appears in both train and validation, or a transform (scaler, encoder, target encoding) was fit on the full dataset before splitting Check for duplicate/near-duplicate rows or shared keys across the split; confirm every fit-requiring transform lives inside a pipeline fit per-fold Group-aware splitting (see ds-validate); move every stateful transform inside the CV loop
Direct target derivation A feature is an arithmetic function of the target itself (e.g. "profit_margin" when predicting "profit", where margin = profit/revenue) Compute the correlation AND check the literal formula/join that produced the feature, not just the correlation number Drop the feature; if the underlying real-world quantity is genuinely available at prediction time, recompute it without touching the target

Read the full file on GitHub · 73 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 12d ago First seen · 73 lines · 93 tokens per session scan A 63d1842cf654

Subscribe to this mod's changes

target-leakage-detection is a skill published in the GitHub repository StamKavid/last-ds-mile (3 stars, last pushed 1mo ago), licensed MIT. It adds 93 tokens to every session and 1,132 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

developing-with-streamlit

Use for ALL Streamlit tasks: creating, editing, debugging, beautifying, styling, theming, optimizing, or deploying Streamlit apps. Also custom components, st.components.v2, HTML/JS/CSS work. Discovers and loads version-matched reference docs from the user's installed Streamlit (>=1.57). Triggers: streamlit, st.…

streamlit/streamlit · 128 tokens

marimo-pair

Work inside the user's live marimo notebook from the code editor: run Python in the same kernel the user does, inspect live notebook state, and commit durable notebook changes through code mode. Use whenever you create, analyze, or improve the user's marimo notebook.

marimo-team/marimo · 57 tokens

wax

Swift framework guidance for Wax on-device memory/RAG. Use when writing Swift code with the public Memory facade, experimental PhotoMemory / VideoMemory, BuiltInMultimodalEmbeddings, embedding providers, retrieval modes, or hybrid search. For agent operators using the Wax MCP server tools, use the separate wax-mcp…

christopherkarani/Wax · 68 tokens

wax-memory-maintenance

Maintain the Wax memory store used by the Hermes wax-memory provider.

christopherkarani/Wax · 18 tokens

ml-expert

Expert-level machine learning, deep learning, model training, and MLOps. Use when the user mentions machine learning, deep learning, neural networks, MLOps, or data science, or when the task involves Machine Learning Fundamentals, Data Preparation, or Model Training.

personamanagmentlayer/pcl · 58 tokens

fast-dash

Build a Fast Dash web app from a Python function. Use when the user wants to turn a function into an interactive app, add a UI to an existing function, or build a dashboard / form / wizard. Fast Dash infers UI components from type hints, so a well-typed function becomes an app with one decorator.

dkedar7/fast_dash · 69 tokens