Skip to content

flegars/mtg-deckbuilder

Repository files navigation

mtg-deckbuilder

A local-first desktop app for building and refining Magic: The Gathering Commander (EDH) decks, with an AI co-pilot that actually understands your strategy.

Why this app

Existing online deckbuilders are great at cataloguing cards but mediocre at the part that actually matters: deciding what should be in your deck and why. They are also tied to a browser tab, a login, and a server that may change pricing, rate-limits, or policies at any time.

This project takes a different angle:

  • Your collection, your decks, on your machine. Everything lives in a local SQLite database. No account, no cloud sync, no telemetry. You can use it on a plane.
  • Commander-first. Rules, validation, color-identity filtering, and the whole UX are built around the EDH format — not generic 60-card constructed shoehorned into a "Commander mode".
  • AI where it adds value, not as a gimmick. Three focused workflows — Doctor, Suggestions, Synergy — that take the full deck context (commander, strategy notes, current 99, color identity, mana curve, known combos) and produce structured, explainable advice instead of vague "this card is good" replies.
  • Bring Your Own Key. AI features call the Anthropic API directly with your own key. You see the estimated cost before each run, and the actual cost after. No middleman, no markup, no opaque quota.

In short: a deckbuilder that respects your time, your wallet, and the fact that Commander is a deeply contextual format where good advice requires knowing the whole picture.

What it does

Deck building

  • Commander picker that surfaces only legal commanders (legendary creatures, planeswalkers with the "can be your commander" clause, partners, etc.) — eligibility is derived from Scryfall's oracle text, so new sets work automatically.
  • Color-identity-aware card search — the search panel only shows cards your commander is actually allowed to run.
  • Full 100-card deck editor with the commander, mainboard, and category grouping.
  • Strategy notes attached to the deck — a short brief of what the deck is trying to do. These notes are fed to the AI for every analysis, so suggestions stay aligned with your intent.
  • Import / export decks as plain text (compatible with the formats used by Moxfield, Archidekt, Arena, etc.).
  • Deck validation against Commander rules (singleton, 100 cards, color identity, banlist).

Analysis

  • Mana curve, color pip distribution, type breakdown, ramp/draw/removal counts computed locally — no API call, no spinner.
  • Combo detection via the Commander Spellbook database: every two-card and multi-card combo present in the deck, with a description of the loop and the colors required.
  • Mana base health check — does the deck have enough sources for each pip in its curve?

AI co-pilot (optional, BYOK)

Three workflows, each running as a multi-step agent loop with tool calls (card search inside the deck's color identity, deck-stats inspection, etc.), then returning a structured report — not a wall of prose:

  • Deck Doctor — audits the current build, flags weaknesses by severity (mana base, win conditions, interaction, redundancy), and recommends concrete cuts and adds.
  • Suggestions — given the commander, the strategy notes and what's already in the 99, proposes new cards with a short justification each, filtered to the legal color identity.
  • Synergy Analysis — explains which cards work together, identifies anchor cards, and surfaces dead weight (cards that don't synergise with anything else).

Every AI run is logged locally: prompt, response, tokens in/out, model, cost. You can re-open past Doctor reports at any time. Cost is estimated before you press the button and recorded after, so there are no surprise bills.

Card database

  • Scryfall bulk import runs locally on first launch (and on demand from the Database panel). The full card pool is then queryable offline.
  • Combo cache so repeated combo lookups don't hammer Spellbook.

Tech stack (one-liner)

Electron + React 19 + TypeScript, with better-sqlite3 as the local store, @anthropic-ai/sdk for AI features, and Tailwind + Radix UI for the interface.

Project Setup

Install

$ npm install

Development

$ npm run dev

Build

# For Windows
$ npm run build:win

# For macOS
$ npm run build:mac

# For Linux
$ npm run build:linux

Recommended IDE Setup

Contributing

Contributions are welcome — bug reports, feature ideas, and pull requests alike.

Before you open a PR

  1. Open an issue first for anything non-trivial (new feature, UX change, AI prompt change, schema migration). It avoids wasted work and keeps the scope of the app focused.
  2. Make sure the build is green:
    npm run typecheck
    npm run lint
    npm run build
    There is no automated test suite yet — please don't add one without discussing it in an issue first.
  3. Keep changes scoped. One feature or one fix per PR; don't bundle unrelated refactors.

Code conventions

  • Prettier + ESLint are the source of truth. Run npm run format and npm run lint before committing — the configs in .prettierrc.yaml and eslint.config.mjs win every style argument.
  • Three TypeScript projects. Renderer code uses tsconfig.web.json; main and preload use tsconfig.node.json. Don't import electron from renderer code — go through the preload bridge.
  • Renderer ↔ main goes through window.api. Expose a typed function in src/preload/index.ts, declare it in src/preload/index.d.ts, and back it with an ipcMain.handle in src/main/.
  • Pure domain logic stays pure. Files under src/main/domain/ must not import from electron, better-sqlite3, or any IO module — they should be trivially unit-testable.
  • Commit style. Conventional Commits (feat:, fix:, chore:, refactor:, docs: …) with a scope when it helps (feat(doctor): …).

Areas where help is especially welcome

  • New AI tools / prompts (deeper synergy reasoning, budget-aware suggestions, sideboard ideas for cEDH).
  • Better combo visualisation in the UI.
  • Performance work on large collections (50k+ card imports).
  • UX polish — keyboard navigation, accessibility, dark/light themes.

Reporting a bug

Please include:

  • OS + app version.
  • The deck (export as text and paste it in) if the bug is deck-specific.
  • Steps to reproduce, expected vs. actual behaviour.
  • For AI-related bugs: the model used and, if you're comfortable sharing it, the redacted Doctor/Suggestions/Synergy run ID from the local log.

Thanks for helping make Commander deckbuilding a little less tedious.

About

AI-assisted Magic: The Gathering Commander deck builder for macOS. Local Electron app powered by Claude (Anthropic), Scryfall card data, and Commander Spellbook combo detection.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages