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

# Initialize a workspace

> Bootstrap a new workspace from the terminal with the guided onboarding wizard.

Flags and arguments below are the contract as the binary states it. The global flags (`--json`, `--timeout`, …) apply here too and are documented on [Global flags](https://octolens.com/docs/cli/contract/global-flags.md). Error codes are a workspace-global contract, not a per-command one — the taxonomy, and how to read a code that is not in it, is on [The error envelope](https://octolens.com/docs/cli/contract/error-envelope.md).

## `octolens init`

Guided onboarding: company profile, keywords, filters, and your first feed

Headless (`--json`, or no TTY) it never prompts: it reports the onboarding plan and exits `0` whether or not steps remain — read `fullyOnboarded` and `steps[].done` for what is left, never the exit code.

**Examples**

```bash theme={null}
octolens init
octolens init --json
```

**Returns**

With `--json`, stdout carries one JSON document with these fields.

| Field | Type | Description |
| - | - | - |
| `interactive` | boolean | Always `false` in `--json`/headless mode — no prompts were opened; the payload is the plan. |
| `fullyOnboarded` | boolean | `true` when every onboarding step is satisfied. The exit code stays `0` either way — branch on this field. |
| `steps` | object\[] | The onboarding steps, in journey order. |
| `steps[].id` | enum: `company`, `keywords`, `filters`, `feed` | Stable step identifier. |
| `steps[].title` | string | Imperative step title. |
| `steps[].done` | boolean | Whether the observable workspace state satisfies this step. |
| `steps[].status` | string | One-line description of the current state. |
| `steps[].commands` | string\[] | The exact command(s) a non-interactive caller runs to complete the step. |
| `onboarding` | object \| null | The `octolens onboard` setup when this workspace has one, else `null` (additive; never affects the exit code or the other fields). On a terminal, `init` hands an unfinished Sonar setup to `octolens onboard`. |
| `onboarding.step` | enum: `account`, `website`, `keywords`, `mentions`, `feeds`, `slack`, `mcp`, `complete` | The setup's current step (`onboard status`'s `step`). |
| `onboarding.status` | enum: `needs_input`, `running`, `needs_human`, `pending_review`, `done` | The setup's status (`onboard status`'s `status`). |
| `onboarding.next` | object \| null | `onboard status`'s `nextAction` (`kind`, `command`, `argv`, …): the move that continues the setup; `null` once it is done. |

A step may additionally carry a non-gating `tip` (`{status, commands}`) naming optional follow-up state (e.g. pending AI keyword suggestions); tips never affect `fullyOnboarded`.

Without `--json`: A terminal walks the pending steps interactively and prints a closing summary.

> [accordion] Example output
>
> ```json theme={null}
> {
>   "interactive": false,
>   "fullyOnboarded": false,
>   "steps": [
>     {
>       "id": "company",
>       "title": "Review your company profile",
>       "done": true,
>       "status": "Profile filled from acme.com.",
>       "commands": [
>         "octolens company get"
>       ]
>     },
>     {
>       "id": "keywords",
>       "title": "Track your first keywords",
>       "done": false,
>       "status": "No keywords tracked yet.",
>       "commands": [
>         "octolens keywords add --term 'acme corp'"
>       ]
>     }
>   ],
>   "onboarding": {
>     "step": "keywords",
>     "status": "needs_input",
>     "next": {
>       "kind": "decide",
>       "command": "octolens onboard keywords --confirm --json",
>       "argv": [
>         "onboard",
>         "keywords",
>         "--confirm",
>         "--json"
>       ],
>       "default": true,
>       "humanPrompt": "Track these 5 keywords? This creates your workspace.",
>       "retryAfterSeconds": null,
>       "url": null
>     }
>   }
> }
> ```

**Exit codes** — `0` OK · `1` UNEXPECTED · `2` USAGE · `8` CANCELLED. The full map is on [Exit codes](https://octolens.com/docs/cli/contract/exit-codes.md).

## `octolens mcp connect`

Connect Claude Code, Cursor or Codex to Octolens's MCP server: write its MCP config (the tool signs in to Octolens on first use)

**Arguments**

| Argument | Type | Required | Description |
| - | - | - | - |
| `CLIENT` | `enum` | optional | The tool: claude-code, cursor, codex, or print (show the setup to paste) |

**Flags**

| Flag | Type | Required (headless) | Description |
| - | - | - | - |
| `--scope` | enum: `user`, `project` | no | Where the config goes: user (every project, the default) or project (this directory only; not for Codex) |
| `--yes` | `boolean` | no | Write the tool's config without a prompt (required headless for claude-code, cursor, codex) |

**Examples**

```bash theme={null}
octolens mcp connect
octolens mcp connect claude-code --yes
octolens mcp connect cursor --scope project --yes --json
octolens mcp connect print --json
```

**Returns**

With `--json`, stdout carries one JSON document with these fields.

| Field | Type | Description |
| - | - | - |
| `client` | enum: `claude-code`, `cursor`, `codex`, `print` | The tool connected. |
| `endpoint` | string | The MCP v2 server written (`<origin>/api/mcp/v2`). |
| `auth` | string | Always `oauth`: the tool signs in to Octolens on first use; no key is created. |
| `path` | string \| null | The config file written (cursor, codex); null for claude-code and print. |
| `backupPath` | string \| null | The `.bak` kept before the first write. |
| `command` | string \| null | The `claude mcp add` that ran (claude-code). |
| `snippet` | string \| null | The `mcpServers` snippet to paste (print). |

Re-running leaves exactly one `octolens` entry (an old key-based `/api/mcp` entry is replaced). Writing a tool's config headless needs `--yes` (exit 2); a failed write exits 9 `MCP_CONFIG_WRITE_FAILED`.

Without `--json`: A terminal says what was written, how the tool signs in, and suggests a first question to ask.

Example output:

```json theme={null}
{
  "client": "cursor",
  "endpoint": "https://app.octolens.com/api/mcp/v2",
  "auth": "oauth",
  "path": "/home/jane/.cursor/mcp.json",
  "backupPath": "/home/jane/.cursor/mcp.json.bak",
  "command": null,
  "snippet": null
}
```

**Exit codes** — `0` OK · `1` UNEXPECTED · `2` USAGE · `8` CANCELLED. The full map is on [Exit codes](https://octolens.com/docs/cli/contract/exit-codes.md).


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