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

# CLI Reference

> Command-line interface for Mengram — setup, MCP server, data import, hooks, and rules generation.

## Installation

```bash theme={null}
pip install mengram-ai
```

## Commands

### mengram setup

One command does the whole onboarding: creates your account, saves the API key, installs Claude Code hooks, **auto-detects and configures your other AI tools** (Cursor, Claude Desktop, Windsurf), **imports your existing Claude Code history** so memory is useful from minute one, and verifies the round-trip.

```bash theme={null}
mengram setup
mengram setup --email you@example.com    # skip email prompt
mengram setup --no-hooks                 # skip Claude Code hook install
mengram setup --no-tools                 # skip Cursor/Claude Desktop/Windsurf MCP config
mengram setup --no-import                # skip Claude Code history import
mengram setup --no-verify                # skip the round-trip check
```

| Flag | Description |
| - | - |
| `--email` | Email address (skip interactive prompt) |
| `--key` | API key (skip signup, just save + configure) |
| `--no-hooks` | Skip Claude Code hook installation |
| `--no-tools` | Skip auto-configuring detected Cursor / Claude Desktop / Windsurf |
| `--no-import` | Skip importing local Claude Code session history |
| `--no-verify` | Skip the end-to-end verification |

Detected tool configs are merged safely (existing servers preserved, a backup is written, unparseable files are never overwritten). If you already have a key, it asks whether to reconfigure.

### mengram weekly

Your AI's memory, summarized for the past 7 days — including the one metric no other tool shows: **repeated mistakes prevented** (procedures with past failures that your memory recalled this week, each with the date you last got bitten by it).

```bash theme={null}
mengram weekly            # print the report
mengram weekly --share    # also print + copy a ready-to-post summary
mengram weekly --no-color # plain output (for piping)
```

The report auto-shows once a week at the start of a Claude Code session (via the SessionStart hook) — shown to you, never added to the model's context. Pass `--no-weekly` to `mengram auto-context` to disable.

```
┌────────────────────────────────────────────────────────┐
│  REPEATED MISTAKES PREVENTED                    3      │
│                                                        │
│  · psycopg2 pool deadlock       last bitten: Apr 12    │
│  · wrong usage table (api_calls last bitten: Jul 20    │
│  · npx guess vs mengram server  last bitten: Jun 30    │
└────────────────────────────────────────────────────────┘
```

### mengram init

Interactive setup — creates config, vault, and Claude Desktop MCP integration.

```bash theme={null}
mengram init
mengram init --provider openai --api-key sk-...
mengram init --mcp-only   # only setup MCP integration
```

| Flag | Description |
| - | - |
| `--provider` | LLM provider: `openai`, `anthropic`, `ollama` |
| `--api-key` | API key for the provider |
| `--vault` | Custom vault path |
| `--home` | Mengram home directory (default: `~/.mengram`) |
| `--no-mcp` | Skip Claude Desktop MCP setup |
| `--mcp-only` | Only setup MCP (config must exist) |

### mengram server

Start the MCP server for Claude Desktop, Cursor, or Windsurf.

```bash theme={null}
mengram server              # local mode (your own LLM keys)
mengram server --cloud      # cloud mode (uses Mengram API)
```

| Flag | Description |
| - | - |
| `--config` | Config path (default: `~/.mengram/config.yaml`) |
| `--cloud` | Use cloud API instead of local vault |

### mengram status

Check setup status — config, vault, vector index, Claude Desktop integration.

```bash theme={null}
mengram status
```

### mengram stats

Show vault statistics — entity counts, fact counts, vector index info.

```bash theme={null}
mengram stats
```

### mengram rules

Generate a CLAUDE.md, .cursorrules, or .windsurfrules file from your cloud memory.

```bash theme={null}
mengram rules                          # default: CLAUDE.md format
mengram rules --format cursorrules     # Cursor format
mengram rules --format windsurf        # Windsurf format
mengram rules --force                  # regenerate (bypass cache)
```

| Flag | Description |
| - | - |
| `--format` | Output format: `claude_md`, `cursorrules`, `windsurf` |
| `--force` | Regenerate (bypass cache) |

### mengram hook

Manage the memory hooks — session context, auto-recall, auto-save, policy gate, run outcomes, and the compaction checkpoint. See [Claude Code Integration](/claude-code) for details.

```bash theme={null}
mengram hook install              # Claude Code: install all six hooks
mengram hook install --every 5    # save every 5th response
mengram hook install --codex      # Codex: the same hooks in ~/.codex/hooks.json
mengram hook install --cursor     # Cursor: the same hooks in ~/.cursor/hooks.json
mengram hook status               # check hook status (both tools)
mengram hook uninstall            # remove the hooks from both
```

### mengram resume

Where the task in this repository stands. The hooks (Claude Code, Codex, Cursor) write a task card when an agent stops — keyed by `git remote` + branch, so another session, another agent in another worktree of that branch or another machine finds it — and inject it at the next session start, saying whether the code has moved since the last check.

A session on a branch with no card of its own — a fresh Orca worktree, say — gets one line saying which cards exist, not another branch's task, which is usually another agent's. The agent's draft of the task carries over only to the session that continues it; a task you confirmed carries over to any.

```bash theme={null}
mengram resume            # print the card: task, done, remaining, last check + commit, files, sources
mengram resume --open     # local page: confirm or correct the card, pick another task, copy the context
mengram resume --json     # the card as JSON
mengram resume --any-age  # show it however old (default: last 14 days)
```

Task / done / remaining are drafted by one model call and marked as the agent's draft until you confirm them on the page; confirmed text is never redrafted. Files, commands, the last test result and the commit it ran on are recorded verbatim. Cards live in `~/.mengram/resume/` and need no account; only the draft uses a model.

### mengram try

Zero-account, local-only preview of what Mengram memory would know. Scans your Claude Code history **on-device** — nothing is uploaded, no API key needed:

```bash theme={null}
mengram try
```

Shows your projects, tech stack, and detected workflow patterns (commit→push→deploy, test→fix→re-test, ...) drawn from your own session history, then the two commands that make it permanent.

### mengram import

Import existing data into memory.

#### mengram import claude-code

Import your local Claude Code session transcripts (`~/.claude/projects`) into cloud memory — memory knows your projects from minute one instead of starting empty.

```bash theme={null}
mengram import claude-code                      # 20 most recent sessions
mengram import claude-code --last 50            # more history
mengram import claude-code --project myapp      # only one project
mengram import claude-code --yes                # skip the confirmation prompt
```

* **Secrets are redacted** before storage — on import (client-side) and again server-side in the extraction pipeline, so keys/tokens/JWTs pasted into a conversation never reach the model or get stored (→ `[REDACTED]`)
* Each session counts as **one add operation** against your plan's monthly quota
* Re-runs skip already-imported sessions; `--reimport` forces a fresh pass

#### mengram import chatgpt

```bash theme={null}
mengram import chatgpt ~/Downloads/chatgpt-export.zip
mengram import chatgpt export.zip --cloud   # use cloud API
```

#### mengram import obsidian

```bash theme={null}
mengram import obsidian ~/Documents/MyVault
mengram import obsidian vault/ --cloud --chunk-chars 4000
```

#### mengram import files

```bash theme={null}
mengram import files notes.md journal.txt research.md
mengram import files *.md --cloud
```

### mengram api

Start a local REST API server.

```bash theme={null}
mengram api                    # default: 0.0.0.0:8420
mengram api --port 9000        # custom port
```

### mengram web

Start the Web UI with chat and knowledge graph visualization.

```bash theme={null}
mengram web                    # opens browser automatically
mengram web --port 9000        # custom port
mengram web --no-open          # don't open browser
```

## Environment Variables

| Variable | Description |
| - | - |
| `MENGRAM_API_KEY` | Cloud API key (starts with `om-`) |
| `MENGRAM_URL` | Custom API base URL |
| `MENGRAM_USER_ID` | Default user\_id |


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