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

# Claude Code

> Configure ruoli in Claude Code

[Claude Code](https://code.claude.com/docs) is an AI coding agent by Anthropic that reads code, edits files, and runs commands in the terminal.

## Installation

```bash theme={null}
curl -fsSL https://claude.ai/install.sh | bash
```

## Configure with CC Switch (Recommended)

Open [CC Switch](https://ccswitch.lovable.app) and add a ruoli configuration:

| Field   | Value               |
| ------- | ------------------- |
| API URL | `https://ruoli.dev` |
| API Key | Your Key            |

Select Claude Code and click Apply.

<Warning>The API URL for Claude Code is `https://ruoli.dev`, **without** `/v1`.</Warning>

## Switch Models

Beyond native Claude models, ruoli routes to third-party models like `gpt-5.5`, GLM, Kimi, and DeepSeek. Open **CC Switch → Edit Provider → Model Mapping**, point each Claude alias at the target model, and save — no JSON editing required.

<Frame>
  <img src="https://mintcdn.com/yibinuniversity/APBCxMo3fcbJAdpd/images/cc-switch/models.png?fit=max&auto=format&n=APBCxMo3fcbJAdpd&q=85&s=7eb7604d36b71eff2723dc8929295e03" alt="CC Switch Model Mapping" width="2000" height="1300" data-path="images/cc-switch/models.png" />
</Frame>

| Field                | Purpose                                   |
| -------------------- | ----------------------------------------- |
| Main Model           | The default model Claude Code calls       |
| Thinking Model       | Used when extended / reasoning mode is on |
| Haiku Default Model  | Target model for the `haiku` alias        |
| Sonnet Default Model | Target model for the `sonnet` alias       |
| Opus Default Model   | Target model for the `opus` alias         |

<Info>Leave these blank if your provider is natively Claude — only fill them in when you want to route aliases to a different model.</Info>

## Disable Attribution Header (Required)

<Warning>
  Claude Code injects a dynamic attribution header (containing session ID and more) into every request by default — this **completely destroys upstream prompt caching**, causing cache hit rates to collapse, costs to spike, and responses to slow down.

  **Always disable it**, whether you're using native Claude models or third-party models like GLM / Kimi / DeepSeek.
</Warning>

In CC Switch → **Edit Provider → Config JSON**, add one line to `env`:

```json theme={null}
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0"
```

<Frame>
  <img src="https://mintcdn.com/yibinuniversity/reJxCvBE5PANr52t/images/cc-switch/json-config.png?fit=max&auto=format&n=reJxCvBE5PANr52t&q=85&s=5897ca6683d204b9cfd53446bc78ce36" alt="Add CLAUDE_CODE_ATTRIBUTION_HEADER in CC Switch JSON" width="2000" height="1302" data-path="images/cc-switch/json-config.png" />
</Frame>

The same applies to manual `~/.claude/settings.json` — see the example below.

## Manual Configuration

Edit `~/.claude/settings.json`:

```json theme={null}
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://ruoli.dev",
    "ANTHROPIC_AUTH_TOKEN": "sk-YOUR-KEY",
    "CLAUDE_CODE_ATTRIBUTION_HEADER": "0"
  }
}
```

Or via environment variables:

```bash theme={null}
export ANTHROPIC_BASE_URL=https://ruoli.dev
export ANTHROPIC_AUTH_TOKEN=sk-YOUR-KEY
export CLAUDE_CODE_ATTRIBUTION_HEADER=0
```

## Configure Context Compression

Claude Code auto-compresses context at about 83% of the context window by default. If you're using a 1M context window, you can adjust when compression triggers via `CLAUDE_AUTOCOMPACT_PCT_OVERRIDE`.

For example, to trigger compression at 180k tokens (180k / 1000k = 18%):

Add to the `env` block in `~/.claude/settings.json`:

```json theme={null}
{
  "env": {
    "CLAUDE_AUTOCOMPACT_PCT_OVERRIDE": "18"
  }
}
```

Or set a temporary environment variable:

```bash theme={null}
export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=18
```

| Value | Trigger point (1M window) | Use case                        |
| ----- | ------------------------- | ------------------------------- |
| `18`  | \~180k tokens             | Keep context clean frequently   |
| `50`  | \~500k tokens             | Balance performance and context |
| `83`  | \~830k tokens (default)   | Maximize context utilization    |

<Warning>You can only set the threshold below 83%. Values above 83% are silently ignored.</Warning>

<Info>**Official Documentation**: [code.claude.com/docs](https://code.claude.com/docs)</Info>
