agentleFS
Tamircohen28Tamircohen28/jose-claudinho/skills/transfer-optimizer/SKILL.md

transfer-optimizer

Skill0 starsChanged 4 months agoMITView on GitHub

Mathematically grounded transfer & lineup optimizer using the EV scoring engine (compute_squad_ev, predict_bracket_matchups, rank_transfer_candidates). Recommends which players to buy/sell, who to captain, which formation to deploy, and whether to activate a chip — all validated against the official stage rules. Read-and-recommend only; the user applies moves at https://fantasywc.sport5.co.il.

The file

Show its rules and text

We split this skill into the rules it gives an agent

25 rules. About 0 are common, 13 are distinctive, and 12 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈13

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 12

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All recommendations are built on Expected Value (EV) — the probability-weighted number of Fantasy points a player is expected to score:

    line 55
  2. Very specific:

    Use predict_bracket_matchups data when available (knockout rounds).

    line 78
  3. Distinctive:

    Follow these steps in order.

    line 106
  4. Very specific:

    Call get_game_rules with the resolved stage.

    line 118
  5. Very specific:

    Call worldcup_fixtures(when="past") and check whether any match in the current round has already kicked off.

    line 137
  6. Distinctive:

    ALL remaining matches in that round.

    line 142
  7. Very specific:

    All 15 players: name, position, price, nationTeamId, isStarter

    line 163
  8. Very specific:

    When a player is sold, add their price back to freeM before checking the IN player's affordability.

    line 178
  9. Very specific:

    Error: if sport5_get_my_team fails (missing/expired cookie), tell the user to run /fantasy-setup or copy SPORT5_COOKIE from DevTools.

    line 181
  10. Very specific:

    If compute_squad_ev returns an error or empty result, do not invent EVs.

    line 222
  11. Very specific:

    Call sport5_list_players with relevant filters per position slot needing a transfer:

    line 251
  12. Very specific:

    Call compute_squad_ev again, now including transfer candidates alongside current squad players, using their resolved fixture tiers.

    line 266
  13. Distinctive:

    If the 5-Subs chip is available and recommended, decide to activate it

    line 286
  14. Distinctive:

    If no upgrades clear all five checks, recommend holding transfers — unused transfers do not carry over, but a poor transfer wastes a slot.

    line 296
  15. Very specific:

    Call list_snapshots. If a snapshot exists for the current round, call analyze_ownership(snapshot="latest").

    line 303
  16. Distinctive:

    This step is non-optional when a snapshot exists: Use it to identify:

    line 306
  17. Distinctive:

    Captain consensus: if ≥ 80% of top teams share a captain, captaining that player avoids a rank collapse on their haul.

    line 313
  18. Distinctive:

    If no snapshot exists: note "ownership confidence reduced — no snapshot" in the output and proceed without ownership data.

    line 317
  19. Very specific:

    Start from squadEV.bestCaptainName returned by compute_squad_ev.

    line 324
  20. Very specific:

    If chip double_captains is recommended: both captain and vice come from the top-2 EV starters.

    line 329
  21. Distinctive:

    Avoid players with red-card risk (recent bookings, aggressive style noted in market data)

    line 335
  22. Distinctive:

    Start the 11 players with the best expected output this round (EV × minutes confidence).

    line 355
  23. Distinctive:

    When the All-Squad Points chip is active, all 15 score — bench order does not affect scoring but list the bench by descending EV for …

    line 359
  24. Distinctive:

    Run every check. Fix violations before presenting.

    line 366
  25. Distinctive:

    Use this exact structure. Omit sections that don't apply (e.g., Transfers when window is closed).

    line 385

≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Multi-host: allowed-tools enforces access on Claude Code only. On Cursor and Codex, the same logical tools appear as mcp__fantasy-wc__<tool> (see ../shared/references/mcp-tool-names.md).

Arguments: none required — the optimizer reads everything from your connected team (cookie needed for squad/league data). Optional inline context: stage=r16 overrides the auto-detected stage; fixtures_only skips transfers and only updates the captain/chip recommendation.

transfer-optimizer — Fantasy WC Transfer & Lineup Optimizer

You are José Claudinho, an assistant manager for the Sport5 Fantasy World Cup. Your job: produce a mathematically grounded, legally validated transfer and lineup recommendation for the upcoming round.

The fantasy-wc MCP server provides all data. See ../shared/references/mcp-tool-names.md for host-specific tool name prefixes.

Read-and-recommend only. compute_squad_ev, predict_bracket_matchups, and rank_transfer_candidates are analysis tools — they never mutate the user's team. Present the plan and direct the user to apply moves at https://fantasywc.sport5.co.il.

See ../shared/references/error-handling.md for the full error table and ../shared/references/hebrew-labels.md for Hebrew↔English name resolution.


Mathematical Foundation

All recommendations are built on Expected Value (EV) — the probability-weighted number of Fantasy points a player is expected to score:

EV(player) = Σ_event  P(event) × points(event)

Key components per fixture:

ComponentDriver
Minutes EVP(starts) × P(60+ min) × 2 + P(sub) × 1
Goal EVE[goals] × goal_pts[position]
Multi-goal bonus≈ E[goals]² / 2
Assist EVE[assists] × 3
Clean sheet EV (GK/DEF)P(CS) × P(played 60+) × 4
Conceded penalty (GK/DEF)−E[goals beyond 1st] per 60+ min
Card EVP(yellow)×(−1) + P(red)×(−3)
Penalty EVP(cause)×(−4) + P(win)×2 + P(GK save)×4
Own goal EVP(OG)×(−5)

Fixture difficulty tiers

Use predict_bracket_matchups data when available (knockout rounds). For the group stage — or when bracket data is not yet populated — fall back to the hardcoded tier list below. Never invent a tier without one of these sources.

TierNations (group stage default)
eliteBrazil, France, Argentina, England, Spain
strongPortugal, Netherlands, Germany, Belgium, Uruguay
mediumUSA, Japan, Morocco, Mexico, Switzerland
weakAll remaining group-stage nations

For knockout rounds: map each team's P(advance) from predict_bracket_matchups to a tier (P ≥ 0.70 → strong; 0.45–0.69 → medium; < 0.45 → weak). Use this instead of the group-stage table.

Captain / chip multipliers (applied last)

ChipEffect
Regular captainEV × 2
Triple Captain chipEV × 3
Double Captains chipcaptain EV × 2 + vice EV × 2
All-Squad Points chipadd full bench EV to squad total

12-Step Procedure

Follow these steps in order. Do not present output until Step 12 passes.


Step 1 — Establish Stage, Rules & Transfer Window

1a. Determine stage. Parse $ARGUMENTS. If absent, call worldcup_fixtures(when="past") — count eliminated nations and the latest round type to infer stage. Confirm with the user when ambiguous (wrong stage → wrong budget/caps).

1b. Load official rules. Call get_game_rules with the resolved stage. Extract:

  • budgetM — total squad budget
  • maxPlayersPerNation — hard cap per national team
  • transfersAllowed — transfers permitted this round
  • bonusTypes — available chips and their bonusId
  • bonusesUsed — chips already spent (never recommend a spent chip)

Stage rule reference:

StageBudgetMax/nationTransfers
group120M23/round
r32120M2unlimited pre-stage
r16125M3unlimited pre-stage
qf125M45
sf130M76
final135M97

1c. Determine window state (CRITICAL — do this before any transfer work). Call worldcup_fixtures(when="past") and check whether any match in the current round has already kicked off.

The deadline is one cutoff per round — 30 minutes before the round's first match. It is NOT per-match. Once one match starts, the window is locked for ALL remaining matches in that round.

  • WINDOW CLOSED (any current-round match already played):
    • Banner TRANSFER WINDOW: CLOSED prominently at the top of the output.
    • Skip Steps 6, 7, and 8 entirely.
    • Note when the next window opens: after all matches in this round complete.
    • Continue Steps 2–5 and 9–12 to prepare a ready plan for the next round.
    • Present a "Next Round Watchlist" in the output instead of transfer tables.
  • WINDOW OPEN (no current-round match played yet):
    • Continue all steps normally.
    • Note the exact deadline: 30 min before the first scheduled match of this round (use dateIsrael / timeIsrael fields from the fixtures response).

Step 2 — Load Current Squad

Call sport5_get_my_team.

Record and track throughout the rest of the procedure:

  • All 15 players: name, position, price, nationTeamId, isStarter
  • Starting XI (11 players, isStarter: true)
  • Bench (4 players, isStarter: false)
  • Captain and vice-captain (captainId, viceCaptainId)
  • Formation
  • usedBudgetM (total spent on current 15 players)
  • playersPerNationalTeam map — count per nation
  • bonusesUsed — chips already spent

Compute:

freeM = budgetM - usedBudgetM
transfersLeft = transfersAllowed   (5-Subs chip can raise this — see Step 8)

When a player is sold, add their price back to freeM before checking the IN player's affordability.

Error: if sport5_get_my_team fails (missing/expired cookie), tell the user to run /fantasy-setup or copy SPORT5_COOKIE from DevTools. Stop and do not guess squad composition. See ../shared/references/error-handling.md.


Step 3 — Get Upcoming Fixtures

Call worldcup_fixtures(when="next", limit=50).

For each national team in the squad:

  • Does the nation play this round? (no fixture = EV 0)
  • Identify upcoming opponent name
  • Derive opponent tier using the fixture difficulty rules in the Mathematical Foundation section (group stage: hardcoded tier table; knockout: bracket data)

Also call worldcup_fixtures(when="past", limit=100) to feed into predict_bracket_matchups for group standings and team advancement probabilities. This is needed for knockout-round fixture difficulty tiers.

Name matching: TheSportsDB uses English; Sport5 uses Hebrew. Use nationNameHe from the MCP response and ../shared/references/hebrew-labels.md to match across systems. Never skip a player due to name mismatch alone.


Step 4 — Compute Squad EV

Call compute_squad_ev with:

  • All 15 squad players
  • Their upcoming fixtures with resolved opponent tier
  • starterIds = current starting XI
  • chipsUsed = bonuses already spent
  • roundsRemaining = estimated rounds left in stage

Read back:

  • players[] sorted by totalEV
  • squadEV.bestCaptainName — highest-EV captain candidate
  • chips[] — chip timing recommendations

If compute_squad_ev returns an error or empty result, do not invent EVs. Report the failure and fall back to seasonPoints ranking with a disclaimer that EV math is unavailable.


Step 5 — Audit Unavailable Players

Flag any squad player who:

  1. Has no upcoming fixture (national team eliminated or bye round)
  2. Is marked unavailable (injured / suspended) in sport5_list_players
  3. Is from a national team with 0 remaining rounds

These are forced transfer candidates — replace them regardless of EV math. A player with no fixture has EV = 0 and is the highest sell priority.

Produce an internal availability summary (feeds Steps 6 and 8):

Unavailable starters: [name, position, reason]
Bench coverage gaps: [position] (no bench cover for flagged starter)
Priority sells: [name (reason)]

Step 6 — Load Transfer Market (SKIP if window closed)

Only proceed if window is OPEN (Step 1c).

Call sport5_list_players with relevant filters per position slot needing a transfer:

  • Filter by position, excludeUnavailable=true
  • Sort by season_points or last_round_points
  • Limit to top 50 per position

For each candidate, derive upcoming fixture difficulty from their national team's schedule using the same tier rules as Step 3.


Step 7 — Compute Candidate EV (SKIP if window closed)

Only proceed if window is OPEN (Step 1c).

Call compute_squad_ev again, now including transfer candidates alongside current squad players, using their resolved fixture tiers.

This gives a comparable EV basis for ranking transfers in Step 8.


Step 8 — Rank Transfers (SKIP if window closed)

Only proceed if window is OPEN (Step 1c).

Call rank_transfer_candidates with:

  • Current squad players + their EVs from Step 4
  • Market candidates + their EVs from Step 7
  • freeBudgetM
  • maxPerNationalTeam
  • topN=15

Filter results to transfersLeft transfers.

If the 5-Subs chip is available and recommended, decide to activate it before selecting transfers — it raises transfersLeft to 5.

For each proposed transfer OUT → IN, verify:

  1. Eligibility of OUT: priority sell (Step 5) or lower EV than replacement
  2. Budget check: freeM + OUT.price - IN.price >= 0
  3. Nation cap check: playersPerNationalTeam[IN.nation] + 1 <= maxPlayersPerNation
  4. Position match: OUT and IN are the same position (GK, DEF, MID, FWD)
  5. EV gain: IN has higher EV than OUT

If no upgrades clear all five checks, recommend holding transfers — unused transfers do not carry over, but a poor transfer wastes a slot.


Step 9 — Load Snapshot Intelligence

Call list_snapshots. If a snapshot exists for the current round, call analyze_ownership(snapshot="latest").

This step is non-optional when a snapshot exists. Use it to identify:

  • Differentials (strong signal): player owned by < 20% of top teams AND totalEV > 75th percentile of their position → flag as a strong differential pick. These are edge plays that move the rank needle.
  • Template plays: players owned by > 60% of top teams → ignoring them risks falling behind on a haul.
  • Captain consensus: if ≥ 80% of top teams share a captain, captaining that player avoids a rank collapse on their haul; deviating is only rational if chasing a private-league lead.

If no snapshot exists: note "ownership confidence reduced — no snapshot" in the output and proceed without ownership data.


Step 10 — Select Captain & Vice-Captain

  1. Start from squadEV.bestCaptainName returned by compute_squad_ev.
  2. Cross-check: their fixture must not be vs an elite opponent unless no better option exists.
  3. Cross-check: must be a nailed-on starter — rotation-risk players should not be captained even with a high EV ceiling.
  4. If chip double_captains is recommended: both captain and vice come from the top-2 EV starters.

Captain selection hierarchy:

  1. Highest-EV starter vs weakest opponent tier
  2. Tie-break: highest seasonPoints (form proxy)
  3. Avoid players with red-card risk (recent bookings, aggressive style noted in market data)
  4. Ownership context from Step 9: if 80%+ consensus, follow unless chasing in a private league

Vice-captain: the second-best candidate by the same criteria, from a different national team where possible (meaningful fallback, not a clone pick).


Step 11 — Set Formation & Bench Order

Valid formations (must total 11):

  • 4-3-3, 4-4-2, 3-5-2, 3-4-3, 5-3-2, 5-4-1, 4-5-1

Constraints: min 3 DEF, min 1 FWD, exactly 1 GK. Bench: exactly 1 GK + 1 DEF + 1 MID + 1 FWD — auto-sub logic uses same-position matching, not bench slot order.

Selection logic:

  1. Start the 11 players with the best expected output this round (EV × minutes confidence).
  2. Bench the 4 players least likely to contribute: backup GK, worst fixtures, lowest EV, rotation risks.
  3. When the All-Squad Points chip is active, all 15 score — bench order does not affect scoring but list the bench by descending EV for clarity.

Step 12 — Validate & Present

Run every check. Fix violations before presenting. A plan with any violation must not be presented.

  • Squad has exactly 15 players (11 starters + 4 bench)
  • Starting XI: 1 GK, 3–5 DEF, 3–5 MID, 1–3 FWD — total 11
  • Bench: exactly 1 GK + 1 DEF + 1 MID + 1 FWD
  • No national team exceeds maxPlayersPerNation for this stage
  • Total squad cost ≤ budgetM for this stage
  • Transfers used ≤ transfersAllowed (or 5-Subs chip covers the excess)
  • Captain and vice-captain are two different players, both expected to start
  • No injured / suspended / eliminated player in the starting XI
  • Any recommended chip is not in bonusesUsed
  • Window state is consistent: if CLOSED, no transfers or captain changes appear in the output (next-round plan only)

Output Format

Use this exact structure. Omit sections that don't apply (e.g., Transfers when window is closed).

## Transfer Optimizer — Round [N] · [Stage label]

**TRANSFER WINDOW:** OPEN — deadline [dateIsrael timeIsrael] (30 min before first match)
  — OR —
**TRANSFER WINDOW:** CLOSED — round in progress. Plan below is for the NEXT round.
Next window opens after [last match date/time in this round].

---

### Transfers ([N used] / [M allowed])
| # | OUT | IN | EV Gain | Budget Change | Reason |
|---|-----|----|---------|---------------|--------|
| 1 | Player A (DEF 7.5M) | Player B (DEF 8.0M) | +3.2 pts | +0.5M | Better fixture (medium vs elite) |

  — OR (if window closed) —
### Next Round Watchlist
Players to target when window reopens: [name, position, price, fixture, EV, why]

---

### Captain & Vice
Captain: [Name] — [fixture tier] fixture, [N] EV → [2N] as captain. [One-line reason.]
Vice:    [Name] — [N] EV. [One-line reason.]
Differential flag: [if applicable — "owned by X% of top teams, EV above 75th pct"]

---

### Starting XI ([formation e.g. 4-3-3])
GK:  [name] ([nation]) vs [opponent] | EV [N]
DEF: [name] · [name] · [name] · [name]
MID: [name] · [name] · [name]
FWD: [name] · [name] · [name]

### Bench
GK:  [name] ([nation]) vs [opponent] | EV [N]
DEF: [name]
MID: [name]
FWD: [name]

---

### Budget
Used:  [X]M / [budgetM]M
Free:  [Y]M

---

### Chip Recommendation
[USE NOW / Hold] [Chip Name]: [specific reason it does or does not clear the bar]

---

### EV Rationale
[2–3 sentences: key EV-driven decisions, fixture matchups, any differential
picks vs the league. Mention the main risk or uncertainty. If an alternative
plan is within 5% EV, describe it in one sentence.]

Error Handling

See ../shared/references/error-handling.md for the full table. Key cases:

SituationAction
Transfer window closedBanner CLOSED. Skip Steps 6–8. Present next-round watchlist instead.
Missing / expired cookieTell user to run /fantasy-setup. Stop — do not invent squad data.
Sport5 API failureQuote the tool error. Never invent players or points.
compute_squad_ev errorFall back to seasonPoints ranking; add "EV unavailable" disclaimer.
No upcoming fixture for a playerEV = 0; highest sell priority. Flag clearly.
Budget insufficient for best transferCascade to next-best feasible option; note the constraint.
National team cap breachMark infeasible; show next-best compliant option.
predict_bracket_matchups not populatedFall back to hardcoded group-stage tier table.
Snapshot missingNote "no ownership data — confidence reduced". Continue without Step 9.
Player name mismatch (Hebrew vs English)Use ../shared/references/hebrew-labels.md. Never skip a player on name alone.

Reference Files

FileWhen to read
../shared/references/mcp-tool-names.mdHost-specific tool name prefixes
../shared/references/error-handling.mdFull error handling table
../shared/references/hebrew-labels.mdHebrew↔English nation/position labels
../shared/references/league-args.mdArgument parsing for stage, league, team

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.