Metadata-Version: 2.5
Name: basemode-tokens
Version: 0.1.0
Summary: Turn Figma variables and styles into CSS, Tailwind, Sass, TypeScript and W3C design tokens
Requires-Python: >=3.11
Requires-Dist: httpx>=0.27
Description-Content-Type: text/markdown

# basemode-tokens

Turns Figma variables and styles into code. The same engine Basemode runs, usable on its own: no account needed.

```bash
uvx --from basemode-tokens basemode generate --file <figma-file-key> --format tailwind4 --out src/tokens
```

| Way in | Command | Figma plan |
| --- | --- | --- |
| Figma's API | `FIGMA_TOKEN=… basemode generate --file KEY` | Enterprise for variables; styles on any plan |
| Plugin export | `basemode generate --input figma-tokens.json` | Any |
| Basemode | `BASEMODE_KEY=… basemode pull` | Any |

Flags: `--format` (repeat for several: `css`, `scss`, `tailwind4`, `tailwind3`, `typescript`, `dtcg`, `storybook`, `swift`, `android`), `--out`, `--color` (`hex`, `rgb`, `hsl`, `oklch`), `--unit` (`px`, `rem`, `em`), `--prefix`.

- `--check` changes nothing and exits 1 if the files are out of date, for a CI step that fails on drift.
- `--rename-references` rewrites code that uses renamed tokens, and reports removed ones still in use.
- `--summary FILE` writes a pull request title and body.

`basemode.lock.json` is written next to the tokens. Commit it: it's how a rename is told apart from one token removed and another added.

## Checking code

`basemode lint` finds hard-coded colors, spacing, radii and font sizes, says which are already tokens, prints an adoption score, and exits 1 if there are any, for CI:

```bash
basemode lint src --tokens src/tokens/basemode.lock.json
```

Add `basemode-ignore` in a comment to leave a line alone.

## Coding assistants

`basemode mcp` serves the design system over [MCP](https://modelcontextprotocol.io), so an assistant can look up tokens and check its own code. It needs no account when pointed at a lock file:

```bash
claude mcp add basemode -- uvx --from basemode-tokens basemode mcp --tokens src/tokens/basemode.lock.json
```

With a Basemode developer key it also serves your guidelines and components, stays current as designers publish, and sends `report_gap` feedback to your team. Or skip the install and use the hosted server, on every plan:

```bash
claude mcp add --transport http basemode https://api.basemode.io/v1/mcp --header "Authorization: Bearer <developer-key>"
```

Tools: `get_design_system`, `search_tokens`, `find_token`, `check_code`, `get_guidelines`, `list_components`, `check_contrast`, `report_gap`.

## Importing

`--input` also takes W3C (DTCG) and Tokens Studio files, so a team without Figma variables can use everything here:

```bash
basemode generate --input tokens.json --format css --format swift --format android
```

## As a library


```python
from basemode import OutputOptions, generate, parse_source, resolve

resolved = resolve(parse_source(export))
files = generate(resolved.tokens, ["css"], OutputOptions(unit="rem"))
```

To run it from GitHub Actions with no code at all, use [arcarolabs/basemode-action](https://github.com/arcarolabs/basemode-action).
