> ## Documentation Index
> Fetch the complete documentation index at: https://developer.dittowords.com/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> These are Ditto's developer docs. Ditto is a single source of truth for product copy across design, review, localization, and code.
> The first step on any codebase is a scan: https://developer.dittowords.com/get-started/scan-your-repo.md. That page also covers reviewing the style guide Ditto drafts from the scan. After it, the follow-on guides are Connect Figma files and Set up localization (under /guides/) and Connect the Ditto MCP (the Setup page of the MCP reference).
> Two different MCP servers: the Ditto MCP server at https://api.dittowords.com/v2/mcp gives an agent a workspace's text and style guide rules; the documentation MCP server at https://developer.dittowords.com/mcp searches these docs.
> Prefer logging in with a Ditto account (npx -y @dittowords/cli@latest login; OAuth in MCP clients) over API keys. API keys are for CI and headless clients only.
> Commands are complete as written and use npx -y @dittowords/cli@latest; nothing needs a global install.

# Ditto Specs CLI setup

> Install the Specs CLI, configure your project, and set up API keys and agent integration

## Prerequisites

* **Node.js** >= 18
* A **Ditto API key** — generate one from your [developer integrations settings](https://app.dittowords.com/developers/api-keys)
* A Ditto workspace with at least one style guide

## Installation

**1. Install the package**

```bash npm theme={null}
npm i --save-dev @dittowords/spec-cli
```

```bash yarn theme={null}
yarn add --dev @dittowords/spec-cli
```

**2. Initialize your project**

Run the init command from your repo root:

```bash theme={null}
npx ditto-spec init
```

This creates two files:

* `dittospec.config.json` — project configuration
* `workspace.ditto.md` — workspace-level Ditto spec file for universal style guide rules

**3. Set your API key**

Set the `DITTO_TOKEN` environment variable:

```bash theme={null}
export DITTO_TOKEN=your-api-key
```

> [!NOTE]
>
> You can also add `DITTO_TOKEN=your-api-key` to a `.env` file at the repo root. The CLI loads it automatically.

**4. Verify the connection**

Run a dry-run pull to confirm everything is wired up:

```bash theme={null}
npx ditto-spec pull --dry-run
```

You should see a list of discovered Ditto spec files and what style guide rules would be written.

## Configuration

The `dittospec.config.json` file controls how the CLI discovers Ditto spec files and syncs style guide rules. A minimal config:

```json theme={null}
{
  "apiBase": "https://api.dittowords.com"
}
```

A full config with all options:

```json theme={null}
{
  "apiBase": "https://api.dittowords.com",
  "roots": ["design-system", "src/components"],
  "styleguides": ["Brand Voice", "Product UI"],
  "locales": ["de-DE", "fr-FR"],
  "defaultStyleguide": "Brand Voice"
}
```

### Properties

| Key | Required | Description |
| - | - | - |
| `apiBase` | Yes | Ditto API base URL. |
| `roots` | No | Repo-relative directories to search for Ditto spec files. Defaults to `["."]`. |
| `styleguides` | No | List of style guide names or IDs to pull style guide rules from. Defaults to all guides in the workspace. |
| `locales` | No | Locale codes to include (e.g. `["de-DE", "fr-FR"]`). Includes locale-scoped style guides matching these codes. Base (no-variant) guides are always included. |
| `defaultStyleguide` | No | Default style guide for `create-rules`. Overridable with the `--styleguide` flag. Defaults to the first guide returned by the API. |

## Agent setup

Running `init` with the `--agent` flag writes configuration for your AI development tool:

```bash theme={null}
npx ditto-spec init --agent
```

> [accordion] Claude Code
>
> Appends a **Ditto Specs** section to `CLAUDE.md` (creates the file if absent) and writes three skill files to `.claude/commands/`:
>
> | Skill | What it does |
> | - | - |
> | `/ditto-spec-component` | Analyze a component, create Ditto spec files, auto-fill surfaces and tags, sync style guide rules |
> | `/ditto-spec-audit` | Audit copy in component instances against style guide rules in their Ditto specs |
> | `/ditto-spec-gaps` | Find style guide rule gaps, then create new rules on the platform |
>
> See [Agent Skills](https://developer.dittowords.com/ditto-specs-cli-reference/agent-skills.md) for detailed documentation of each skill.

> [accordion] Cursor
>
> Appends a **Ditto Specs** section to `.cursorrules` with instructions for reading and creating Ditto specs.

> [!NOTE]
>
> Re-running `init --agent` is safe — it updates skill files to the current CLI version and skips `CLAUDE.md` sections that already exist. Use `--force` to overwrite skill files you've customized.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.