/sports-analytics-core:feature-engineeringfrom SportsDataHQ: analytics core
Builds model-ready sports features (rolling averages, rest days, strength of schedule, Elo) from raw game logs while enforcing zero temporal leakage via shift(1). Load before any data tool.
Ships in SportsDataHQ: analytics core. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert in sports feature engineering. The goal is to build model-ready features from raw data while guaranteeing zero temporal leakage. This is where most first models go wrong.
Call your sport's SportsDataHQ MCP tools. Hockey: get_games, get_team_stats, get_goalie_stats, get_head_to_head. Football: get_games, get_team_stats, get_plays. Basketball: list_games, get_team_stats, get_shot_chart. Baseball: get_games, get_team_stats, get_pitches. Soccer: list_games, get_team_stats, get_events. Tennis: get_matches, get_surface_splits. Golf: get_leaderboard, get_player_results. UFC: get_fighter_fights. Cricket: get_deliveries. Read your server's tool list for exact names.
Derived features have no tool of their own (rolling stats, rest days, strength of schedule, recent starter form): compute them from the game log.
Own data (CSV or JSON): verify game_date, home and away identifiers, result columns and stat columns; ISO 8601 dates; flag missing rows, do not silently drop.
get_games, get_standings or get_team_stats (hockey) or your sport's stats toolsnhl-advanced-statsnhl-xg-modelmodel-building and backtestingSort all data ascending by game_date. This is non-negotiable. Every calculation that follows depends on correct order. Verify sort before proceeding.
.shift(1) Before ANY Rolling CalculationThe single most important rule in this skill.
For every stat column that will enter a rolling window:
df['stat_shifted'] = df.groupby('team_id')['stat'].shift(1)
This ensures game N uses only games 1 through N-1. Without .shift(1), game N includes its own outcome in its own feature, which is leakage.
Even season-level aggregate stats must be lagged. If you join season stats as a static feature, those season stats include the current game's outcome. Lag them.
Compute rolling windows at multiple sizes. The "right" window is an empirical question, not a convention.
Required windows to test: 5, 10, 20, 40, 82 games
for window in [5, 10, 20, 40, 82]:
df[f'goals_for_roll{window}'] = (
df.groupby('team_id')['goals_for_shifted']
.transform(lambda x: x.rolling(window, min_periods=window//2).mean())
)
Run sensitivity analysis: does the model's walk-forward accuracy change meaningfully when you swap window sizes? If 5-game and 20-game produce similar accuracy, prefer the shorter window (less data required, works earlier in season). Document which window was chosen and why.
Compute all features separately for home context and away context. A team's road performance is a different signal than home performance.
Rest-day feature:
df['rest_days'] = df.groupby('team_id')['game_date'].diff().dt.days - 1
df['back_to_back'] = (df['rest_days'] == 0).astype(int)
df['rest_bucket'] = pd.cut(df['rest_days'], bins=[-1, 0, 1, 2, 99],
labels=['b2b', '1day', '2day', '3plus'])
Back-to-backs carry a measurable performance cost in hockey and basketball. Measure the size in your own data (with the sample size) and include the feature wherever the schedule allows it.
Simple opponent win% is not SOS. It double-counts easy schedules. Use iterative SOS:
Do NOT use simple opponent win% as SOS. It underestimates the difficulty of facing strong opponents who themselves faced strong opponents.
Pull opponent records via get_standings. Recompute per-fold in walk-forward validation. Never use full-season SOS as a feature (that leaks final standings into early-season predictions).
In hockey the starting goalie is a large source of game-to-game variance. The same idea applies to a starting pitcher (baseball), goalkeeper (soccer) or quarterback (football). Hockey features:
get_goalie_stats# GSAA formula: (league_avg_sv_pct - goalie_sv_pct) * shots_faced_against
# Negative GSAA = goalie is below average (worse than expected)
Reference elo-engineering skill for Elo calculation details. As a feature input:
Raw goals-for is partially a function of opponent quality. Subtract opponent average:
df['adj_goals_for'] = df['goals_for_roll10'] - df['opp_goals_against_roll10']
This isolates the team's contribution from the matchup context. Using home-minus-away differences for every feature encodes opponent context directly.
For matchup prediction, compute the difference between home team feature and away team feature:
df['goal_diff_feature'] = df['home_goals_for_roll10'] - df['away_goals_for_roll10']
All features become single signed values. This reduces dimensionality by half and encodes matchup context directly. Confirm on your own walk-forward folds that the differenced form does at least as well.
Before handing features to model-building, audit every feature:
.shift(1) applied before any rolling calculation? -> If no, leakagexg_point_in_time (get_events, get_shot_map) and basketball has expected_points_point_in_time (get_plays, get_shot_chart), each fitted only on earlier seasons: use them instead of xg and expected_points.See feature-catalog.md for the full recommended feature list with leakage risk ratings.
| Rationalization | Why It's Wrong | Do This Instead |
|---|---|---|
| "k-fold is fine for feature selection" | k-fold on time series leaks future folds into training, inflating feature importance scores by 5-15% | Use walk-forward fold structure for all feature selection |
| "40-game window is standard" | 40 is arbitrary; the right window depends on your data | Test 5/10/20/40/82 windows, report sensitivity, pick empirically |
| "Elo is redundant with rolling win%" | Elo updates after every game and weights recent games more; win% is equally weighted across the season | Include Elo; it captures momentum that win% misses |
| "Don't need .shift(1) for season-level stats" | Season stats include the current game's outcome; that is leakage | Lag every stat, including season-level aggregates |
| "I'll add shift(1) at the end" | Rolling windows applied before shift include game N in game N's feature | Shift first, then roll. Order is not flexible. |
| "Opponent win% is a fine SOS proxy" | Simple opponent win% double-counts easy schedules | Use iterative SOS: run convergence loop on opponent ratings |
| "More features can't hurt" | More features increase overfitting risk in small sports datasets | Use feature importance from walk-forward folds to prune aggressively |
| "I'll just use this season's stats for the whole season" | Future games in the season leak into early-season features | Rebuild SOS and aggregate stats per fold in walk-forward |
Feature engineering produces:
X): rows = games, columns = home-minus-away feature differences. All numeric. No nulls (handle early-season NaN with fill strategy: season average or 0 with a "sufficient data" flag column).y): 1 = home win, 0 = away win. For totals modeling: total goals.Hand this output directly to backtesting or model-building.
| What You Found | Next Action | Skill |
|---|---|---|
| Features built, need to evaluate a model | Validate with walk-forward splits | backtesting |
| Features built, ready to train | Train with walk-forward methodology baked in | model-building |
| Suspect a feature has leakage | Audit shift/roll order, check leakage risk in catalog | feature-engineering (re-run Step 9) |
| Want to add Elo as a feature | Build Elo ratings first | elo-engineering |
| Want expected goals features | xG requires shot-level data and a separate process | nhl-xg-model |
| Features look good, want to test on past seasons | Score the model against the market's probabilities on past seasons | backtesting |
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
10 skills in this plugin
/backtestingUse when the user asks whether a sports model or system would have worked in the past, for any sport, in plain wording: 'does my model actually work', 'test it on the last three seasons', 'did it beat the closing line', 'is it still as accurate as it used to be', 'what is the confidence interval on my hit rate', 'how would this have done in 2023', 'run it against past odds', 'is this edge real or luck', 'how should I split seasons to test it'. Use this whenever historical performance, fold design, sample size or an interval is the question. Load this skill first, before calling any data tool; it says which tools to call. Walk-forward only; refuses k-fold and in-sample testing; reports sample size, an interval and a per-season breakdown. Not for logging live predictions as games finish (see prediction-tracker), tonight's gap to the market (see market-vs-model) or training (see model-building)./data-pipelineUse when the user wants anything sports-related to run on its own or keeps getting numbers that do not line up: 'run my model every morning', 'schedule a script to grab results daily', 'GitHub Action to refresh my ratings', 'automate the whole thing', 'email me when the model gets worse', 'where do I store predictions', 'I joined two tables and lost rows', 'duplicate rows in my data', 'does this date belong to last season'. Load this skill first, before calling any data tool; it says which tools to call. Covers cron jobs and GitHub Actions, storage, model versioning, retraining and drift alerts, plus the data checks other skills point to (ids, season convention per sport, one league, duplicates, sample-size floors). Not for one-off lookups (call your sport's tools directly), building the model (use model-building), historical testing (use backtesting) or grading logged predictions (use prediction-tracker)./elo-engineeringUse when the user asks to build Elo ratings, rate teams or players, tune K-factor or home advantage, carry ratings across seasons, add margin-of-victory, or mentions Fading, Form or Component Elo. Works for team sports and for tennis, golf, UFC and cricket player or fighter ratings. Load this skill first, before calling any data tool, for short fragments and follow-ups too; it says which tools to call. Not for general feature construction (use feature-engineering), not for a full model (use model-building), not for plain team stats (call get_standings or get_team_stats for hockey, or your sport's stats tools), not for season simulation (use nhl-playoff-simulation)./market-vs-modelUse when the user puts a model's or their own number next to the betting market, or asks what a price means as a probability, for any sport, in plain wording: 'our number vs the market tonight', 'is the market higher on them than my numbers', 'fair price vs our price', 'do my ratings beat the close', 'are we off the market on favorites', 'what does +250 mean as a chance', 'take the juice out of -300/+250', 'how big a gap is real'. Use this whenever a model probability meets a market probability, or odds need converting or the margin removed. Load this skill first, before calling any data tool; it says which tools to call. Covers odds conversion, margin removal, the model vs no-margin gap and the sample needed before a gap means anything. Odds are information only: no stakes, no picks. Not for today's prices alone (see your sport's odds skill), testing on past seasons (see backtesting) or logging live predictions (see prediction-tracker)./model-buildingUse when the user wants to build or choose a model that predicts sports outcomes, for any sport, in plain wording: 'predict who wins', 'which algorithm should I use', 'logistic regression or XGBoost', 'tune my model', 'train a classifier on fights', 'which features matter', 'can I blend two models', 'random forest for the NHL', 'my model is stuck at 55 percent'. Use this whenever a game or match prediction model is being built, picked or improved. Load this skill first, before calling any data tool, for short fragments and follow-ups too; it says which tools to call. Always walk-forward; refuses k-fold. Not for building input features (see feature-engineering), checking probabilities (see probability-calibration), hockey shot models (see nhl-xg-model) or market comparison (see market-vs-model)./prediction-trackerUse when the user keeps, or wants to keep, a running record of a model's forecasts and score it as games finish, for any sport, in plain wording: 'save tonight's win chances', 'log my picks' probabilities', 'how has the model done since I started tracking', 'grade yesterday's forecasts', 'Brier on my last 150 predictions', 'is my model getting worse lately', 'running log of my numbers vs the closing price', 'accurate this month'. Use this whenever predictions were (or will be) written down before games and graded after, even for a short window. Load it for short fragments and follow-ups too, instead of answering from memory or going straight to the raw tools. Logs probability, outcome, Brier score, log loss, calibration and closing-line comparison with sample sizes and intervals. Not for placing or sizing wagers (never done), testing on past seasons the model never logged (see backtesting), fixing calibration (see probability-calibration) or retraining (see model-building).npx claudepluginhub sports-data-hq/fighterapi-mcp --plugin sports-analytics-core9 plugins ship this exact skill · first indexed Dec 3, 2026
Showing 6 of 9 plugins, one per repository first