CLI Reference

A complete reference for the ai command.

Usage

ai                 # start an interactive session in the current repo
ai "<request>"     # start a session with <request> as the first message
ai [options]

Coding sessions require an interactive terminal on both stdin and stdout. Piped prompts and redirected coding output are rejected; commands such as --help, --version, whoami, --usage, and --list-sessions remain redirectable.

Auth

CommandDescription
aiSigns you in if you aren't, then starts a session.
ai loginThe same thing; kept for muscle memory. Starts the session directly when you are already signed in.
ai whoamiShow the signed-in account.
ai --usageShow account usage percentage and reset times.
ai logoutSign out.

The sign-in screen opens your browser and, at the same time, prints a URL you can open on any other device and a box for an authorization code. Headless and remote machines need no separate command: open the URL wherever you have a browser, choose On another computer on that page, and paste the code it shows. Whichever route answers first signs you in.

Updates

When a newer release is published, ai says so on start, before the session opens, and offers two ways on:

ChoiceWhat happens
Update now (selected; Enter)Installs the new version with the package manager this copy came from, then asks you to run ai again so the whole session runs one version.
SkipStarts the session on the version you have.

Update now is selected when the offer appears, so Enter takes the update. ↑/↓ move between the two rows and the number keys jump straight to one.

TheGitAI works best on the latest version, and an older CLI may not work optimally. Skipping covers that one start: the next start asks again, and a release cannot be silenced for good. Ctrl+C at the prompt quits without installing anything.

MCP servers

CommandDescription
ai mcp add <name> -- <command> [args...]Configure a local stdio server.
ai mcp add --transport http <name> <url>Configure a remote Streamable HTTP server.
ai mcp add-json <name> '<JSON>'Import a server configuration.
ai mcp listShow configured servers without starting them.
ai mcp get <name>Show metadata without credential values.
ai mcp enable <name> / ai mcp disable <name>Enable or disable a server.
ai mcp remove <name>Remove a server configuration.
ai mcp --helpShow header and environment-variable options.

Short setup options are -t / --transport, -e / --env, -H / --header, and -s user / --scope user. Only user scope is supported.

These commands work without a coding session or sign-in. Configuration applies to your user on this machine. See MCP Servers for Context7, Playwright, authentication and current limits.

Sessions

CommandDescription
ai --list-sessionsList saved sessions for this repo.
ai --session <id|name>Resume a saved session by id or name.

Sessions are stored locally and scoped to the current repo. Local history can be listed and resumed from that computer. Continuing a session through the service requires the TheGitAI account used for that session. The five most recent sessions per repo are kept.

Options

OptionDescription
-y, --yesStart in Bypass all permissions mode.
-h, --helpShow help.

Chat commands

Used inside an interactive session:

CommandDescription
/helpShow help.
/mcpCheck MCP connections and list available tools.
/aboutShow the installed version and platform information.
/usageShow account usage percentage and reset times.
/modelList supported models and pick one.
/model <id>Switch the active model without clearing history.
/resumeResume a saved session for this repo.
/jobsOpen the background jobs picker (browse, expand output, stop).
/jobs output <id>Print a background job's full captured output.
/jobs kill <id>Stop a background job by id.
/reportOpen the private form for bugs and feature requests on the TheGitAI website.
/newstart a new conversation; this session remains saved
/logoutSign out and quit.
/exitQuit the session.

Environment

VariableDescription
THEGITAI_SESSION_DIROverride the default local directory for saved sessions.
Run ai --help at any time to print this reference in your terminal.

Related: Chat commands·Installation·Troubleshooting