> For the complete documentation index, see [llms.txt](https://docs.gitloom.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gitloom.cloud/documentation/cli.md). Agents can also search and read this documentation through its [MCP server](https://docs.gitloom.cloud/~gitbook/mcp).

# CLI

The gitloom binary — memory on your own machine, and an MCP server for your editor.

The CLI keeps memory in a git repository on your machine. Same engine as the hosted API, no network on the read path, and every operation is also available to an assistant over MCP.

### Install

```bash
curl -fsSL https://gitloom.cloud/install.sh | sh   # current: 0.5.0
```

One static binary, no runtime dependency. The installer verifies a checksum and puts it in `/usr/local/bin` if that is writable, `~/.local/bin` otherwise — override with `GITLOOM_PREFIX`.

Or take an archive directly from `https://gitloom.cloud/dl/`: builds exist for macOS (Apple silicon and Intel), Linux (x86-64 and arm64) and Windows, with `SHA256SUMS` alongside them.

:::note\[macOS quarantine] The binaries are not code-signed yet. A browser download will be quarantined — `xattr -d com.apple.quarantine /path/to/gitloom` clears it. The `curl | sh` route is normally exempt. :::

The local CLI is free. It needs no account, no key and no network: install it and run `gitloom init`.

### Which memory?

You will have more than one — personal, per-project, a scratch one. A command resolves its memory in this order, and `gitloom repo where` tells you which and why:

1. `--repo <path>`
2. `GITLOOM_REPO`
3. a memory at or above the working directory — the way `git` finds a repository
4. the one selected with `gitloom repo use`

```bash
gitloom init ~/memories/work        # creates, registers and selects it
gitloom init ~/memories/personal
gitloom repo list
#   personal  ~/memories/personal
# * work      ~/memories/work

gitloom repo use personal           # change the default
gitloom repo where                  # which one would this command use?
```

Standing anywhere inside a memory selects it, so a project that keeps its memory alongside the code needs no flags and no configuration.

:::note\[A wrong path is an error, not a new memory] Earlier versions created a repository wherever `--repo` pointed. That turned a typo into an empty memory in a surprising place, with no sign anything was wrong. A path that is not a memory is now refused, and `gitloom init` is the only thing that creates one. :::

### Writing and reading

```bash
# store a memory (body on stdin)
echo "Maya moved to Lisbon in March 2026." |
  gitloom write -p facts/people/maya.md --tags person -m "maya moved"

# ranked search over structure and full text
gitloom search "where does maya live"

# one memory, or one section of one
gitloom get facts/people/maya.md
gitloom section facts/people/maya.md#housing
```

Every command takes `--json` when you want to pipe it somewhere.

#### Dates and tags

A memory has three times. `occurred` is when the thing it describes happened. Only you know that, so `write` takes it. `created` and `updated` are when the memory was added to the repository and when it last changed. Without `--occurred-at`, a note about last March is dated today, and a search over March misses it.

```bash
echo "Signed the lease for the Indiranagar flat." |
  gitloom write -p facts/home/lease.md --tags home,lease --occurred-at 2026-03-05

echo "Flew to Tokyo." |
  gitloom write -p facts/travel/tokyo.md --tags trip \
    --occurred-at "2026-05-14 19:30" --tz Asia/Kolkata
```

`--occurred-at` takes epoch seconds, RFC 3339, or a date or datetime without an offset. A date alone is that calendar day wherever you are. A datetime without an offset is read in `--tz`, an IANA zone (default UTC). A memory written without `--occurred-at` counts as happening when it was written.

`search` narrows by tag and by time:

```bash
gitloom search "lease" --tag home --tag lease    # every --tag must match
gitloom search --tag trip --time-field occurred \
  --since 2026-05-01 --until 2026-05-31 --tz Asia/Kolkata
```

`--since` and `--until` bound the time named by `--time-field`: `occurred`, `created`, or `updated` (the default). They take epoch seconds, RFC 3339, or a date or datetime without an offset, read in `--tz`. A date in `--since` starts at that day's midnight, and a date in `--until` includes the whole day.

With no query and at least one filter (`--tag`, `--tier`, `--path-prefix`, `--since` or `--until`), `search` doesn't rank anything. It lists every memory the filters match, newest first by `--time-field`, each with a score of 1, so the second command above lists May's trips, latest first. With no query and no filter, it lists what changed most recently.

The [MCP server](#mcp-server) takes the same parameters, because its tools are generated from the same operations. `remember` takes `occurred_at`, `tz` and `tags`, and `search` takes `tags`, `since`, `until`, `time_field` and `tz`. Its `search` with filters and an empty `query` lists the same way.

### Navigating instead of retrieving

A memory's `##` headers are indexed as their own nodes, which makes the store a navigable table of contents rather than a pile of files. That is the PageIndex loop: descend the tree, then pull only the section you decided you wanted.

```bash
gitloom tree                       # whole table of contents
gitloom tree facts/db --depth 2    # one subtree
gitloom section facts/db/replication.md#failover
```

It matters at scale. Retrieving whole documents and hoping the answer is inside them costs context and buries the sentence you needed; descending to a section costs two cheap calls.

### Following relationships

Memories link to each other with `[[wikilinks]]` and labelled relations.

```bash
gitloom related facts/people/maya.md
gitloom related facts/people/maya.md --label spouse
gitloom related facts/db/replication.md --direction in --depth 2
```

`--direction in` finds what points *at* a memory — the question "what else depends on this?" that a search cannot answer. Depth beyond 1 pulls a cluster rather than a neighbour list; useful deliberately, expensive as a habit.

### Semantic search

Semantic search only sees memories whose retrieval cues have been embedded. Writing a memory queues its cues; draining that queue is explicit:

```bash
gitloom embed --stats     # how much is covered
gitloom embed             # embed what is pending
```

### Querying the index directly

The index is a SQLite database derived entirely from git — nodes, the section tree, an FTS5 table, cue vectors, the link graph. `gitloom rebuild` recreates it from scratch, so reading it is safe and writing to it is refused by the database itself.

```bash
gitloom index stats
gitloom index schema nodes
gitloom index query "SELECT tier, count(*) FROM nodes WHERE kind='file' GROUP BY tier"
```

:::note\[Read-only is enforced, not checked] The connection is opened in SQLite's read-only mode. Matching on the word `INSERT` would be trivially defeated and would give false comfort. :::

### Ingestion and answering

`ingest` turns conversations into memories: it extracts what is durable, places it in a tier, folds it into an existing memory where it updates one rather than repeating it, and attaches retrieval cues.

```bash
gitloom ingest sessions.json
cat chat.jsonl | gitloom ingest --provider openai --model gpt-5
```

Input is a JSON array of sessions, or one per line:

```json
{"id":"s1","date":"2026-03-04T10:00:00Z","turns":[
  {"role":"user","content":"I moved to Lisbon"},
  {"role":"assistant","content":"How is it?"}]}
```

`answer` retrieves and has a model write the sentence:

```bash
gitloom answer "where does Maya live?" --evidence
```

Both need a model, and both use **your** provider key — `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and so on, or `--base-url` for a local server. Inference is between you and your provider; GitLoom never sees it.

### MCP server

Every operation above is exposed to an assistant over the Model Context Protocol. The tools are generated from the same definitions the CLI dispatches through, so the two cannot drift apart. See [MCP](https://docs.gitloom.cloud/documentation/mcp.md) for the full picture, including the hosted server for a namespace instead of a local repository.

```bash
gitloom mcp --repo ~/memory              # stdio: what editors launch
gitloom mcp --read-only                  # search and recall, no writes
gitloom mcp --http 127.0.0.1:7000 --token "$(openssl rand -hex 16)"
```

#### Connecting an agent

`gitloom install` writes the configuration in each host's own shape:

```bash
gitloom install claude-code      # print it
gitloom install codex --write    # write it
gitloom install opencode --project
```

Supported: `claude-code`, `openclaw`, `opencode`, `codex`, `hermes`. All of them speak MCP, so there is no plugin to install — GitLoom already serves the protocol and this just points them at it.

To use a hosted namespace instead of a memory on this machine, add `--cloud`. That points the host at [`@gitloomhq/mcp`](https://www.npmjs.com/package/@gitloomhq/mcp) via `npx`, which needs `GITLOOM_API_KEY` and no local repository at all:

```bash
export GITLOOM_API_KEY=gl_live_...
gitloom install claude-code --cloud --write
```

Claude Desktop, in `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "gitloom": {
      "command": "gitloom",
      "args": ["mcp", "--repo", "/absolute/path/to/memory"]
    }
  }
}
```

:::caution\[Do not serve this to a network without a token] The tools include `remember`, which commits, and `index_query`, which reads everything. Binding a public address without `--token` is refused outright. :::

Model-driven tools (`ingest`, `answer`) appear only when a model is configured via `GITLOOM_MODEL` and a provider key, so a client listing tools sees what will actually work rather than operations that fail on every call.

### Working with the cloud

The local CLI and the hosted API are separate memories. `gitloom cloud` reaches the hosted one, authenticated with an API key in `GITLOOM_API_KEY`. The local commands need neither a key nor an account.

```bash
gitloom cloud whoami
gitloom cloud namespaces --create staging
gitloom cloud recall "where does maya live" --namespace staging
gitloom cloud push --namespace staging --dry-run
```

`push` uploads finished memories as they are — ingestion is not re-run, no model is called, and the text you curated locally is what lands.

### Environment

| Variable           | Purpose                                                         |
| ------------------ | --------------------------------------------------------------- |
| `GITLOOM_API_KEY`  | API key for `gitloom cloud`                                     |
| `GITLOOM_MODEL`    | model for `ingest`, `answer`, and the MCP tools that need one   |
| `GITLOOM_PROVIDER` | provider name (default `anthropic`)                             |
| `GITLOOM_BASE_URL` | OpenAI-compatible endpoint, overrides the provider              |
| `GITLOOM_API`      | API base URL, for pointing at a different deployment            |
| `GITLOOM_REPO`     | which memory to use, when not passing `--repo`                  |
| `GITLOOM_HOME`     | where the registry of memories lives (default: your config dir) |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.gitloom.cloud/documentation/cli.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
