genome

v0.5.1
@flashdsm/genome Checked 2 days ago Published 20 days ago

Flash Genome - the local MCP server for a Flash design system: give Cursor, Claude and any MCP client your real tokens, component specs and token linting over…

Flash Genome: the local MCP server for a Flash DSM design system, over stdio. Point it at a design-tokens.json and every MCP client - Cursor, Claude Desktop, Claude Code - can read your real tokens and component specs instead of guessing hex values. It also lints code against the system and proposes the token you should have used. Deterministic tools, no LLM inside: the AI is on the other end of the protocol. Works standalone with any token file - a plain design-tokens.json next to your project is enough.

Summary extracted from the README.

@flashdsm/genome

Flash Genome: the local MCP server for a Flash DSM design system, over stdio.

Point it at a design-tokens.json and every MCP client - Cursor, Claude Desktop, Claude Code - can read your real tokens and component specs instead of guessing hex values. It also lints code against the system and proposes the token you should have used. Deterministic tools, no LLM inside: the AI is on the other end of the protocol.

Works standalone with any token file - a plain design-tokens.json next to your project is enough.

Connect it to a Flash design system

Sign in once. Genome opens Flash in the browser, the same OAuth flow Cursor uses, and stores the session under ~/.config/flash-dsm/. Nothing is printed and nothing goes in the repo.

npx @flashdsm/genome login
npx @flashdsm/genome link

link asks the server which system you signed in to and writes genome.config.json next to your code.

A script that cannot open a browser can still set FLASH_GENOME_TOKEN to a flash_mcp_… value. That is the same kind of token OAuth issues.

No design system yet? Start from your code

Started in a folder with no Flash tokens, Genome says so instead of failing: the host gets it in the server instructions, and get_tokens, list_components, check_violations and the other token tools answer designSystem: null with the command below. They read the folder again on every call, so once connect writes the system they answer from it without a restart.

In your app's folder, in a terminal or in your AI editor's chat:

npx @flashdsm/genome@latest connect

connect scans the folder (stylesheets, CSS inside JS/TS, Tailwind config, theme modules, tokens files; nothing else is read) and opens Flash in your browser, showing what it found and a short code that matches the one in your terminal. Click Connect there: Flash creates the system in your account, and the command links the repo (genome.config.json), writes the system into it (pull --confirm), writes the files an agent reads (AGENTS.md, the skill, the Cursor rule) and stores a token bound to that system under ~/.config/flash-dsm/. Inside Claude Code it also adds Genome as the project's MCP server; elsewhere it prints the line to add. --name overrides the name, which otherwise comes from package.json; --no-open prints the link instead of opening it.

Run connect again in a folder that is already connected and it updates that system instead of making another: no scan, no Connect click; it pulls, refreshes the agent files and the live preview. connect --new makes a new system anyway. If the linked system is gone or this machine can't open it, connect says why and connects the folder as a new system.

Your app keeps running on its own CSS: tokens.css is Flash's copy, and nothing imports it until you say so. connect ends with one question for you (or your agent to ask you): use Flash's colours, so a change in Flash shows up in the app? The steps it prints keep every variable name and leave the screen the same in light and dark. AGENTS.md carries the same steps, plus how changes move: while genome watch runs in the background, both ways happen by themselves. Change a token in Flash and Genome rewrites tokens.css within seconds, no Publish; save the app's CSS and Flash takes the change. Genome never writes over a hand edit to tokens.css that Flash doesn't hold. Without it, pull --confirm and push --confirm do the same once.

When your app's dev server is running, connect also leaves a live preview in the background (localhost:4747): Flash's editor shows your real app and recolours it as you edit tokens, through its CSS variables. Nothing is written to your code. npx @flashdsm/genome@latest preview starts it again; preview --stop ends it.

connect also leaves Genome watching the folder. Change a colour, a theme or a type size in your app's own stylesheets and, a couple of seconds after you save, Flash takes it and the editor says what changed, with Undo. Only what you changed comes in: a token edited in Flash since keeps Flash's value (the notice says so), nothing in Flash is deleted, and a comment or whitespace save does nothing. Genome's own files (tokens.css, design-tokens.json, genome/) are never read back. It rescans once an hour as a backup, and keeps running after the terminal closes; the watcher and the live preview are one background process. npx @flashdsm/genome@latest watch starts it again, watch --stop ends both, and watch --once sends one scan in the foreground and says what Flash did with it. The log is ~/.config/flash-dsm/genome-watch.log.

The link works once and expires after 15 minutes. init --code does the same with a setup code instead of the browser.

Quick start

npx @flashdsm/genome --tokens ./design-tokens.json

Cursor (.cursor/mcp.json) or Claude Desktop (claude_desktop_config.json):

{
  "mcpServers": {
    "flash-ds": {
      "command": "npx",
      "args": ["@flashdsm/genome", "--tokens", "./design-tokens.json"]
    }
  }
}

With no flags it looks for ./genome.config.json, then the older ./flash-ds.config.json (tokenFile / componentsFile), then ./design-tokens.json with a sibling ./components.json, and finally falls back to a small bundled fixture so the server always boots. It logs which file it resolved to stderr.

Project shell preview

After scan_workspace creates a design system from local tokens, capture a running preview so Flash can show Your project in the editor:

Tool What it does
capture_project_shell Headless capture of a preview URL → upload + attach as source: project
scan_usage Where the repo's own components are used → the editor's "In your product"

Localhost vs public URL: Flash’s API cannot open localhost on your laptop, so Genome always captures on your machine (Playwright). Pass http://localhost:6006/ (or any public https://… preview you can reach locally). The API only stores the sanitised HTML+CSS — it never fetches the URL for you. Full teammate loop: docs/workflows/README.md § E.

Set an optional default URL in genome.config.json:

{
  "version": 2,
  "genomeId": 42,
  "name": "Acme Product",
  "previewUrl": "http://localhost:6006/"
}

Then call capture_project_shell with no url, or pass url and designSystemId explicitly. Sign in with flash-genome login or FLASH_GENOME_TOKEN (same credential as other hosted tools — never commit it).

Keeping a repo in sync

Once linked:

Tool What it writes
pull_from_web The token files and mirrors named by genome.config.json, plus genome/genome.lock
sync_context AGENTS.md (once), the Cursor rule, and the Agent Skill

Both are dry runs by default: they return a plan of what would be created, updated or skipped, and write only when called again with confirm: true. A second pull is all skips, lock included, whenever the revision, the file list and their contents all still agree, so pulling to check never leaves a diff behind.

Sending repo edits back

Tool What it does
detect_drift Read-only. Whether the repo's pulled files moved, whether Flash moved, and which token values changed
push_to_web Proposes what the code changed to Flash as one change set, reviewed on the Sync page

push_to_web reads the code two ways and sends both in one change set:

  • The app's own stylesheets. A file layered on Flash's tokens.css counts: a light block, --danger: var(--danger-400), new --text-* sizes. The files the pull wrote (listed in genome/genome.lock) are never read as code.
  • The pulled design-tokens.json. Value edits, aliases re-pointed ({color.danger-400}), tokens added, and a light or dark value for a colour Flash holds in the other theme only.

Flash merges them with one set of rules. A var(--step) re-points the alias. A colour equal to a ramp step points at that step; a colour no step holds gets a step of its own (neutral-150) in both themes, so nothing in Semantic becomes a bare hex. New names are added, a value Flash has no theme for is added and said so, and nothing is deleted. The plan says why for every row that is more than a new value.

Nothing is applied until someone with edit rights says yes. A token deleted from the file is flagged, never sent as a delete.

It is a dry run without confirm: true, and it refuses to push while Flash is ahead of genome/genome.lock, because a value left over from the last pull would otherwise look like an edit and undo someone's change. Pull, re-apply your edits, then push.

Tokens that change with the viewport

A system with breakpoints writes each size that moves at its widest step, and lists every step beside it:

"type-h1": {
  "$value": "48px",
  "$type": "font",
  "$extensions": {
    "com.flashdsm.breakpoints": [
      { "name": "phone", "minWidth": 0, "value": "36px" },
      { "name": "tablet", "minWidth": 768, "value": "42px" },
      { "name": "desktop", "minWidth": 1280, "value": "48px" }
    ]
  }
}

tokens.css carries the same steps as media queries, so var(--type-h1) is already responsive.

A push carries the narrowest step only, because that is the one value Flash stores for the token. Change phone in the list and it is proposed like any other edit. Change $value or a wider step and it is flagged: set those sizes in Flash, then pull. A repo that pulled before Genome wrote steps is told to pull again.

AGENTS.md is written once and then left alone however far it drifts: it is where a team puts its own instructions. The Cursor rule is Genome's to keep current, because a stale rule file is worse than none.

Asking the graph

With FLASH_GENOME_TOKEN set, these answer from the design system itself, with the same walk and the same answers as the hosted server's tools of the same name. No linked repo needed.

Tool Args What it answers
get_impact token What breaks if this token changes: tokens that resolve through it, and the components and modules that use any of them
get_relations token? A token's direct edges, or every alias edge, binding and module part
list_modules - Every module, its part count, components and bindings
get_module module One module, parts resolved to components

Tools

Tool Args Description
get_tokens category? Read tokens from the local token file. Read-only
list_components category? List components from components.json
get_component name One component spec
get_brand_dna - Brand DNA from a sibling file or tokens['dsm-brand-dna']
suggest_token context Nearest-token suggestions for hex/px in a snippet. Deterministic
apply_token_patch patch, confirm? Upsert/remove tokens. Dry-run unless confirm: true
generate_component_prompt name Handoff prompt for a component plus its tokens
check_violations file Lint a source file for hardcoded colors / arbitrary Tailwind
capture_project_shell url?, designSystemId?, viewportWidth? Local preview capture → upload + attach (localhost OK)
scan_usage designSystemId?, countsOnly?, dryRun? Count where components are used; dryRun sends nothing
api_health - GET {api}/health against a Flash DSM backend
list_design_systems - List your systems from a Flash DSM backend (needs a token)

Writes are guarded: apply_token_patch is a dry-run unless you pass confirm: true, so a curious agent cannot rewrite your tokens by accident.

CLI

flash-genome --tokens ./design-tokens.json
flash-genome --config ./genome.config.json
flash-genome --tokens ./design-tokens.json --components ./components.json
Flag Env Default
--tokens, -t - resolved as above
--components - sibling components.json
--config, -c - ./genome.config.json
--api-url FLASH_GENOME_API_URL, then FLASH_DS_API_URL this repo's genome.config.json, then https://flashdsm.com
--token FLASH_GENOME_TOKEN none, and link needs it
--access-token FLASH_DS_ACCESS_TOKEN none, deprecated

link uses the MCP token. The deprecated web JWT is only still read by api_health and list_design_systems; every other tool reads local files. Against a backend on your own machine, pass --api-url http://localhost:8008.

Sync commands: pull, push, drift

Scripts and CI need no MCP client. These run the same code as the MCP tools pull_from_web, push_to_web and detect_drift, in the repo that holds genome.config.json (run link first).

flash-genome pull                 # print what would be written; writes nothing
flash-genome pull --confirm       # write the token files, the mirror and genome.lock
flash-genome push                 # print what the code changed, as Flash would propose it
flash-genome push --confirm       # open the change set for review in Flash
flash-genome drift                # has the repo moved, has Flash, which tokens
flash-genome drift --json         # the same, as one JSON object (for watchers)
flash-genome pull --cwd ../web    # run against another repo root
Flag Applies to Meaning
--confirm pull, push Write / propose. Without it the command is a dry run
--json all three Print one JSON object on stdout instead of the plan (errors too)
--cwd all three Repo root (default: the current directory); --config resolves against it
--config, --api-url, --token all three As in the table above

The human output is the plan: + create, ~ update, ! flag lines (a flag is something a person must look at), and a count of the unchanged items.

Exit codes

Code Meaning
0 Done. A dry run that printed its plan is done. drift exits 0 whether or not it found drift: read the output
1 Refused or failed: push while Flash is ahead of the last pull, push or drift in a repo that never pulled, a pull where a file was flagged (refused or failed to write), or a network/server error
2 Auth or config: no token, a token Flash rejects (401/403), no genome.config.json, or a token for a different design system than the config names

--json output. Always one object on stdout, always with ok, command, exitCode (equal to the process exit code) and schemaVersion (currently 1; it moves only if a field is removed or changes meaning, fields are otherwise only added).

  • pull / push: { ok, command, exitCode, schemaVersion, result }, where result is the tool's own result (the change plan: dryRun, entries, counts, plus written for pull, status / changeSetId for push).
  • Any failure: { ok: false, command, exitCode, schemaVersion, error: { kind, message } } with kind one of auth, config, refused, error.
  • drift:
{
  "ok": true,
  "command": "drift",
  "exitCode": 0,
  "schemaVersion": 1,
  "genomeId": 42,
  "state": "repo-dirty",
  "neverPulled": false,
  "flashAhead": false,
  "dirty": true,
  "pushable": 2,
  "changedFiles": ["design-tokens.json"],
  "missingFiles": [],
  "changedTokens": [
    {
      "path": "color.brand-500 (dark)",
      "before": "#2563eb",
      "after": "#ff0000",
      "code": "repo-edit"
    }
  ],
  "pulledPublishedVersionId": 100,
  "publishedVersionId": 100,
  "pulledRevision": 7,
  "revision": 7,
  "summary": "The repo changed 2 token values. Run push_to_web to propose them for review in Flash."
}

state is one of in-step, flash-ahead (Flash changed since the pull: its revision moved, published or not), repo-dirty (a pulled file changed or is missing), both, never-pulled. flashAhead and dirty are the booleans behind it; changedTokens lists the token values the repo changed (code: "repo-edit", what push would propose) and anything else a push does not carry (any other code). never-pulled is the one drift result with exit code 1 and ok: false; the object is still printed in full.

Claude Code plugin

For Claude Code there is also a plugin: the hosted connector, a skill that has Claude read the kit before it writes UI and run check_violations after, /flash:build, /flash:check, /flash:start, and an after-edit check for raw colours. Source and install lines: plugins/claude-flash.

Hosted alternative

If your design system lives in Flash DSM, you may not need this package at all: the app serves a remote MCP endpoint per design system (https://flashdsm.com/api/v1/mcp with a flash_mcp_* token). This package is the local-files variant for repos that vendor their tokens.

Development

Source lives in the Flash DSM Maker monorepo under packages/genome. pnpm --filter @flashdsm/genome test runs the tests, ... build bundles with tsup, ... smoke checks the built output against the fixtures.

MIT.