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

# Commands

> Reference for every studiograph CLI command, grouped by task.

All commands run as `studiograph <command>` from a workspace directory unless noted.

## Getting started

### init

Create a new workspace: a single Git repository at the root, a `.studiograph/` config directory, and a baseline commit.

```bash theme={null}
studiograph init <team-name> [directory]
```

The optional `directory` controls where the workspace is created; by default it's a new directory named after the team.

### clone

Clone a hosted workspace into a full local copy. Owner-oriented: it signs in with your email and password (the `STUDIOGRAPH_EMAIL` and `STUDIOGRAPH_PASSWORD` environment variables) and stores an `sg_` token in `~/.studiograph/user.json` for later `pull`/`push`.

```bash theme={null}
studiograph clone <server-url> [directory]
```

## Daily workflow

### pull

Fetch content and configuration from the server into the local checkout. If the local and remote copies have diverged, `pull` exits non-zero with a clear error — resolve manually. After pulling into a workspace that's being served, restart `serve`.

```bash theme={null}
studiograph pull [--remote <url>] [--token <token>]
```

* `--remote` (alias `--server`) — server URL to pull from
* `--token` — auth token; falls back to `STUDIOGRAPH_TOKEN`, then the stored token

### push

Send local content and configuration to the server. Same flags and divergence behavior as `pull`.

```bash theme={null}
studiograph push [--remote <url>] [--token <token>]
```

### commit

Commit local workspace changes to Git.

```bash theme={null}
studiograph commit [--message <message>] [--config]
```

* `--message` — commit message
* `--config` — also commit changes in the `.studiograph/` config directory

### about

Display or edit the workspace's `ABOUT.md` — the team profile the agent uses for context.

```bash theme={null}
studiograph about [-e|--edit] [-i|--interactive] [-s|--set <file>]
```

* `-e, --edit` — open `ABOUT.md` in `$EDITOR`
* `-i, --interactive` — step through each section interactively
* `-s, --set <file>` — replace `ABOUT.md` with the contents of a file

## Server

### serve

Start the server from the workspace directory. Defaults to port 8000 on host 0.0.0.0; if the port is busy, it auto-increments. Opens the web UI in a browser unless `STUDIOGRAPH_NO_OPEN=1` is set.

```bash theme={null}
studiograph serve [-p <port>] [-H <host>] [--verbose]
```

### deploy railway

Deploy the workspace to Railway. Auto-provisions `STUDIOGRAPH_JWT_SECRET` and `STUDIOGRAPH_MASTER_KEY`.

```bash theme={null}
studiograph deploy railway [-n <name>] [-p <project>] [-s <service-name>] [--provider <provider>] [--model <model>] [--api-key <key>]
```

* `-n, --name` — Railway project name (ignored when `--project` is given)
* `-p, --project` — existing Railway project ID or dashboard URL; adds the service to it instead of creating a new project
* `-s, --service-name` — Railway service name (defaults to the workspace name slug)
* `--provider`, `--model`, `--api-key` — AI provider configuration; skips the interactive prompts (`STUDIOGRAPH_DEPLOY_API_KEY` also works for the key)

### redeploy

Redeploy an existing Railway deployment, pinning the exact npm version currently installed.

```bash theme={null}
studiograph redeploy [project]
```

## Admin

Administrative commands live under `admin`. The old top-level `user`, `folder`, `secrets`, `settings`, and `audit` forms print a deprecation warning and will be dropped in a future release.

### admin token issue

Mint an `sg_` API token against a running server and store it for CLI use.

```bash theme={null}
studiograph admin token issue <server-url> [--email <email>] [--password <password>] [--name <name>]
```

Reads `STUDIOGRAPH_EMAIL` / `STUDIOGRAPH_PASSWORD` when the flags are omitted.

### admin user

Add or remove user accounts.

```bash theme={null}
studiograph admin user add [--role owner|member] [--if-empty]
studiograph admin user remove
```

* `--role` — `owner` or `member`
* `--if-empty` — only create the user when no users exist yet (used for first-boot provisioning)

### admin folder

Manage folders.

```bash theme={null}
studiograph admin folder <add|list|rename|remove>
```

* `remove --delete-files` — also delete the folder's files on disk

### admin secrets

Manage stored credentials in the encrypted secrets store.

```bash theme={null}
studiograph admin secrets <list|get|set|remove|test>
```

### admin settings

Read and write workspace settings.

```bash theme={null}
studiograph admin settings <list|get|set|clear|describe>
```

### admin audit

List audit records.

```bash theme={null}
studiograph admin audit list
```

### admin migrate

Bulk regex find-and-replace across the workspace's content files, producing one commit per folder. Refuses to run if anything targeted has uncommitted changes.

```bash theme={null}
studiograph admin migrate <regex> <replace> [--dry-run] [--also-rename-files] [--repos <folders>] [--commit-message <msg>]
```

* `--dry-run` — report matches without writing
* `--also-rename-files` — also rename files whose names match the regex
* `--repos` — limit to specific folders

### admin backup

Create a passphrase-wrapped `.sgbackup` bundle of the workspace.

```bash theme={null}
studiograph admin backup
```

### admin restore

Restore a workspace from a `.sgbackup` bundle.

```bash theme={null}
studiograph admin restore <bundle>
```

### admin transfer-ownership

Transfer workspace ownership to another user.

```bash theme={null}
studiograph admin transfer-ownership <email>
```

### admin audit-workspace

Audit the workspace for integrity problems.

```bash theme={null}
studiograph admin audit-workspace
```

### admin audit-orphan-attachments

Find attachments no entry references; `--apply` acts on the findings.

```bash theme={null}
studiograph admin audit-orphan-attachments [--apply]
```

## Integrations

### mcp

Run a stdio MCP server for AI clients that spawn subprocesses. Requires `STUDIOGRAPH_MCP_TOKEN`; proxies to the local server's `/mcp` endpoint and fails loudly on auth errors. See [Connect AI tools](/cli/mcp).

```bash theme={null}
studiograph mcp [workspace]
```

### connector

List or remove external connectors.

```bash theme={null}
studiograph connector <list|remove>
```

### r2

Configure Cloudflare R2 asset storage and move assets to it.

```bash theme={null}
studiograph r2 <setup|upload|sync|rewrite>
```

## Maintenance

### index

Rebuild the workspace index.

```bash theme={null}
studiograph index [--repo <folder>]
```

### lint

Check workspace content for problems.

```bash theme={null}
studiograph lint
```

### orphans

List orphaned entries; optionally delete them.

```bash theme={null}
studiograph orphans [--entity-types <types>] [--min-age <age>] [--repos <folders>] [--delete] [--dry-run]
```

### repair-folders

Detect and repair inconsistencies in folder records.

```bash theme={null}
studiograph repair-folders [--repo <folder>] [--dry-run]
```

### reset

Reset workspace state — entities, sessions, or memory.

```bash theme={null}
studiograph reset <entities|sessions|memory> [--remote]
```

<Warning>
  `reset` and `admin folder remove --delete-files` are destructive. Take a backup with `admin backup` first.
</Warning>

### config

Manage the CLI's stored tokens: list them and drop the ones you no longer need.

```bash theme={null}
studiograph config
```
