FPL Copilot
Fantasy Premier League data sync, analysis, and squad management.
- FPL data: SQLite database at
~/.fplcopilot/fplcopilot.db
- User squads: Markdown files in
~/.fplcopilot/squads/
When to Use
Activate this skill when the user mentions:
- FPL, Fantasy Premier League, fantasy football (UK context)
- Player stats, form, price, points, xG, xA, ICT, ownership
- Transfer advice, who to buy/sell, budget options
- Captain pick, vice-captain, chip timing
- Fixture difficulty, FDR, schedule, easy/hard fixtures
- Gameweek deadline, scores, standings, averages
- Squad management, team composition, formation
- Team analysis: momentum, xG differential, leaky defences, hot attacks
- Rotation pairs, differential picks, value picks
Quick Start
1. Check Data Freshness
sqlite3 ~/.fplcopilot/fplcopilot.db "SELECT * FROM sync_metadata;"
If the database doesn't exist or data is stale, sync first.
2. Sync Data
SYNC="${CLAUDE_PLUGIN_ROOT}/skills/fpl-copilot/references/sync.sh"
# First time or daily refresh
$SYNC bootstrap # Teams, gameweeks, ~600 players (~5s)
$SYNC fixtures # All 380 fixtures (~2s)
# On demand — single player's match history
$SYNC player 328 # e.g., Salah's detailed GW-by-GW stats
# Batch — all players' histories (slow, ~60s, rate-limited)
$SYNC player-stats
# Everything at once
$SYNC all
# Bypass freshness checks
$SYNC bootstrap --force
3. Query and Analyze
# All queries go through sqlite3
sqlite3 ~/.fplcopilot/fplcopilot.db "SELECT web_name, position, form, total_points, now_cost FROM players ORDER BY form DESC LIMIT 10;"
Read references/analysis.md for formulas and example SQL queries.
Read references/squad.md for squad management, persistence format, and multi-squad support.
Output Format: HTML vs Markdown
Many FPL outputs are inherently spatial or color-coded — formation, FDR matrix, transfer comparison. For those, generate a self-contained HTML report instead of a markdown table. For quick lookups and one-shot answers, stay in markdown.
When to output HTML
| Output type |
Format |
Template |
| Squad view (formation, bench, totals) |
HTML |
templates/squad-view.html |
| Fixture difficulty matrix (teams × next N GWs) |
HTML |
templates/fixture-matrix.html |
| Transfer comparison (out → in, deltas) |
HTML |
templates/transfer-comparison.html |
| Captain ranking with reasoning |
HTML |
templates/captain-ranking.html |
| Gameweek strategy report (squad + fixtures + recs) |
HTML |
templates/gameweek-report.html |
| Single-stat lookup ("Salah's form?") |
markdown |
— |
| Short reasoning ("Bench Haaland this week?") |
markdown |
— |
| Deadline, price changes, one-line answers |
markdown |
— |
| 3-row SQL result |
markdown |
— |
Heuristic: if the user will refer back to it, share it, or scan it visually → HTML. If they glance and move on → markdown.
Universal rules for HTML output
- Single self-contained
.html file. No build step. CSS in <style>, JS in <script>, SVG inlined.
- Vanilla HTML/CSS/JS only. No Tailwind, no shadcn, no external CDN, no web fonts.
- Mobile responsive. Include
<meta name="viewport" content="width=device-width, initial-scale=1">. Layout survives a phone viewport.
- Save to
~/.fplcopilot/reports/{YYYY-MM-DD}-{slug}.html. Create the directory with mkdir -p if missing.
- Tell the user the path after saving. On macOS, offer
open <path> to view in their default browser.
- Adapt the template, don't write from scratch. Read the matching file in
templates/, replace the placeholder data with real values from SQL, save the result.
Before generating any HTML report, read references/html-output.md for color tokens, typography, the team-color table, the sortable-table snippet, and the list of anti-patterns to avoid.
Reference Docs
Read these BEFORE answering questions in their domain:
| Doc |
When to Read |
references/api.md |
Understanding FPL API endpoints and data structure |
references/analysis.md |
Computing metrics (VAPM, projected points, FDR, momentum, etc.) |
references/squad.md |
Squad persistence, management, multi-squad, scoring rules |
references/schema.sql |
Understanding database tables and columns |
references/html-output.md |
Styling rules, color tokens, team colors, anti-patterns for HTML reports |
Squad Persistence
Squads are stored as markdown files in ~/.fplcopilot/squads/ — one file per squad. This enables multi-squad support (user's own team, friends' teams, draft plans).
Proactive persistence rules — the agent MUST follow these:
- On squad identification: When the user shares their squad (screenshot, text, or any format), immediately save it to
~/.fplcopilot/squads/. Ask for a name if unclear.
- On squad changes: When the user makes a transfer, changes captain, uses a chip, or modifies their squad in any way, update the squad file immediately after confirming the change.
- On conversation start: If the user asks about "my squad" or "my team", check
~/.fplcopilot/squads/ for existing squad files first. List available squads if multiple exist.
- On analysis: After generating a strategy report or analysis, update the squad file's Notes section with key takeaways.
- Multi-squad: Users may discuss multiple squads (their own, friends', draft plans). Each gets its own file. The user can specify which squad by name.
- File naming: Use kebab-case slugs derived from the squad name (e.g.,
my-fpl-team.md, daves-team.md, wildcard-draft.md).
Read references/squad.md for the full markdown format specification.
Agent Rules
- Always check freshness before answering data questions. If
sync_metadata shows stale data (bootstrap > 6h, fixtures on match day > 2h), run the sync script first.
- Always check for saved squads when the user asks about "my squad/team". Read
~/.fplcopilot/squads/ before asking the user to re-share.
- Never guess player IDs. Look up by name:
-- Try exact web_name first, then partial, then full name
SELECT * FROM players WHERE web_name = 'Salah' COLLATE NOCASE;
SELECT * FROM players WHERE web_name LIKE '%salah%' COLLATE NOCASE;
SELECT * FROM players WHERE (first_name || ' ' || last_name) LIKE '%salah%' COLLATE NOCASE;
- Price units:
now_cost is in 0.1m units. 130 = £13.0m. Always display as £X.Xm.
- Position codes: GKP, DEF, MID, FWD (mapped from API's 1, 2, 3, 4).
- Status codes:
a=available, d=doubtful, i=injured, s=suspended, u=unavailable.
- FDR scale: 1 (very easy) to 5 (very hard).
- Normalize by price when comparing players: value = points / (cost in millions).
- Fetch player detail on demand: Only run
sync.sh player <id> when the user asks about a specific player's match-by-match performance. Don't batch-fetch unless explicitly needed.
- Proactively persist squads: Always save/update squad files after any squad-related interaction. Never rely on conversation context alone.
- Generate HTML for spatial outputs: Any request that maps to a template in
templates/ — "plan gameweek" / "next gameweek team" → gameweek-report.html; "show/view my squad", formation, bench → squad-view.html; "compare transfer", out → in → transfer-comparison.html; "captain pick" with reasoning → captain-ranking.html; fixture run / FDR matrix → fixture-matrix.html — MUST produce the HTML file (saved to ~/.fplcopilot/reports/{YYYY-MM-DD}-{slug}.html) and report the path with an open <path> hint on macOS. Markdown is only for one-line / single-stat lookups, short reasoning, deadlines, price changes, or ≤3-row SQL results.
1---2name: fpl-copilot3description: Fantasy Premier League copilot: syncs live FPL data, analyzes players/teams/fixtures, manages your fantasy squad, and generates self-contained HTML reports for squads, fixtures, transfers, captain picks, and gameweek strategy. Use when the user asks about FPL, player stats, transfer advice, captain picks, fixture difficulty, gameweek strategy, or squad management.4---5
6# FPL Copilot
7
8Fantasy Premier League data sync, analysis, and squad management.
9
10- **FPL data**: SQLite database at `~/.fplcopilot/fplcopilot.db`
11- **User squads**: Markdown files in `~/.fplcopilot/squads/`
12
13## When to Use
14
15Activate this skill when the user mentions:
16- FPL, Fantasy Premier League, fantasy football (UK context)
17- Player stats, form, price, points, xG, xA, ICT, ownership
18- Transfer advice, who to buy/sell, budget options
19- Captain pick, vice-captain, chip timing
20- Fixture difficulty, FDR, schedule, easy/hard fixtures
21- Gameweek deadline, scores, standings, averages
22- Squad management, team composition, formation
23- Team analysis: momentum, xG differential, leaky defences, hot attacks
24- Rotation pairs, differential picks, value picks
25
26## Quick Start
27
28### 1. Check Data Freshness
29
30```bash
31sqlite3 ~/.fplcopilot/fplcopilot.db "SELECT * FROM sync_metadata;"
32```
33
34If the database doesn't exist or data is stale, sync first.
35
36### 2. Sync Data
37
38```bash
39SYNC="${CLAUDE_PLUGIN_ROOT}/skills/fpl-copilot/references/sync.sh"
40
41# First time or daily refresh
42$SYNC bootstrap # Teams, gameweeks, ~600 players (~5s)
43$SYNC fixtures # All 380 fixtures (~2s)
44
45# On demand — single player's match history
46$SYNC player 328 # e.g., Salah's detailed GW-by-GW stats
47
48# Batch — all players' histories (slow, ~60s, rate-limited)
49$SYNC player-stats
50
51# Everything at once
52$SYNC all
53
54# Bypass freshness checks
55$SYNC bootstrap --force
56```
57
58### 3. Query and Analyze
59
60```bash
61# All queries go through sqlite3
62sqlite3 ~/.fplcopilot/fplcopilot.db "SELECT web_name, position, form, total_points, now_cost FROM players ORDER BY form DESC LIMIT 10;"
63```
64
65Read `references/analysis.md` for formulas and example SQL queries.
66Read `references/squad.md` for squad management, persistence format, and multi-squad support.
67
68## Output Format: HTML vs Markdown
69
70Many FPL outputs are inherently spatial or color-coded — formation, FDR matrix, transfer comparison. For those, generate a self-contained **HTML report** instead of a markdown table. For quick lookups and one-shot answers, stay in markdown.
71
72### When to output HTML
73
74| Output type | Format | Template |
75|---|---|---|
76| Squad view (formation, bench, totals) | HTML | `templates/squad-view.html` |
77| Fixture difficulty matrix (teams × next N GWs) | HTML | `templates/fixture-matrix.html` |
78| Transfer comparison (out → in, deltas) | HTML | `templates/transfer-comparison.html` |
79| Captain ranking with reasoning | HTML | `templates/captain-ranking.html` |
80| Gameweek strategy report (squad + fixtures + recs) | HTML | `templates/gameweek-report.html` |
81| Single-stat lookup ("Salah's form?") | markdown | — |
82| Short reasoning ("Bench Haaland this week?") | markdown | — |
83| Deadline, price changes, one-line answers | markdown | — |
84| 3-row SQL result | markdown | — |
85
86Heuristic: if the user will *refer back to it, share it, or scan it visually* → HTML. If they glance and move on → markdown.
87
88### Universal rules for HTML output
89
901. **Single self-contained `.html` file.** No build step. CSS in `<style>`, JS in `<script>`, SVG inlined.
912. **Vanilla HTML/CSS/JS only.** No Tailwind, no shadcn, no external CDN, no web fonts.
923. **Mobile responsive.** Include `<meta name="viewport" content="width=device-width, initial-scale=1">`. Layout survives a phone viewport.
934. **Save to** `~/.fplcopilot/reports/{YYYY-MM-DD}-{slug}.html`. Create the directory with `mkdir -p` if missing.
945. **Tell the user the path** after saving. On macOS, offer `open <path>` to view in their default browser.
956. **Adapt the template, don't write from scratch.** Read the matching file in `templates/`, replace the placeholder data with real values from SQL, save the result.
96
97**Before generating any HTML report, read `references/html-output.md`** for color tokens, typography, the team-color table, the sortable-table snippet, and the list of anti-patterns to avoid.
98
99## Reference Docs
100
101Read these BEFORE answering questions in their domain:
102
103| Doc | When to Read |
104|-----|-------------|
105| `references/api.md` | Understanding FPL API endpoints and data structure |
106| `references/analysis.md` | Computing metrics (VAPM, projected points, FDR, momentum, etc.) |
107| `references/squad.md` | Squad persistence, management, multi-squad, scoring rules |
108| `references/schema.sql` | Understanding database tables and columns |
109| `references/html-output.md` | Styling rules, color tokens, team colors, anti-patterns for HTML reports |
110
111## Squad Persistence
112
113Squads are stored as markdown files in `~/.fplcopilot/squads/` — one file per squad. This enables multi-squad support (user's own team, friends' teams, draft plans).
114
115**Proactive persistence rules — the agent MUST follow these:**
116
1171. **On squad identification**: When the user shares their squad (screenshot, text, or any format), immediately save it to `~/.fplcopilot/squads/`. Ask for a name if unclear.
1182. **On squad changes**: When the user makes a transfer, changes captain, uses a chip, or modifies their squad in any way, update the squad file immediately after confirming the change.
1193. **On conversation start**: If the user asks about "my squad" or "my team", check `~/.fplcopilot/squads/` for existing squad files first. List available squads if multiple exist.
1204. **On analysis**: After generating a strategy report or analysis, update the squad file's Notes section with key takeaways.
1215. **Multi-squad**: Users may discuss multiple squads (their own, friends', draft plans). Each gets its own file. The user can specify which squad by name.
1226. **File naming**: Use kebab-case slugs derived from the squad name (e.g., `my-fpl-team.md`, `daves-team.md`, `wildcard-draft.md`).
123
124Read `references/squad.md` for the full markdown format specification.
125
126## Agent Rules
127
1281. **Always check freshness** before answering data questions. If `sync_metadata` shows stale data (bootstrap > 6h, fixtures on match day > 2h), run the sync script first.
1292. **Always check for saved squads** when the user asks about "my squad/team". Read `~/.fplcopilot/squads/` before asking the user to re-share.
1303. **Never guess player IDs.** Look up by name:
131 ```sql
132 -- Try exact web_name first, then partial, then full name
133 SELECT * FROM players WHERE web_name = 'Salah' COLLATE NOCASE;
134 SELECT * FROM players WHERE web_name LIKE '%salah%' COLLATE NOCASE;
135 SELECT * FROM players WHERE (first_name || ' ' || last_name) LIKE '%salah%' COLLATE NOCASE;
136 ```
1374. **Price units**: `now_cost` is in 0.1m units. `130` = £13.0m. Always display as `£X.Xm`.
1385. **Position codes**: GKP, DEF, MID, FWD (mapped from API's 1, 2, 3, 4).
1396. **Status codes**: `a`=available, `d`=doubtful, `i`=injured, `s`=suspended, `u`=unavailable.
1407. **FDR scale**: 1 (very easy) to 5 (very hard).
1418. **Normalize by price** when comparing players: value = points / (cost in millions).
1429. **Fetch player detail on demand**: Only run `sync.sh player <id>` when the user asks about a specific player's match-by-match performance. Don't batch-fetch unless explicitly needed.
14310. **Proactively persist squads**: Always save/update squad files after any squad-related interaction. Never rely on conversation context alone.
14411. **Generate HTML for spatial outputs**: Any request that maps to a template in `templates/` — "plan gameweek" / "next gameweek team" → `gameweek-report.html`; "show/view my squad", formation, bench → `squad-view.html`; "compare transfer", out → in → `transfer-comparison.html`; "captain pick" with reasoning → `captain-ranking.html`; fixture run / FDR matrix → `fixture-matrix.html` — MUST produce the HTML file (saved to `~/.fplcopilot/reports/{YYYY-MM-DD}-{slug}.html`) and report the path with an `open <path>` hint on macOS. Markdown is only for one-line / single-stat lookups, short reasoning, deadlines, price changes, or ≤3-row SQL results.