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

# Ditto CLI (dittosh)

> Install the Ditto CLI with Homebrew or npm and use dittosh to run DQL against a local, offline Ditto store, load sample datasets, inspect query plans and profiles, benchmark statements, learn DQL with interactive lessons, and install Ditto skills for AI coding agents.

> [!NOTE]
>
> The Ditto CLI is in preview. Commands, options, and output can change between releases. This page covers version **0.3.0**.

**dittosh** is the Ditto command-line tool. It runs [DQL](https://docs.ditto.live/dql/dql.md) statements against a local Ditto store on your machine, so you can try queries, check query plans, and measure performance from a terminal without writing an app. It also loads sample datasets, teaches DQL with interactive lessons, and installs Ditto skills into AI coding agents.

After you load the `movies` sample dataset (see [Quickstart](#quickstart)), a query looks like this:

```bash theme={null}
dittosh dql "SELECT _id.title AS title, _id.year AS year, rated FROM movies WHERE _id.year > '2000' LIMIT 3"
```

```text theme={null}
+---------+----------+------+
| rated   | title    | year |
+---------+----------+------+
| PG      | Day City | 2003 |
| UNRATED | Day Wars | 2013 |
| PG      | Day Wars | 2017 |
+---------+----------+------+
3 rows
```

dittosh runs entirely on your machine. It ships with a built-in offline license, so you don't need a Ditto account or credentials, and it never syncs: it doesn't connect to the Ditto Server or to other peers. All your data stays in one local folder (see [Data directory](#data-directory)).

dittosh uses the Ditto Node.js SDK **5.2.0**, so queries behave the same way they do in an app on that SDK version.

## Requirements

* One of these platforms:
  * macOS on Apple silicon (arm64)
  * Linux x64 or arm64
  * Windows x64 (npm only)
* One of these package managers:
  * [Homebrew](https://brew.sh) on macOS or Linux
  * [npm](https://www.npmjs.com/package/@dittolive/cli) with Node.js 22 or later

> [!NOTE]
>
> Intel Macs are not supported.

## Install

**1. Install dittosh**

> [tab] Homebrew
>
> > [!NOTE]
> >
> > Homebrew installs the Node.js runtime that dittosh needs and keeps only your platform's copy of the Ditto SDK, so dittosh takes about 150 MB on macOS and 180 MB on Linux.
>
> ```bash theme={null}
> brew install getditto/tap/dittosh
> ```
>
> Newer Homebrew versions only load formulas from trusted taps. If `brew` reports `Refusing to load formula getditto/tap/dittosh from untrusted tap`, run `brew trust getditto/tap` and try again.

> [tab] npm
>
> > [!NOTE]
> >
> > The npm package includes the Ditto SDK for every supported platform, so an npm install takes about 420 MB.
>
> Install the `@dittolive/cli` package globally. It needs Node.js 22 or later:
>
> ```bash theme={null}
> npm install -g @dittolive/cli
> ```

**2. Check the install**

```bash theme={null}
dittosh doctor
```

`doctor` checks your platform, Node.js, the data directory, the built-in license (shown as `token`), the Ditto SDK, and whether another process has the store open:

```text theme={null}
✓ platform — darwin/arm64 supported
✓ node — v24.22.2
✓ data directory — /Users/you/Library/Application Support/dittosh
✓ token — loaded, expires 2028-05-05 (543d)
✓ sdk — native SDK loaded; store opened and closed
✓ lock — data directory is free
```

`dittosh dql doctor` runs the same checks.

**3. Show versions**

```bash theme={null}
dittosh version
```

This prints the dittosh and Ditto SDK versions, how dittosh was installed, when the built-in license expires, and where your data lives. Add `--format json` for machine-readable output.

### Update

```bash theme={null}
dittosh update
```

`update` checks for a newer release, works out whether you installed with Homebrew or npm, and runs the matching upgrade command. Add `--check` to only check. To upgrade by hand, use the package manager you installed with:

> [tab] Homebrew
>
> ```bash theme={null}
> brew update && brew upgrade getditto/tap/dittosh
> ```
>
> If `brew upgrade` says the tap is untrusted, run `brew trust getditto/tap` once and upgrade again.

> [tab] npm
>
> ```bash theme={null}
> npm install -g @dittolive/cli@latest
> ```

### Uninstall

> [tab] Homebrew
>
> ```bash theme={null}
> brew uninstall dittosh
> ```
>
> To also remove the Node.js runtime that Homebrew installed for dittosh, run `brew autoremove`.

> [tab] npm
>
> ```bash theme={null}
> npm uninstall -g @dittolive/cli
> ```

Uninstalling leaves your data directory and config directory in place. To delete your local store first, see [Data directory](#data-directory).

## Quickstart

```bash theme={null}
# Load a sample dataset of 10,000 movies
dittosh dql dataset load movies

# Query it
dittosh dql "SELECT _id.title, _id.year FROM movies WHERE _id.year > '2000' LIMIT 5"

# Open the interactive DQL shell
dittosh dql

# Learn DQL with guided lessons
dittosh tutorial --interactive
```

To learn dittosh by doing, run `dittosh tutorial`. It writes `dittosh-tutorial.md`, a hands-on walkthrough tailored to your install. See [Tutorials and lessons](#tutorials-and-lessons).

## Run DQL

`dittosh dql` runs DQL statements. It accepts a statement in several ways:

```bash theme={null}
dittosh dql "SELECT * FROM movies WHERE rated = 'PG'"    # a statement as an argument
dittosh dql -f script.dql                                # a file of statements, separated by ;
echo "SELECT * FROM movies LIMIT 3;" | dittosh dql       # statements piped on stdin
dittosh dql                                              # the interactive shell
```

`dittosh dql exec` is the same command under an explicit name.

When you run statements from a file or stdin, dittosh stops at the first failure. Add `--continue-on-error` to run the rest.

### Parameters

Bind `:name` parameters with `-p`, or pass them all at once as a JSON object with `--args`:

```bash theme={null}
dittosh dql "SELECT * FROM movies WHERE rated = :rating" -p rating=PG
dittosh dql "SELECT * FROM movies WHERE rated = :rating AND _id.year > :year" --args '{"rating": "PG", "year": "2000"}'
dittosh dql "SELECT * FROM movies WHERE rated = :rating" --args @params.json
```

`-p` is repeatable. Its values are parsed as JSON when possible and treated as strings otherwise, so `-p year=2000` binds the number `2000`. To bind the string `"2000"`, use `-p 'year="2000"'` or `--args`. `--args -` reads the JSON object from stdin, and `--args @file` reads it from a file.

### Options

Run `dittosh dql -h` to see these options from the command line at any time.

| Option | Description |
| - | - |
| `-h, --help` | Show the options for `dittosh dql`. |
| `-f, --file <path>` | Run the statements in a file, separated by `;`. |
| `-p, --param <name=value>` | Bind a `:name` parameter. Repeatable. |
| `--args <json>` | Bind parameters from a JSON object. `-` reads stdin; `@file` reads a file. |
| `-o, --out <path>` | Write results to a file. The extension picks the format: `.json`, `.csv`, `.md`, or `.html`. Other extensions get a text table. |
| `--format <format>` | `table`, `json`, `csv`, `markdown`, `html`, or `vertical`. Overrides the `-o` extension. |
| `--max-rows <n>` | The most rows to display. Default 10,000. |
| `--no-pager` | Don't page long results through `$PAGER` or `less`. |
| `--continue-on-error` | Keep running statements after one fails (`-f` and stdin). |
| `--time` | Print the time the statement took. |
| `--explain` | Print the query plan. See [Analyze queries](#analyze-queries). |
| `--profile` | Print the execution profile. |
| `--advise` | Print index advice instead of results. |
| `--apply` | With `--advise`, create the suggested indexes. |
| `-y, --yes` | Skip confirmation prompts. |
| `-d, --data-dir <path>` | Use a different data directory. |

### Output formats

In a terminal, results print as a table that fits the window width; long values are shortened with `…`, and long results open in a pager. Use `--format vertical` to print one block per row with nothing shortened.

When you pipe or redirect the output, dittosh prints JSON. Query results go to stdout, and progress, warnings, and diagnostics go to stderr, so you can pipe results into tools like [jq](https://jqlang.org):

```bash theme={null}
dittosh dql "SELECT _id.title AS title FROM movies LIMIT 5" | jq '.[].title'
```

You can feed one query's results into another query's parameters:

```bash theme={null}
dittosh dql "SELECT _id FROM movies WHERE _id.year = '2001' LIMIT 1" \
  | jq '{id: .[0]._id}' \
  | dittosh dql "SELECT * FROM movies WHERE _id = :id" --args -
```

To save results, use `-o`. Results written to a file include every row unless you set a limit with `--max-rows`. dittosh prints a one-line summary of what it wrote:

```bash theme={null}
dittosh dql "SELECT * FROM movies" -o movies.csv
```

In table, vertical, Markdown, and HTML output, attachments appear as `[attachment …]` placeholders, because attachment data isn't returned through DQL. JSON and CSV output include the attachment's metadata object.

> [!NOTE]
>
> CSV output doesn't escape values that start with `=`, `+`, or `@`. Spreadsheet apps can treat these as formulas, so review CSV files from untrusted data before you open them in Excel or a similar app.

## Interactive shell

Run `dittosh dql` with no statement to open an interactive shell. End each statement with `;`; a statement can span several lines. The shell keeps a history and prints how long each statement took.

Options you pass when you open the shell, such as `--profile` or `--format vertical`, apply to every statement you run in it.

| Command | Description |
| - | - |
| `.help` | Show the shell commands. |
| `.collections` | List collections. |
| `.indexes [collection]` | List indexes, optionally for one collection. |
| `.metrics [section…]` | Show the SDK's live system metrics. |
| `.break` or `.clear` | Discard the statement you're typing. |
| `.exit` | Quit. You can also press `Ctrl+D`, or `Ctrl+C` twice. |

### System metrics

`.metrics` shows the Ditto SDK's live system metrics for the session as tables. By default it shows two sections:

* **Store metrics:** SQLite transactions, fsync calls, WAL size, and commit and lock timings.
* **Query metrics:** DQL requests, selects, failures, and parse, plan, and execution times.

The **Total**, **Count**, **Avg**, and **Peak** columns cover the whole session. The **Change**, **New**, **p50** through **p99**, and **Max** columns cover the time since you last ran `.metrics`, so you can run a statement and then see what it cost.

Name one or more sections to see just those, for example `.metrics query` or `.metrics store query`. The sections are `store`, `query`, `network`, `sync`, `transport`, `discovery`, `peer`, and `other`. `.metrics all` shows every section.

## Analyze queries

Add these options to a `dittosh dql` command to see how Ditto runs a query:

```bash theme={null}
dittosh dql --time "SELECT * FROM movies WHERE rated = 'PG'"      # how long it took
dittosh dql --explain "SELECT * FROM movies WHERE rated = 'PG'"   # the query plan
dittosh dql --profile "SELECT * FROM movies WHERE rated = 'PG'"   # the execution profile
dittosh dql --advise "SELECT * FROM movies WHERE rated = 'PG'"    # index suggestions
```

* **`--explain`** prints the plan from [`EXPLAIN`](https://docs.ditto.live/dql/explain) as a tree of operators.
* **`--profile`** runs the query with [`PROFILE`](https://docs.ditto.live/dql/profile) and shows a summary followed by an operator tree. Each operator shows its execution, receive, send, and storage wait times, document counts (including skipped documents), and scheduler yields by reason. Join subplans appear as nested trees, and operators that take 50% or more of the execution time are marked with `▲`. The summary also shows the request type, feature flags, and directives.
* **`--advise`** runs [`ADVISE`](https://docs.ditto.live/dql/advise) instead of the query and prints the indexes that would help, with ready-to-run `CREATE INDEX` statements. It doesn't print query results.

  ```text theme={null}
  Index advice
    analyzed: SELECT * FROM movies WHERE rated = 'PG'

    movies — equality predicates on `rated`
      CREATE INDEX IF NOT EXISTS adv_movies_rated ON default:`movies` (`rated` ASC)

    apply with: dittosh dql --advise --apply "SELECT * FROM movies WHERE rated = 'PG'" (prompts; -y skips)
  ```

  Add `--apply` to create the suggested indexes. dittosh asks before it creates anything; add `-y` to skip the prompt. Without a terminal to prompt in, such as in a script, `--apply` creates indexes only when you also pass `-y`.

`--explain`, `--profile`, and `--advise` work with `SELECT` statements only. When you use `--advise`, dittosh ignores `--explain` and `--profile`. In a terminal, the plan and profile print with the results. When you pipe the output, they go to stderr so they don't mix with the JSON results.

To learn how indexes affect queries, see [Indexing](https://docs.ditto.live/dql/indexing.md).

## Sample datasets

dittosh includes three sample datasets. Each one comes with a catalog of named queries you can run.

| Dataset | Collections | Catalog queries | Default size |
| - | - | - | - |
| `movies` | 1 | 49 | 10,000 movies |
| `retail-joins` | 8 | 96 | 5,000 orders |
| `pos` | 3 | 44 | 5,000 orders |

The data is generated on your machine when you load it.

```bash theme={null}
dittosh dql dataset list                                  # available datasets
dittosh dql dataset show retail-joins                     # document shapes, setup indexes, and the query catalog
dittosh dql dataset load retail-joins --docs 20000        # generate and insert 20,000 orders
dittosh dql dataset run stores__select__by_location_city  # run a catalog query by name
dittosh dql dataset reset retail-joins --yes              # evict the dataset's documents
```

* **`load`**: `--docs <n>` sets the size of the dataset's main collection, and the related collections grow with it. `dataset show` lists how each collection scales. `--seed <n>` makes the generated data reproducible (the default seed is 42). Loading again with a different seed adds more documents; run `reset` first to start over. `--batch-size <n>` sets how many documents are inserted at a time (default 500).
* **`run`**: prints the statement on stderr, then runs it. Query names are looked up across all datasets; add `--dataset <name>` if a name matches more than one. `--setup` creates the query's index first. Queries that write data need `--yes`, and clean up after themselves. `run` also takes `--time`, `--explain`, `--profile`, `-o`, `--format`, and `--max-rows`, and benchmarks the query with `--runs` and `--warmup` (see [Benchmark queries](#benchmark-queries)).
* **`reset`**: evicts all documents in the dataset's collections.

## Collections and indexes

```bash theme={null}
dittosh dql collections          # list collections
dittosh dql indexes              # list all indexes
dittosh dql indexes movies       # list indexes on one collection
```

These read the `system:collections` and `system:indexes` [virtual collections](https://docs.ditto.live/dql/virtual-collections.md). Create and drop indexes with DQL:

```bash theme={null}
dittosh dql "CREATE INDEX IF NOT EXISTS movies_rated ON movies (rated)"
dittosh dql "DROP INDEX IF EXISTS movies_rated ON movies"
```

## Import your own data

`dittosh dql import` loads documents from a JSON file into a collection. The file can be a JSON array of objects:

```json theme={null}
[
  { "_id": "prod_1", "name": "Brass Hammer", "price": 24.99 },
  { "_id": "prod_2", "name": "Cordless Drill", "price": 129.0 }
]
```

Or NDJSON, with one object per line. dittosh detects the format from the first character of the file.

```bash theme={null}
dittosh dql import products.json products
dittosh dql "SELECT * FROM products WHERE price > 100"
```

* The collection is created when the first document is inserted. Collection names can contain letters, digits, and underscores, and can't start with a digit.
* `_id` is optional. Documents without one get a generated ID.
* When a document with the same `_id` already exists, the import updates it with the fields in the file and keeps its other fields. Importing the same file again is safe when its documents have `_id` values. Documents without an `_id` are added again as new documents.
* Large files are inserted in batches of 500 documents. Change this with `--batch-size <n>`.

## Benchmark queries

`dittosh dql bench` runs a statement many times and reports how long it took:

```bash theme={null}
dittosh dql bench "SELECT * FROM movies WHERE rated = 'PG'" --runs 100 --warmup
```

```text theme={null}
+-----------------------------------------+------+--------+------+---------+--------+--------+--------+--------+--------+-----------+
| benchmark                               | runs | warmup | rows | mean_ms | p50_ms | p95_ms | p99_ms | min_ms | max_ms | stddev_ms |
+-----------------------------------------+------+--------+------+---------+--------+--------+--------+--------+--------+-----------+
| SELECT * FROM movies WHERE rated = 'PG' |  100 |     15 | 1784 |  16.427 | 14.961 | 21.437 | 74.256 | 14.341 | 74.256 |     6.814 |
+-----------------------------------------+------+--------+------+---------+--------+--------+--------+--------+--------+-----------+
1 row
```

* `--runs <n>` sets the number of timed runs, from 1 to 10,000. The default is 50.
* `--warmup` runs the statement first without timing it, enough times to fill about 250 ms, so cold caches and query planning don't skew the results. `--warmup <n>` runs it exactly `n` times. Without `--warmup`, there's no warmup.
* `p50_ms` is the median. `p95_ms` and `p99_ms` are taken from the sorted run times, so with 20 runs or fewer `p95_ms` is the slowest run, and with 100 runs or fewer `p99_ms` is the slowest run. Use more runs to measure the tail.
* Times are measured by dittosh, so they include the time to convert results for display. Compare results from the same machine and the same data.

### Set up and clean up

Statements that change data or indexes need setup so that every run does the same work. These options run statements without timing them, and each one is repeatable:

| Option | When it runs | Typical use |
| - | - | - |
| `--pre <stmt>` | Once, before warmup and timing | Create an index. |
| `--before-each <stmt>` | Before every warmup and timed run | Re-insert the document that an `EVICT` removes. |
| `--after-each <stmt>` | After every successful warmup and timed run | Evict the document that an `INSERT` adds. |
| `--post <stmt>` | Once at the end, even after a failure | Drop the index or remove test documents. |

`--reset` is another name for `--before-each`.

Measure a query with an index:

```bash theme={null}
dittosh dql bench "SELECT * FROM movies WHERE rated = 'PG'" \
  --pre "CREATE INDEX IF NOT EXISTS movies_rated ON movies (rated)" \
  --post "DROP INDEX IF EXISTS movies_rated ON movies"
```

Measure an insert, undoing it after each run:

```bash theme={null}
dittosh dql bench "INSERT INTO movies VALUES ({'_id': 'bench-doc', 'rated': 'TEST'})" --runs 50 \
  --pre "EVICT FROM movies WHERE _id = 'bench-doc'" \
  --after-each "EVICT FROM movies WHERE _id = 'bench-doc'" \
  --post "EVICT FROM movies WHERE _id = 'bench-doc'"
```

The `--pre` evict removes a document left behind by an interrupted run. dittosh warns you when an `INSERT`, `EVICT`, or `DELETE` benchmark runs more than once without `--before-each` or `--after-each`.

### Benchmark files

To run a set of benchmarks, put them in a JSON file. Each key names a benchmark:

```json theme={null}
{
  "movies_by_rating": {
    "description": "Optional note for people reading the file.",
    "preQueries": [
      "DROP INDEX IF EXISTS movies_rated ON movies",
      "CREATE INDEX movies_rated ON movies (rated)"
    ],
    "query": "SELECT * FROM movies WHERE rated = 'PG'",
    "postQueries": ["DROP INDEX IF EXISTS movies_rated ON movies"]
  },
  "evict_one": {
    "resetQueries": ["INSERT INTO movies VALUES ({'_id': 'bench-doc', 'rated': 'TEST'})"],
    "query": "EVICT FROM movies WHERE _id = 'bench-doc'"
  }
}
```

| Key | Required | Command-line equivalent |
| - | - | - |
| `query` | Yes | The statement argument. This is the statement that is timed. |
| `preQueries` | No | `--pre` |
| `resetQueries` | No | `--before-each` |
| `afterEachQueries` | No | `--after-each` |
| `postQueries` | No | `--post` |
| `description` | No | None. Notes for readers; not used when running. |

The file can also be a JSON array of benchmarks, each with an optional `name`, or a single benchmark object with `query` at the top level. dittosh rejects unknown keys, and suggests the right key for common misspellings such as `prequeries`, so a typo can't silently skip an index.

```bash theme={null}
dittosh dql bench --example movies -o movies-bench.json      # write a sample file to start from
dittosh dql bench -f movies-bench.json --runs 50 --warmup     # run every benchmark in the file
dittosh dql bench -f movies-bench.json --only filtered_query_with_index
```

`--example` writes a sample file for `movies`, `retail`, `retail-joins`, or `pos`, with an explanation in each entry's `description`. Load that dataset to run the sample as is.

Results go to stdout as a table in a terminal or JSON when piped, and `-o` saves them to a file. To compare a change, such as a new index, save results before and after with `-o before.json` and `-o after.json`. The command exits with code `1` if any benchmark fails, and `2` if the file is invalid.

You can also benchmark a query from a dataset's catalog. Add `--setup` to create the query's index first:

```bash theme={null}
dittosh dql dataset run filtered_query_with_index --setup --runs 50 --warmup
```

## Tutorials and lessons

### Interactive DQL lessons

```bash theme={null}
dittosh tutorial --interactive
```

The interactive tutorial teaches DQL in 27 lessons across beginner, intermediate, and advanced levels. Each lesson explains a concept, shows the syntax, gives you a task, and checks your answer. Most lessons include a note for readers who know SQL. Topics include projection, filtering, sorting, writes, functions, `CASE`, `MISSING` and `NULL`, aggregation and grouping, joins, `ANY … SATISFIES`, indexes, query plans, `USE IDS`, and the system collections.

Lessons run in a separate practice store, so your own data is never changed, and your progress is saved between sessions.

The lessons open full screen. The lesson stays at the top, results scroll below it, and the result of your last answer (✓ or ✗) stays above the prompt.

| Key | Action |
| - | - |
| `Enter` | Run the statement. A trailing `;` is optional. |
| `Up` / `Down` | Move through the statements you've run. |
| `Tab` | Show a hint. |
| `Ctrl+N` / `Ctrl+P` | Next or previous lesson. |
| `Ctrl+L` | Pick a lesson from a list. |
| `Ctrl+B` | Show or hide the lesson outline and your progress. |
| `Ctrl+T` | Show the fields of the collections the lesson uses. |
| `Ctrl+O` | Show the whole lesson when the window is short. |
| `?` | Open the help panel (when the input line is empty). |
| `Esc` | Clear the input, or close the help panel. |
| `PgUp` / `PgDn` | Scroll the results. |
| `Ctrl+D` or `Ctrl+C` | Quit (when the input line is empty). |

The shell commands `.hint`, `.answer`, `.next`, `.back`, `.lessons`, `.level <name>`, `.goto <n>`, `.schema`, `.reset`, `.break`, and `.exit` work too.

These options work with `--interactive`:

* `--level beginner`, `--level intermediate`, or `--level advanced` starts at that level.
* `--plain` uses a simple line-by-line shell instead of the full-screen view. dittosh also uses it when the terminal is smaller than 60 × 20.
* `-d <path>` keeps the practice store in a different directory.

### dittosh walkthrough

```bash theme={null}
dittosh tutorial                      # write ./dittosh-tutorial.md
dittosh tutorial -o ~/tutorial.md     # choose where to write it (--force overwrites)
dittosh tutorial --stdout             # print it instead
```

The walkthrough is a Markdown file of commands to try, tailored to your install: your dittosh and SDK versions, your platform, and the upgrade command for your install. It covers importing, querying, and exporting data, the interactive shell and `.metrics`, sample datasets, query analysis, benchmarking, joins, system collections, and agent skills.

## AI agent skills

`dittosh skills` installs Ditto skills from the [getditto/agent-skills](https://github.com/getditto/agent-skills) repository into AI coding agents, so they write correct DQL and SDK code.

```bash theme={null}
dittosh skills add                          # install write-dql into every agent dittosh detects
dittosh skills add swift-sdk                # plus the skills it links to
dittosh skills add js-sdk                   # all JS/TS skills
dittosh skills add js-node --no-deps        # only the named skill
dittosh skills add --all                    # install every skill
dittosh skills add --agent claude,cursor    # install into specific agents
dittosh skills add --project .              # install into this project instead of globally
dittosh skills add --ref <tag>              # install a specific release
dittosh skills list                         # see global installs (add --project <path> for a project)
dittosh skills update                       # update write-dql to the latest release
dittosh skills update --all                 # update every installed skill
dittosh skills versions                     # list published releases
```

The default skill is `write-dql`. Others include:

* **SDKs:** `swift-sdk`, `kotlin-sdk`, and `js-sdk`
* **JavaScript platforms:** `js-node`, `js-web`, `js-react-native`, and `js-expo`
* **Concepts:** `data-modeling`, `data-streams`, `ditto-mesh-networking`, `sync-subscriptions`, and `native-app-config` (Apple and Android permissions)

Run `dittosh skills add --all` to get every skill in the repository.

`add` skips skills that are already installed; add `--force` to overwrite them. Use `update` to move to a newer release, or `update --ref <tag>` to move to a specific one. `list` and `update` work on global installs unless you pass `--project <path>`. The `skills` commands accept `--format table|json|csv`.

### Companion skills

Some skills link to files in other skills, and those links only work when both skills are installed. `dittosh skills add` installs the linked skills too, and lists them on stderr and as `companion of <skill>` in the results. With agent-skills v0.6.1:

| Installing | Also installs |
| - | - |
| Any `js-*` skill | The other JavaScript skills and `native-app-config` |
| `swift-sdk` | `native-app-config` |
| `data-streams` | `kotlin-sdk`, `swift-sdk`, and `native-app-config` |
| `data-modeling` | `write-dql` |

Companions that are already installed show as `present`. Add `--no-deps` to install only the named skill; later updates of that install don't add companions either. `update` installs companions that a newer release adds, unless you pass `--no-deps`.

Copilot and Windsurf get one file per skill, so links between skills can't work there, and dittosh doesn't install companions for them.

### Agents and locations

dittosh detects agents from their folders in your home directory and in the current directory. If it finds none, pass `--agent`.

| Agent | `--agent` name | Global location | Project location |
| - | - | - | - |
| Claude Code | `claude` | `~/.claude/skills` | `.claude/skills` |
| OpenCode | `opencode` | `~/.agents/skills` | `.agents/skills` |
| Codex | `codex` | `~/.codex/skills` | `.codex/skills` |
| Gemini CLI | `gemini` | `~/.gemini/skills` | `.gemini/skills` |
| Antigravity | `antigravity` | `~/.gemini/config/skills` | `.agents/skills` |
| Cursor | `cursor` | None | `.cursor/rules` |
| GitHub Copilot | `copilot` | None | `.github/instructions` |
| Windsurf | `windsurf` | None | `.windsurf/rules` |

Cursor, Copilot, and Windsurf support project installs only, so use `--project` with them.

## Data directory

dittosh keeps the local store in one data directory. It picks the directory in this order:

1. The `-d, --data-dir <path>` option
2. The `DITTOSH_DATA_DIR` environment variable
3. The default for your OS:
   * macOS: `~/Library/Application Support/dittosh`
   * Linux: `~/.local/share/dittosh`
   * Windows: `%LOCALAPPDATA%\dittosh\Data`

Use `-d` to keep separate stores, for example one per experiment:

```bash theme={null}
dittosh dql dataset load retail-joins -d ~/stores/retail-test
dittosh dql "SELECT count(*) FROM orders" -d ~/stores/retail-test
```

Only one dittosh process can use a data directory at a time. A second process exits with code `4`.

To delete the whole store, including all collections, indexes, and files:

```bash theme={null}
dittosh dql delete-store --yes
```

> [!WARNING]
>
> `delete-store` permanently deletes the data directory and can't be undone. It requires `--yes`, and it refuses to run while another process has the store open. To remove only a sample dataset's documents, use `dittosh dql dataset reset <name> --yes`.

## Global options

These options work with every command:

| Option | Description |
| - | - |
| `--no-color` | Turn off colors. |
| `--quiet` | Hide informational notes on stderr. |
| `--debug` | Show the Ditto SDK's debug logs and stack traces on stderr. |
| `-h, --help` | Show help for any command, for example `dittosh dql bench --help`. |

`dittosh --version` (or `-V`) prints the dittosh version.

## Environment variables

| Variable | Effect |
| - | - |
| `DITTOSH_DATA_DIR` | The data directory. |
| `DITTOSH_CONFIG_DIR` | The config directory. It holds shell history, tutorial progress and the practice store, and the record of the last failed command. Defaults to `~/Library/Preferences/dittosh` on macOS, `~/.config/dittosh` on Linux, and `%APPDATA%\dittosh\Config` on Windows. |
| `DITTOSH_NO_PAGER` | Set to `1` to turn off paging. |
| `DITTOSH_DEBUG` | Set to `1` for the same effect as `--debug`, or `verbose` for more detail. |
| `NO_COLOR` | Turn off colors. Colors are also off when `CI` is set or output isn't a terminal. |
| `PAGER` | The pager for long results. Defaults to `less`. |

## Exit codes

| Code | Meaning |
| - | - |
| `0` | Success. |
| `1` | A query or DQL error. |
| `2` | A usage error, such as a bad option, a missing file, or an ambiguous dataset query name. |
| `3` | A platform, license, or data directory problem. |
| `4` | The data directory is locked by another process. |

## Troubleshooting

### Common problems

| Problem | Solution |
| - | - |
| `dittosh: command not found` | Make sure your package manager's install directory is on your `PATH`, then open a new terminal. For Homebrew, see `brew doctor`. For npm, `npm prefix -g` prints the global prefix; commands go in its `bin` folder on macOS and Linux, and in the prefix folder itself on Windows. |
| The store is locked (exit code `4`) | Close the other dittosh command or shell that uses the same data directory, or pass `-d` to use a different one. |
| `token ✗` in `dittosh doctor`, or the license has expired | Update dittosh. See [Update](#update). |
| `platform ✗` in `dittosh doctor` | dittosh supports Apple silicon Macs, Linux x64/arm64, and Windows x64 (npm installs) only. |
| `data directory ✗` in `dittosh doctor` | The directory isn't writable, or a file is in the way. Fix the permissions or pass `-d`. |
| `warning: some trace filter directives…` and `INFO` lines when a command starts | The Ditto SDK prints these to stderr when it starts. They're harmless and don't affect results. |

### See SDK logs

```bash theme={null}
dittosh --debug dql "SELECT * FROM movies LIMIT 1"
dittosh --debug dql "SELECT * FROM movies LIMIT 1" 2> debug.log   # save the logs
```

`--debug` turns on the Ditto SDK's debug logs and prints a stack trace when a command fails unexpectedly. Everything goes to stderr, so the results on stdout don't change.

### Report a problem

```bash theme={null}
dittosh doctor --report
```

This runs the `doctor` checks and writes `dittosh-report-<time>.tar.gz` to attach to a [GitHub issue](https://github.com/getditto/ditto-cli/issues/new?template=bug_report.yml). Pass a path to choose where it's written, for example `dittosh doctor --report ~/Desktop/report.tar.gz`. The file contains:

* `report.md` and `report.json`, with:
  * dittosh and Ditto SDK versions, how dittosh was installed, OS, CPU, memory, and terminal details
  * the `doctor` checks
  * paths, store size, and free disk space
  * dittosh settings, with credential variables shown only as set or not set
  * a store summary: collection names, document counts, and indexes
  * the last command that failed, as you typed it, with its exit code and error output
* `ditto-support-bundle.tar`, the Ditto SDK support bundle with the SDK's debug logs and the store configuration with secrets removed

The report never includes the license token. The store summary doesn't include document contents, but the last failed command is saved as typed, so values in that statement appear in the report. `report.md` and `report.json` show your home folder as `~`. `--no-store` leaves out the store summary, and `--no-sdk-bundle` leaves out the SDK support bundle.

> [!WARNING]
>
> dittosh includes the SDK support bundle as Ditto creates it. Its logs and configuration contain the database ID, full file paths, and peer keys. Extract the report and review it before you post it publicly, or use `--no-sdk-bundle`.

When Ditto support asks only for the SDK support bundle, save it with:

```bash theme={null}
dittosh dql support-bundle                  # ./ditto-support-bundle-<time>.tar
dittosh dql support-bundle -o bundle.tar    # choose the file name
dittosh dql support-bundle --list           # list the bundles kept in the store
```

The SDK creates at most 3 bundles per store every 10 minutes, and `doctor --report` counts toward that limit. After that, dittosh saves the newest existing bundle and tells you so. To learn what a bundle contains, see [Capturing Support Bundles](https://docs.ditto.live/sdk/latest/deployment/support-bundles.md).

## Related documentation

* [DQL overview](https://docs.ditto.live/dql/dql.md)
* [EXPLAIN](https://docs.ditto.live/dql/explain.md), [PROFILE](https://docs.ditto.live/dql/profile.md), and [ADVISE](https://docs.ditto.live/dql/advise.md)
* [Indexing](https://docs.ditto.live/dql/indexing.md)
* [Virtual collections](https://docs.ditto.live/dql/virtual-collections.md)
* [Capturing Support Bundles](https://docs.ditto.live/sdk/latest/deployment/support-bundles.md)


## Related topics

- [GCP Setup Guide for Ditto BYOC](https://docs.ditto.live/cloud/public-cloud/gcp.md)
- [React Native](https://docs.ditto.live/sdk/latest/install-guides/react-native.md)
- [AWS Setup Guide for Ditto BYOC](https://docs.ditto.live/cloud/public-cloud/aws.md)
