/nhl-data:nhl-xg-modelfrom PuckAPI: hockey skills
Trains XGBoost or LightGBM shot-quality (xG) models on NHL play-by-play data. Handles feature engineering, time-ordered train/test splits, log loss, and calibration. Not for reading existing xG numbers.
Ships in PuckAPI: hockey skills. 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.
Data: the PuckAPI MCP server (
nhl-puckapi-tools) has shot-level data.
get_shot_map(10 credits) returns shot locations to plot or model.get_plays(10 credits) returns events for a game, player or season, used for rebound and rush context.get_shiftsandget_situation_time(10 credits) cover who was on the ice and strength-state time.get_team_statsandget_goalie_stats(5 credits each) validate your aggregates against the server's own team and goalie numbers.For the user's own shot data CSV/JSON, work with the file directly.
You are an expert in hockey expected goals modeling. Your goal is to build a shot-level xG model that estimates the probability any given shot results in a goal, controlling for shot quality rather than shot volume.
nhl-xg-report or nhl-advanced-statsmodel-buildingnhl-goalie-gsax-reportfeature-engineering| Command | What It Does | Credits |
|---|---|---|
get_shot_map | Shot locations for a game, player or team | 10 |
get_plays | Event-level play-by-play (shots, goals, misses, blocks, strength state, time) | 10 |
get_games | Game list to get game IDs | 5 |
get_team_stats | Team-level shot and goal summaries to validate your xGF% | 5 |
get_goalie_stats | Goalie totals to validate xGA | 5 |
Inspect the fields a call returns before assuming a column exists, and map them to the names below. Shot events typically carry an event type (shot, goal, miss, block), x/y coordinates (feet, center ice = 0,0), shot type, strength state, period and game time, and shooter and goalie IDs.
If user provides CSV/JSON:
x_coord, y_coord, shot_type, strength_state, period, game_seconds, event_type (SHOT/GOAL/MISS/BLOCK), shooter_id, goalie_id| Not Available | Use Instead |
|---|---|
get_xg_model | Build the model yourself from get_shot_map and get_plays |
| Bulk shot export in one call | Pull per game or per player and aggregate; agree the scope with the user first, since each call costs credits |
| Screen or traffic data, shot velocity | Not available; document as a known model limitation |
Before building, establish:
Pull shot events with get_shot_map and get_plays and filter to shot events:
SHOT (on goal, saved)GOALMISS (missed net)BLOCK (blocked before reaching goalie)Set target: is_goal = 1 if event_type is GOAL, else 0.
Important: Include blocked shots in the model but treat them carefully: some public models exclude blocks and others include them. Document the choice.
See xg-features.md for the complete feature table with formulas. Core features:
Location:
shot_distance: Euclidean distance from shot coordinates to net centershot_angle: Absolute angle from net-center axisShot type: One-hot encode: wrist, slap, snap, backhand, tip, deflection, wrap-around. Backhand and tip/deflection have higher xG per distance than wrist shots.
Strength state: One-hot encode: 5v5, PP, SH, EN. Train separate models per strength state (Step 4).
Time context:
seconds_since_last_event: time elapsed since the prior eventdistance_from_last_event: Euclidean distance between shot coordinates and prior event coordinatesThese are the features that separate public xG models from naive distance-only models.
Rebound detection:
df['is_rebound'] = (
(df['seconds_since_last_event'] < 3) &
(df['last_event_type'].isin(['SHOT', 'GOAL', 'MISS']))
).astype(int)
Rush detection (zone entry proxy):
df['is_rush'] = (
(df['seconds_since_last_event'] < 4) &
(df['distance_from_last_event'] > 30) # feet, large spatial jump = transition
).astype(int)
Shot angle change rate (rebound angle speed):
df['rebound_angle_speed'] = df['is_rebound'] * df['shot_angle_change'] / df['seconds_since_last_event'].clip(lower=0.1)
Train four separate XGBoost (or LightGBM) classifiers:
from xgboost import XGBClassifier
models = {}
for state in ['5v5', 'PP', 'SH', 'EN']:
subset = df[df['strength_state'] == state]
X = subset[FEATURE_COLS]
y = subset['is_goal']
models[state] = XGBClassifier(
n_estimators=300,
max_depth=4,
learning_rate=0.05,
subsample=0.8,
colsample_bytree=0.8,
eval_metric='logloss',
random_state=42
)
models[state].fit(X, y)
Shot-level evaluation:
Team-level validation:
# Sum shot-level xG per team per game: compare to actual goals
df['xg'] = df.apply(lambda r: models[r['strength_state']].predict_proba([r[FEATURE_COLS]])[0][1], axis=1)
team_xg = df.groupby(['game_id', 'team'])['xg'].sum()
Compare your xGF/xGA per team against the expected-goals figures the server returns from get_team_stats (5 credits) and get_standings (2 credits). Report the correlation and the number of teams; a high correlation (for example above 0.85) means your aggregates track the server's. Differences are expected because the models differ.
# xGF% (5v5 only: standard)
xg_5v5 = df[df['strength_state'] == '5v5'].groupby(['game_id', 'team'])['xg'].sum()
team_xgf_pct = xg_5v5 / (xg_5v5.groupby('game_id').transform('sum'))
xGF% is the primary team-level output. Values above 50% indicate a team that generates better shot quality than it allows at even strength.
| Operation | Credits | Notes |
|---|---|---|
get_shot_map per call | 10 | Scope by game, player or team |
get_plays per call | 10 | Event context for rebound and rush features |
get_team_stats (validation) | 5 | Compare your xGF% to the server's team stats |
get_goalie_stats (validation) | 5 | Compare your xGA to goalie stats |
get_games (get game IDs) | 5 | Pull the game list first |
A full season is about 1,312 games, so a full-season pull is expensive. Start with one team or a few months and confirm scope with the user before bulk pulls.
get_shot_map, team totals checked against get_team_stats").20252026 = 2025-26) and the held-out seasons used for evaluation.| Rationalization | Why It's Wrong | Do This Instead |
|---|---|---|
| "One model for all strength states is simpler" | PP and SH have fundamentally different shot distributions; a combined model learns the average and is wrong for both | Train separate models per strength state |
| "Distance alone is good enough" | Distance-only models miss rebound and rush context, which account for ~15% of xG variance | Include rebound flag and rush flag at minimum |
| "k-fold cross-validation is fine for shot data" | Shots within a game are correlated; k-fold leaks game-level context across folds | Group k-fold by game_id or season |
| "Blocked shots should be included the same as saved shots" | Blocked shots are a different event with different outcome distribution; mixing them without a flag distorts calibration | Either exclude blocks or include a is_blocked indicator |
| "I'll validate against total goals only" | Total goals validation misses calibration problems at the shot level | Validate Brier score at shot level AND team-level xGF% correlation |
| "Screen/traffic data isn't available so skip it" | Acknowledging the gap is correct: just document it as a known model limitation | Note it as a known gap; tracking data may expose it in future |
"I'll use get_game_detail for shot data" | It returns game-level data, not shot events | Use get_shot_map and get_plays |
The xG model produces:
game_id, event_id, shooter_id, team, strength_state, xg (float 0-1), and all computed features.xGF and xGA per team per game per strength state.nhl-xg-report or feature-engineering..pkl or .json), feature names, and Brier score per strength state.| What You Found | Next Action | Skill |
|---|---|---|
| xG model built, want to use it as a prediction model feature | Add xGF% as a lag feature | feature-engineering |
| Team xGF% computed, want to analyze team quality | Use xGF% alongside Corsi and PDO | nhl-xg-report |
| Goalie xGA computed, want to evaluate goalie quality | xGA is the input to GSAA calculation | nhl-goalie-gsax-report |
| Model is built, want to compare with the market | How the xG-implied win probability differs from the market probability | market-vs-model |
| Want to validate the model with proper temporal splits | Hold out full seasons for out-of-sample testing | backtesting |
| Calibration curve is off | Recalibrate probabilities with isotonic regression or Platt scaling | probability-calibration |
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
expected-goals, hockey-analytics, shot-quality, xgboost, lightgbm, puckapi
Other plugins' skills for the same job
npx claudepluginhub sports-data-hq/sportsdatahq-skills --plugin nhl-data15 skills in this plugin
/nhl-advanced-statsUse when the user asks what a hockey advanced stat means or how to read it, in fan or analyst wording: 'what is PDO', 'explain Corsi', 'what does high danger mean', 'what is Fenwick', 'how do I read RAPM', 'what does zone entry data tell you', 'what is the difference between xG and Corsi', 'what is a good Corsi percentage', 'how stable is shooting percentage'. Use this whenever a metric name, its definition or how to interpret a number comes up. Load it for short fragments and follow-ups too, instead of answering from memory or going straight to the raw tools. Explains the metric, its limits and what it tells you, and pulls real numbers with sample sizes when asked. Not for whether a team is lucky or deserved a result, or got outshot but won (see nhl-xg-report), building an xG model (see nhl-xg-model), odds terms (see market-vs-model) or value decomposition (see nhl-war-gar)./nhl-daily-slateUse when the user wants every NHL game on a given day at once, in fan wording: 'what's on tonight', 'tonight's slate', 'anything interesting on the board', 'every game today', 'all the matchups tomorrow with win chances', 'sort today's games by the gap to the market', 'morning rundown'. Use this whenever the question covers a day's games rather than one game, even with no team or sport named ('the board', 'the full card' mean the NHL here). Load this skill first, before calling any data tool; it says which tools to call. Pulls the slate, each game's market (no-margin) probability and our model probability, and ranks games by the model vs market gap. Odds are information only: no stakes, picks or wagering advice. Not for one game in depth (use nhl-game-preview), a past score or plain schedule lookup (call get_games or get_schedule), one game's odds (use nhl-odds-explorer) or historical testing (use backtesting)./nhl-dfs-lineupUse when someone has an NHL daily fantasy slate: 'build my hockey DraftKings lineup', 'salary file for tonight, make a lineup', 'line stack with a power play', 'cheap goalie options', 'which line to stack', 'value defensemen', 'project the slate', 'FanDuel hockey lineup'. Builds lineups under the cap from the user's salary file using projected goals, assists, shots, blocks and saves (the model's tonight projections on paid plans, otherwise prop medians). Also for bare follow-ups with no names: load this skill first, then ask for what is missing, rather than answering from memory. Load this skill first, before calling any data tool, for short fragments and follow-ups too; it says which tools to call. Not for entry fees, contest choice or how much to play, which it will not advise; not for weekly streaming (see nhl-fantasy-streamers), game previews or prop research (see nhl-player-props-research). Needs the salary file pasted./nhl-fantasy-streamersUse when a fantasy hockey manager is planning the week or hunting pickups: 'goalie to stream', 'who has four games this week', 'back-to-back goalies', 'power play unit to add', 'defenseman with shots and blocks', 'rest of week waiver adds', 'is his ice time up', 'Monday-Thursday schedule', 'hot goalie worth a stash', 'who gets first-unit power play now'. Ranks goalies and skaters by games in the window, goalie workload and recent form, ice time and power-play production, and opponent offense. Also for bare follow-ups with no names: load this skill first, then ask for what is missing, rather than answering from memory. Not for a single game preview (see nhl-game-preview), a goalie's season quality (see nhl-goalie-gsax-report), DFS lineups (see nhl-dfs-lineup) or prop prices (see nhl-player-props-research)./nhl-game-previewUse when the user wants to know how one NHL game shapes up, in fan or analyst wording: 'Sabres vs Leafs tonight', 'who wins Oilers Stars', 'breakdown of the Rangers game', 'who is in goal', 'how do these two teams compare', 'what should I know about tonight's game', 'preview the Panthers game', 'is the favorite live'. Use this whenever two NHL teams are named together for one game. Load it for short fragments and follow-ups too, even with no team given, instead of answering from memory or going straight to the raw tools. Builds one report: records and rest, goalie matchup, key stats, odds snapshot with no-margin probability, our probability against the market's and head to head. Odds are information only. Not for the whole slate (see nhl-daily-slate), odds only (see nhl-odds-explorer), past results (call get_games) or modeling./nhl-goalie-gsax-reportUse when the user asks whether an NHL goalie is good, hot, overrated, tired or just the team in front of him, in fan or analyst wording: 'is Hellebuyck actually elite', 'is his .925 sustainable', 'goalie stealing games?', 'is he overrated', 'who is the best by GSAx', 'is he running hot', 'is he tired, does he play back-to-backs', 'is this a tandem', 'high-danger saves for Vasilevskiy', 'goalie rankings by shot quality'. Use this whenever goalie performance, form or workload is judged against shot quality. Load it for short fragments and follow-ups too, even with no name given, instead of answering from memory. Reads GSAX, expected goals against, high-danger save percentage, rolling form, rest days and start share from the goalie leaderboard, with games counted. Not for who starts tonight (not in the data), skaters (see nhl-player-scouting), a game preview (see nhl-game-preview), goalie saves props (see nhl-player-props-research) or building an xG model (see nhl-xg-model).