Claude Code Setup Guide (Terminal CLI)

Install Claude Code CLI in your terminal and connect to platform API

1

Install Claude Code

Run the following command in your terminal to install Claude Code CLI.

macOS / Linux / WSL:

curl -fsSL https://claude.ai/install.sh | bash

Or install via npm (requires Node.js 18+):

npm install -g @anthropic-ai/claude-code
2

Configure Environment Variables

Set the following environment variables. Replace your-api-key with your platform API key.

Method 1: Shell Profile

Add to ~/.zshrc or ~/.bashrc, then restart your terminal or run source.

export ANTHROPIC_BASE_URL="/api"
export ANTHROPIC_AUTH_TOKEN="your-api-key"
export ANTHROPIC_API_KEY=""

Method 2: Project-Level Config

Create .claude/settings.local.json in your project root (do not commit to Git).

// .claude/settings.local.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "/api",
    "ANTHROPIC_AUTH_TOKEN": "your-api-key",
    "ANTHROPIC_API_KEY": ""
  }
}

Important Notes

  • ANTHROPIC_API_KEY must be set to an empty string to prevent conflicts with official authentication.
  • If you previously used Anthropic directly, run /logout in Claude Code before configuring.
  • Do not put these in a project-level .env file. The native installer does not read .env files.
3

Specify Models (Optional)

Specify models for different roles via environment variables.

# Opus - complex reasoning
export ANTHROPIC_DEFAULT_OPUS_MODEL="claude-opus-4-6"

# Sonnet - general coding
export ANTHROPIC_DEFAULT_SONNET_MODEL="claude-sonnet-4-5"

# Haiku - quick completions
export ANTHROPIC_DEFAULT_HAIKU_MODEL="claude-haiku-4-5"

# Sub-agent tasks
export CLAUDE_CODE_SUBAGENT_MODEL="claude-sonnet-4-5"
4

Verify Configuration

Launch Claude Code and type /status to confirm the connection is working.

claude
/status
5

Cost Tracking Statusline (Optional)

Display provider, model, cumulative cost, and cache discounts in the Claude Code statusline in real-time.

After downloading, make the script executable and add to ~/.claude/settings.json:

chmod +x statusline.sh
// ~/.claude/settings.json
{
  "statusLine": {
    "type": "command",
    "command": "/path/to/statusline.sh"
  }
}
6

GitHub Actions Integration (Optional)

Use Claude Code in GitHub Actions by passing platform credentials via Secrets.

# .github/workflows/claude-code.yml
name: Claude Code
on: [push]
jobs:
  claude:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: anthropics/claude-code-action@v1
        with:
          anthropic_api_key: ${{ secrets.ANTHROPIC_AUTH_TOKEN }}
        env:
          ANTHROPIC_BASE_URL: /api