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

# Init

> Use xerg init for the first local audit, understand what it detects, and know when to switch to direct commands.

`xerg init` is the default first-run path for the CLI.

> `init` is interactive. Use direct `doctor` / `audit` commands when you need non-interactive behavior or explicit flags immediately.

## What `xerg init` does

Run:

```bash theme={null}
npx @xerg/cli@latest init
```

`init`:

* checks the local OpenClaw, Hermes, and Claude Code defaults
* auto-selects the only detected runtime or asks you to choose when more than one is present
* runs the first audit with local snapshot persistence enabled
* prints the normal terminal summary
* tells you to use `audit --compare` after the next fix
* offers optional hosted follow-up with `connect` and `mcp-setup`

## Supported local runtimes

`init` covers local OpenClaw, Hermes, and Claude Code detection.

Current defaults:

* OpenClaw gateway logs: `/tmp/openclaw/openclaw-*.log`
* OpenClaw session transcripts: `~/.openclaw/agents/*/sessions/*.jsonl`
* Hermes v0.17+ state database: `~/.hermes/state.db` (preferred, read-only)
* Optional Hermes observer ledger: `~/.hermes/xerg/events/`; legacy files remain fallback inputs
* Claude Code session transcripts: `~/.claude/projects/`

Cursor usage CSVs remain a direct `doctor` / `audit --cursor-usage-csv` workflow rather than part of `init`.

## When to use `init` versus `audit`

Use `init` when:

* you are onboarding for the first time
* you want the CLI to choose between detected local runtimes
* you want a guided path from first audit to optional hosted setup

Use `audit` directly when:

* you need non-interactive behavior
* you already know the runtime
* you want JSON, Markdown, CI gates, or explicit path flags immediately
* you want remote OpenClaw audits over SSH or Railway

Examples:

```bash theme={null}
npx @xerg/cli@latest audit --runtime openclaw
npx @xerg/cli@latest audit --runtime hermes --json
npx @xerg/cli@latest audit --remote user@host
npx @xerg/cli@latest audit --railway
```

## What happens when no local data is found

`init` does not guess. It prints:

* the default local paths it checked (OpenClaw, Hermes, and Claude Code)
* explicit local-path commands for OpenClaw, Hermes, and Claude Code
* the Cursor usage CSV alternative (`audit --cursor-usage-csv ./usage.csv`)
* remote OpenClaw-only next steps:
  * `npx @xerg/cli@latest audit --remote user@host`
  * `npx @xerg/cli@latest audit --railway`

Remote SSH and Railway guidance are OpenClaw-only.

## What happens after a successful audit

After the first audit, `init` tells you to re-run:

```bash theme={null}
npx @xerg/cli@latest audit --compare
```

Then it offers optional hosted follow-up:

* `connect` for authentication and pushing the latest audit
* `mcp-setup` for generating hosted MCP config for Cursor, Claude Code, Codex, or another client

Hosted follow-up is optional. Local audits and compare remain available if you skip it.
