Launch
claude # interactive session
claude "fix the failing test" # start with a prompt
claude -p "summarise this repo" # print mode: answer, then exit
claude -c # continue the most recent session
claude -r # pick a session to resume
claude --model claude-opus-5 # choose the model for this session
Flags worth knowing
-p, --print— non-interactive; pipe input in, get output out. The basis of every script and CI use.--output-format text|json|stream-json— structured output for print mode.--model <id>— any model the endpoint serves (/v1/modelson this gateway lists them).--allowedTools "Read,Edit,Bash(git *)"— pre-approve tools so print mode never blocks on a prompt.--dangerously-skip-permissions— no prompts at all. Only inside a container or sandbox you can throw away.--max-turns N— cap the agent loop in headless runs.--add-dir <path>— let the session work across more than one directory.
Slash commands inside a session
/init— write a CLAUDE.md for the project (conventions, build commands, what to avoid)./compact [focus]— summarise the conversation to free context; the single most effective cost control./clear— start over with an empty context./model— switch model mid-session;/cost— tokens and spend so far;/status— endpoint, key, model, version./permissions— what the agent may do without asking;/config— settings;/memory— edit memory files./mcp— connected MCP servers;/agents— define and manage subagents;/hooks— shell hooks on tool events./review— review a pull request;/doctor— diagnose the install;/help— everything else.
claude setup-token: long-lived auth for CI on a subscription
claude setup-token signs in once in a browser and prints a long-lived OAuth token for a Claude Pro/Max subscription, meant for headless environments where /login is impossible. Export it as CLAUDE_CODE_OAUTH_TOKEN in CI and print mode runs against the subscription's allowance. It is subscription-only; with an API key (Anthropic or gateway) the step is unnecessary — set ANTHROPIC_API_KEY instead.
Print mode for scripts and CI
cat error.log | claude -p "explain the root cause in three lines"
claude -p "write a changelog entry for the staged diff" \
--allowedTools "Read,Bash(git diff *)" \
--output-format json
Print mode is how the GitHub Action, editor integrations and the Agent SDK use Claude Code. With ANTHROPIC_BASE_URL set to the gateway, these runs bill against your gateway balance or unlimited plan rather than an Anthropic account.
Where configuration lives
CLAUDE.mdin the repo root (andCLAUDE.local.mdfor personal notes) — project memory, read every session..claude/settings.json— per-project permissions, hooks, env;~/.claude/settings.json— global.~/.claude/skills/and.claude/skills/— skills;.claude/agents/— subagent definitions.- Environment: ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY / ANTHROPIC_AUTH_TOKEN, and the per-tier model overrides covered in the models guide.
Frequently asked questions
How do I run Claude Code without the interactive prompt?
Use print mode: claude -p "your prompt". Combine it with --allowedTools and --output-format json for scripts, and pipe files in on stdin.
What does /compact do?
It asks the model to summarise the conversation so far and replaces the history with that summary. Context shrinks, cost per turn drops, and the session can continue. Run it whenever a task changes direction.
Can I use Claude Code with a different API base URL?
Yes — set ANTHROPIC_BASE_URL. /status confirms which endpoint the session is using.
Run Claude Code on the gateway
Same models, two environment variables, credits at 7.69× face value — or a flat-rate unlimited plan.
Get an API key See unlimited plansAI Prime Tech is an independent API gateway and is not affiliated with, endorsed by, or sponsored by Anthropic. “Claude” and “Claude Code” are trademarks of Anthropic. Claude Code features described here follow Anthropic’s public documentation at the time of writing and change frequently; prices and model lists on this page are read from this gateway’s live settings.