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

# CLI Command Reference

> Every corestory command and option.

Run `corestory help <command>` or `corestory <command> --help` for the same information in your terminal. Every command except `setup` and `update` works on the corpus in the current folder, so run them from the repository root.

| Command | What it does |
| - | - |
| [`setup`](#setup) | Accept the terms, choose telemetry, and configure models for this machine |
| [`update`](#update) | Check for or install CLI updates |
| [`init`](#init) | Create a corpus in the current folder |
| [`ingest`](#ingest) | Build a new snapshot of the corpus |
| [`list`](#list) | List the corpus's snapshots |
| [`summary`](#summary) | Show the selected snapshot |
| [`delete`](#delete) | Delete the corpus and all its snapshots |
| [`mcp`](#mcp) | Start the local MCP server for coding agents |
| [`search`](#search) | Search code and rules by meaning |
| [`rules-for`](#rules-for) | List the rules with evidence in a file or line range |
| [`entity show`](#entity-show) | Show one entity in detail |
| [`entity connections`](#entity-connections) | List an entity's links to other entities |
| [`explore`](#explore) | Browse the snapshot in an interactive terminal view |

***

## Machine setup

### setup

Accept the Terms of Use and Privacy Policy, choose whether to share anonymous usage data, and configure model providers. Settings are saved to `~/.config/corestory/config.toml` and apply to every repository on the machine. Setup is interactive, and other commands do not run until it is complete.

```bash theme={null}
corestory setup [--models] [--telemetry]
```

| Option | Description |
| - | - |
| `--models` | Open the model editor to add or change providers and models. This is also what plain `setup` does. |
| `--telemetry` | Ask again whether to share anonymous usage data. |

### update

Check for and install new CLI releases. Every release's signature is verified before installation, even with `--force`.

```bash theme={null}
corestory update [--check] [--yes] [--force] [--channel stable|preview]
```

| Option | Description |
| - | - |
| `--check` | Compare the installed version with the latest release, without downloading anything. |
| `--yes` | Install without asking for confirmation. |
| `--force` | Reinstall even if the published version is the same as or older than the installed one. |
| `--channel <CHANNEL>` | Release channel: `stable` (default) or `preview`. |
| `--manifest-url <URL>` | Use a different release manifest. Intended for testing. |

```text theme={null}
$ corestory update --check
Manifest: https://github.com/CoreStory-Frontier/release-dist/releases/latest/download/cli.json
Channel: stable
Installed package version: 0.1.0-alpha.1
Published CLI release: 0.1.0-alpha.1
Already up to date for this channel.
```

***

## Corpus and snapshots

### init

Create a corpus in the current folder. This creates `.corestory/` and records the corpus settings. It does not read your files or call any models.

```bash theme={null}
corestory init [--corpus-name <NAME>] [--source-kind <KIND>]
```

| Option | Description |
| - | - |
| `-n`, `--corpus-name <NAME>` | Optional name for the corpus. |
| `--source-kind <KIND>` | Where the source comes from. Defaults to `git` inside a Git repository and `file_upload` otherwise. |

```text theme={null}
$ corestory init
CorpusID 01a22cdb-bd58-7573-96f3-45c144e71bb1
```

### ingest

Read the repository and build a new snapshot. By default it reads the working tree as it is now, including uncommitted changes. This command calls your model provider, so it costs money on your key. Cost and time grow with the size of the repository.

Aliases: `build`, `b`.

```bash theme={null}
corestory ingest [--branch <NAME> | --tag <NAME> | --sha <SHA>] [--target <TARGET>...] [--display-name <NAME>]
```

| Option | Description |
| - | - |
| `--branch <NAME>` | Ingest the tip of this branch instead of the working tree. |
| `--tag <NAME>` | Ingest this tag instead of the working tree. |
| `--sha <SHA>` | Ingest this commit instead of the working tree. |
| `--display-name <NAME>` | Label the snapshot. Without one, the snapshot is labeled with the start of its content hash. |
| `-t`, `--target <TARGET>` | Build only part of the snapshot. Repeat to choose several. Defaults to `all`. See below. |

**Targets.** Most people should use the default. Use targets to rebuild one part of a snapshot or to control model spend:

| Target | Builds |
| - | - |
| `full` | Everything |
| `languages` | Language detection and parsing |
| `embeddings` | Embeddings for search |
| `semantic` | All model-derived knowledge, including rules |
| `semantic:rules` | Business rules only |
| `semantic:actors` | Actors only |
| `semantic:features` | Features only |
| `semantic:entities` | Domain entities only |

```text theme={null}
$ corestory ingest --display-name "after loyalty change"
IngestID 01a22cdc-a67c-7456-b374-a8790228f367
```

### list

List the corpus's snapshots, newest first.

```bash theme={null}
corestory list [--limit <N>] [--asc]
```

| Option | Description |
| - | - |
| `--limit <N>` | Maximum number of snapshots to show. Default 100. |
| `--asc` | Show oldest first. |

```text theme={null}
$ corestory list
Snapshots
01a22cdc-a67f-7047-8515-0af0d0457ee2 after loyalty change (created@2026-11-30 14:29:47 UTC)
01a22cdb-bd76-74c0-a83d-3e7e1dc84c87 928769df71ff (created@2026-11-30 14:28:48 UTC)
```

### summary

Show the selected snapshot: its ID, label, creation time, and content hash.

```bash theme={null}
corestory summary
```

```text theme={null}
$ corestory summary
01a22cdc-a67f-7047-8515-0af0d0457ee2 after loyalty change (created@2026-11-30 14:29:47 UTC) sha256:f3c6a9e3dd39e5f46ba440390776344a7810398ecb83222f635e8a041b1cfe03
```

### delete

Delete the corpus and all of its snapshots. Aliases: `rm`, `drop`.

```bash theme={null}
corestory delete
```

> [!WARNING]
>
> `delete` does not ask for confirmation. Snapshots cannot be recovered afterward, and rebuilding them means paying for a new ingest.

***

## Agents

### mcp

Start the local MCP server over standard input and output. Coding agents run this command themselves, so you rarely run it by hand. It serves the corpus in the folder it starts in. See [Connect Your Agent](https://docs.corestory.ai/cli/connect-your-agent.md) for setup and the list of tools.

```bash theme={null}
corestory mcp [--no-instructions]
```

| Option | Description |
| - | - |
| `--no-instructions` | Leave out the workflow guidance the server normally sends to the agent when it connects. |

***

## Exploring a snapshot

These commands read the selected snapshot. They do the same lookups as the MCP tools, so you can check what your agent sees. Add `--json` where available to get the same JSON the MCP tools return.

Search results and graph lookups return **entities**. Two kinds come up most often:

* **Chunks** (`plot:Chunk`): a section of a source file
* **Rules** (`sao:Rule`): a business rule the code enforces, with its summary and evidence

Each entity has an ID that you can pass to `entity show` and `entity connections`.

### search

Find code and rules related to a description, ranked by meaning. The query is embedded with your embedding model, so it makes a small model call.

```bash theme={null}
corestory search [--kind <KIND>] [--limit <N>] [--offset <N>] [--json] <QUERY>
```

| Option | Description |
| - | - |
| `--kind <KIND>` | Return only `plot:Chunk` (code) or `sao:Rule` (rules). |
| `--limit <N>` | Number of results, 1–100. Default 5. |
| `--offset <N>` | Skip this many results, to get the next page. Default 0. |
| `--json` | Print JSON in the same shape as the MCP `search` tool. |

```text theme={null}
$ corestory search "free shipping threshold" --limit 2
entity:sao@2_1:Rule — us-orders-at-threshold-ship-free
  entity: 01a22cdc-55a6-7368-b29e-4864b55a74ae  score=0.637
  evidence:
    src/orders.py:9–10
    src/orders.py:3
  summary:
    Shipping cost is 0.0 when the country is "US" and the subtotal is greater than
    or equal to the free-shipping threshold of 50.00.

entity:sao@2_1:Rule — us-orders-below-free-shipping-threshold-pay-flat-rate
  entity: 01a22cdc-55aa-7395-8bb8-97c902153f7f  score=0.590
  ...

More matches available; repeat with --limit 2 --offset 2.
```

### rules-for

List the rules whose evidence falls in a file, or in a range of lines within it. Use this before you change a file to see what it enforces. This is an exact lookup, so it makes no model calls.

```bash theme={null}
corestory rules-for [--start-line <N>] [--end-line <N>] [--limit <N>] [--cursor <TOKEN>] [--json] <PATH>
```

| Option | Description |
| - | - |
| `<PATH>` | File path relative to the repository root, exactly as captured in the snapshot. |
| `--start-line <N>` | First line to include. Omit to start at the top of the file. |
| `--end-line <N>` | Last line to include. Omit to go to the end of the file. |
| `--limit <N>` | Rules per page, 1–100. Default 20. |
| `--cursor <TOKEN>` | Get the next page. Pass the token from the previous output, with the same path, lines, and limit. |
| `--json` | Print the JSON page, including its cursor. |

```text theme={null}
$ corestory rules-for src/orders.py --limit 3
01a22cdc-55a4-7301-ab56-c778cb1045c7  entity:sao@2_1:Rule · order-subtotal-must-be-positive
01a22cdc-55a6-7368-b29e-4864b55a74ae  entity:sao@2_1:Rule · us-orders-at-threshold-ship-free
01a22cdc-55aa-7395-8bb8-97c902153f7f  entity:sao@2_1:Rule · us-orders-below-free-shipping-threshold-pay-flat-rate

More Rules: repeat with --cursor <token> and the same path, bounds and limit.
```

> [!NOTE]
>
> An empty result does not prove that no rules apply. A rule can be evidenced in a different file, and extraction can miss rules. Read the code before concluding a file enforces nothing.

### entity show

Show one entity's details and source locations.

```bash theme={null}
corestory entity show [--include <FACTS>] [--facts-limit <N>] [--facts-cursor <TOKEN>] [--json] <ENTITY_ID>
```

| Option | Description |
| - | - |
| `--include <FACTS>` | Also show related facts, comma separated: `description`, `evidence`. For rules, `--include description,evidence` shows the rule's summary and the values it cites. |
| `--facts-limit <N>` | Related facts per page, 1–20. |
| `--facts-cursor <TOKEN>` | Get the next page of related facts. |
| `--json` | Print JSON in the same shape as the MCP `entity` tool. |

```text theme={null}
$ corestory entity show 01a22cdc-55af-75e8-aa13-ed748e7a6713 --include description,evidence
entity: 01a22cdc-55af-75e8-aa13-ed748e7a6713
kind: entity:sao@2_1:Rule
name: loyalty-discount-applies-only-to-subtotal
...
fact: plot:has_summary/v1
kind: entity:plot@1:RuleSummary
payload:
{
  "text": "If loyalty_member is true, the discounted subtotal is calculated as ..."
}

fact: plot:has_evidence/v1
kind: entity:plot@1:RuleEvidence
payload:
{
  "values": [
    { "value_type": "number", "value": "0.10", "unit": "ratio", "role": "loyalty discount rate" },
    ...
```

### entity connections

List the links into and out of an entity: for a rule, its summary, its evidence, and the file content it was found in.

```bash theme={null}
corestory entity connections [--direction in|out|both] [--predicate <PREDICATE>...] [--limit <N>] [--cursor <TOKEN>] [--json] <ENTITY_ID>
```

| Option | Description |
| - | - |
| `--direction <DIR>` | `in`, `out`, or `both` (default). |
| `--predicate <PREDICATE>` | Show only this kind of link, written `namespace:term/vN`, for example `plot:has_evidence/v1`. Repeat to include several. |
| `--limit <N>` | Links per page, 1–100. Default 20. |
| `--cursor <TOKEN>` | Get the next page. |
| `--json` | Print JSON in the same shape as the MCP `connections` tool. |

```text theme={null}
$ corestory entity connections 01a22cdc-55af-75e8-aa13-ed748e7a6713
entity: 01a22cdc-55af-75e8-aa13-ed748e7a6713
kind: entity:sao@2_1:Rule
name: loyalty-discount-applies-only-to-subtotal

  ← plot:asserts/v1 ← 01a22cdc-55ae-7543-9ada-4911f31eb452
    entity:plot@1:RuleAssertion loyalty-discount-applies-only-to-subtotal

  → plot:has_summary/v1 → 01a22cdc-55af-75e8-aa13-ed757edc8e9b
    entity:plot@1:RuleSummary

  → plot:has_evidence/v1 → 01a22cdc-55af-75e8-aa13-ed76e7319ee2
    entity:plot@1:RuleEvidence

  ← plot:has_rule/v1 ← 01a22cdb-bd85-77f9-94ca-4fd1cac74c5e
    entity:plot@1:Content
```

### explore

Browse the snapshot in an interactive terminal view. It starts at an overview of the snapshot, a search, or one entity, and you move between results and connections from there.

```bash theme={null}
corestory explore [--entity <ENTITY_ID>] [--kind <KIND>] [--page-size <N>] [QUERY]
```

| Option | Description |
| - | - |
| `[QUERY]` | Start with this search instead of the overview. |
| `--entity <ENTITY_ID>` | Open this entity directly. Needs no embedding model. |
| `--kind <KIND>` | Limit searches to `plot:Chunk` or `sao:Rule`. |
| `--page-size <N>` | Results or connections per page, 1–100. Default 20. |

***

## Files and settings

| Location | What it holds |
| - | - |
| `.corestory/` in the repository | The corpus and all its snapshots, stored as a local database. Add it to `.gitignore`. |
| `~/.config/corestory/config.toml` | Model providers, keys, and model roles, shared by every repository on the machine. Written by `corestory setup`. |


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