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

# CLI reference

> Every 9p command, slash command, and configuration file.

## Commands

| Command           | What it does                                                    |
| ----------------- | --------------------------------------------------------------- |
| `9p`              | Interactive session. Full terminal UI in a TTY, REPL otherwise. |
| `9p --plain`      | Force the bare REPL — use this in CI or over a pipe.            |
| `9p login`        | Sign in via the browser. `--paste` for headless machines.       |
| `9p logout`       | Revoke the token server-side and clear credentials.             |
| `9p init`         | Set up project memory: a `9P.md` or an Obsidian-style vault.    |
| `9p map`          | Write codebase wiki notes into the vault's `graph/`.            |
| `9p serve [port]` | Local browser session on `127.0.0.1` (default `4310`).          |

## Slash commands

Available inside a session:

| Command                                       | What it does                                                   |
| --------------------------------------------- | -------------------------------------------------------------- |
| `/help`                                       | List commands.                                                 |
| `/models`                                     | Catalog with tiers, burn rate, and plan locks.                 |
| `/model [id\|auto]`                           | Show, pin, or unpin the model. `/model auto` restores routing. |
| `/bias [economy\|balanced\|quality]`          | Tune Auto routing. Persists to `~/.9p/config.json`.            |
| `/mode [default\|accept-edits\|plan\|bypass]` | Change the permission mode.                                    |
| `/skills`                                     | Reload and list available skills.                              |
| `/<skill> [args]`                             | Run a skill by name.                                           |
| `/compact`                                    | Summarise older history now. See [Context](/context).          |
| `/clear`                                      | Reset context, keep the session.                               |
| `/usage`                                      | Calls, tokens, and the current context estimate.               |
| `/exit`                                       | Quit.                                                          |

## Tools the agent has

| Tool                   | Kind   | Gated by default                        |
| ---------------------- | ------ | --------------------------------------- |
| `read`, `glob`, `grep` | read   | No                                      |
| `write`, `edit`        | write  | Yes                                     |
| `bash`                 | exec   | Yes                                     |
| `task`                 | exec   | Yes — spawns a [sub-agent](/sub-agents) |
| `ask_user`             | —      | No, it's a question to you              |
| MCP tools              | varies | Per [MCP](/mcp) server                  |

`write` and `edit` refuse to touch a file the agent has not read first, so it
can't blindly overwrite something it never looked at.

## Files 9p reads

| Path                               | Purpose                                           |
| ---------------------------------- | ------------------------------------------------- |
| `~/.9p/auth.json`                  | Credentials (`0600`).                             |
| `~/.9p/config.json`                | Preferences, e.g. `autoBias`.                     |
| `~/.9p/9P.md`                      | Global standing instructions.                     |
| `./9P.md`                          | Project standing instructions (wins over global). |
| `~/.9p/skills/`, `./.9p/skills/`   | [Skills](/skills) (project wins on name clash).   |
| `~/.9p/mcp.json`, `./.9p/mcp.json` | [MCP servers](/mcp) (project wins per name).      |
| `./.9p/config.json`                | Project config, e.g. the vault path.              |

## Environment variables

| Variable             | Purpose                                     |
| -------------------- | ------------------------------------------- |
| `NINEP_API_URL`      | Platform API base URL.                      |
| `NINEP_TOKEN`        | Platform access token (not auto-refreshed). |
| `OPENROUTER_API_KEY` | BYOK key.                                   |
| `NINEP_MODEL`        | Pin a model, bypassing Auto.                |
| `NINEP_AUTO_BIAS`    | `economy`, `balanced`, or `quality`.        |
| `NINEP_PORT`         | Default port for `9p serve`.                |

## Exit codes

| Code | Meaning                                                   |
| ---- | --------------------------------------------------------- |
| `0`  | Success.                                                  |
| `1`  | Auth failure, unknown command, or an unrecoverable error. |

## Non-interactive use

```bash theme={null}
echo "run the test suite and summarise failures" | 9p --plain
```

For CI, authenticate with `NINEP_API_URL` + `NINEP_TOKEN` and consider
`/mode plan` semantics by keeping tasks read-only, or run with a scoped
throwaway token.
