# Claude Code 1M Context (Opt-Out)

> ⚠️ **This skill may become obsolete.** The Opus 4.6 "1M context" mode
> is currently an Anthropic **beta**. Once it graduates to GA (or
> Anthropic changes the default back to 200K), everything documented
> here stops mattering. If you're reading this and the
> `CLAUDE_CODE_DISABLE_1M_CONTEXT` env var no longer does anything
> — or the "Opus 4.6 (with 1M context)" label no longer shows up
> in your Claude Code banner — this skill can probably be deleted
> from gallia. Check the [Claude Code docs on extended context][docs]
> first.
>
> [docs]: https://code.claude.com/docs/en/model-config#extended-context-with-1m

## The problem

Claude Code 2.1.x running inside the VS Code extension defaults to
**Opus 4.6 with the 1M-context beta** when your account is entitled
to it. The 1M window is great for massive codebase reads, but:

1. **Every turn costs more.** The 1M-context variant is a separate
   SKU with premium pricing — you burn through your token budget
   noticeably faster than the standard 200K Opus 4.6.
2. **Most sessions don't need it.** A typical Claude Code session
   (single-file edits, small refactors, debugging one bug) fits
   comfortably in 200K. Using 1M for those sessions is pure waste.
3. **There's no obvious toggle in the UI.** The VS Code extension's
   `Claude Code: Select Model` command lets you pick `opus` or
   `sonnet`, but the 1M variant is layered on top of "opus" via a
   separate beta opt-in that isn't exposed in the model picker.

Result: users notice their tokens draining faster than they
expected and have no obvious way to stop it.

## The fix

Set `CLAUDE_CODE_DISABLE_1M_CONTEXT=1` in the environment Claude
Code starts with. The Claude Code binary checks this env var at
session start and, if set, pins the session to the standard 200K
Opus context.

**Canonical place to set it:** the VS Code extension's
`claudeCode.environmentVariables` setting in
`~/.local/share/code-server/User/settings.json` (code-server) or
`~/.config/Code/User/settings.json` (VS Code desktop). The
extension reads that setting on every Claude Code process launch
and injects the values into the child process env.

## Step-by-step

### 1. Edit the VS Code user settings

```bash
# code-server (the usual Adom container setup)
$EDITOR ~/.local/share/code-server/User/settings.json

# VS Code desktop
$EDITOR ~/.config/Code/User/settings.json
```

Add (or merge into) the `claudeCode.environmentVariables` object:

```jsonc
{
  // ... your other settings ...
  "claudeCode.preferredLocation": "panel",
  "claudeCode.selectedModel": "opus",

  // NEW: pin to 200K standard context so sessions don't use the
  // expensive 1M beta variant.
  "claudeCode.environmentVariables": {
    "CLAUDE_CODE_DISABLE_1M_CONTEXT": "1"
  }
}
```

If there are already other env vars under
`claudeCode.environmentVariables`, add `CLAUDE_CODE_DISABLE_1M_CONTEXT`
as another key inside the existing object — don't wipe the others.

### 2. Restart the Claude Code panel

The env var is only read at Claude Code process launch, so the
currently-running session keeps using whatever it was using. Close
the Claude Code panel and reopen it (or Ctrl+Shift+P → `Claude
Code: Start New Conversation`) for the change to take effect.

You do **not** need to reload the entire VS Code window — the
Claude Code process is per-panel, so closing and reopening the
panel is enough.

### 3. Verify

The first banner / system message in the fresh session should
say `Opus 4.6` **without** the "with 1M context" suffix. You can
also confirm by asking Claude "what model are you running" — it
should report `claude-opus-4-6` (no `[1m]` tag).

You can also grep the running process env:

```bash
PID=$(pgrep -f 'resources/native-binary/claude' | head -1)
cat /proc/$PID/environ | tr '\0' '\n' | grep DISABLE_1M
# → CLAUDE_CODE_DISABLE_1M_CONTEXT=1
```

## To re-enable 1M context

Just remove (or comment out) the `CLAUDE_CODE_DISABLE_1M_CONTEXT`
entry from `claudeCode.environmentVariables` and restart the
Claude Code panel. The extension will re-enable the beta on the
next session launch (provided your account is still entitled).

If you want it only sometimes — e.g. for one long session reading
a huge codebase — temporarily override it by launching the
`claude` binary from a terminal with `CLAUDE_CODE_DISABLE_1M_CONTEXT=`
(empty string) in front, or remove the setting, open one panel,
then put the setting back and restart. The env var is evaluated
per-process, so panels started under different env can coexist.

## Other Claude Code settings worth knowing about

These also live under the `claudeCode.*` namespace in the VS Code
user settings and are relevant when you're tuning cost/behavior:

| Setting | Effect |
|---|---|
| `claudeCode.selectedModel` | `"opus"` / `"sonnet"` / `"haiku"`. Switching to Sonnet is a bigger cost cut than disabling 1M context but trades some reasoning capability. |
| `claudeCode.environmentVariables` | Arbitrary env vars injected into every Claude Code process. Also useful for `ANTHROPIC_LOG_LEVEL`, proxy settings, etc. |
| `claudeCode.allowDangerouslySkipPermissions` | Bypass permission prompts on tool calls. Separate from token cost but worth knowing about. |
| `claudeCode.initialPermissionMode` | `"bypassPermissions"` vs `"default"`. Affects prompt flow, not cost. |

## Troubleshooting

### "I restarted the panel but it's still on 1M context"

Double-check:
- Settings file path is correct (code-server vs VS Code desktop
  use different paths — see Step 1).
- JSON is syntactically valid after your edit (`jq . < settings.json`
  should parse cleanly — `code-server` and `code` both tolerate
  line comments but not trailing commas inside `environmentVariables`).
- You restarted the **Claude Code panel**, not just opened a new
  chat in the existing panel. New chats in the same panel reuse
  the existing process env.

### "The setting vanishes when I restart"

VS Code / code-server reads the user settings file fresh on each
launch. If your edit is missing after a restart, either:
- Another extension is rewriting the file (unlikely, but check
  git history on the settings file), or
- You edited workspace settings (`.vscode/settings.json` in a
  project folder) instead of user settings — workspace settings
  only apply when that workspace is open. Put the env var in
  **user settings** for a global pin.

### "CLAUDE_CODE_DISABLE_1M_CONTEXT doesn't do anything"

Likely one of:
- You're on an older Claude Code version that didn't yet ship
  the kill switch. Update the extension (`code-server
  --install-extension anthropic.claude-code` or via the
  Extensions pane) and try again.
- Anthropic changed the env var name or retired the beta. Check
  the [extended context docs][docs] and update this skill.

## Why it's in gallia

This lives in gallia (not just in an individual user's local
settings) because every Adom user running Claude Code inside
their container hits the same problem: 1M context on by default,
no obvious toggle, tokens burning faster than expected. Putting
the fix in a gallia skill means any Claude Code session can
discover and apply it via the standard `/adom` skill umbrella.

When the Anthropic beta graduates and the default changes back
(or when Claude Code ships a proper in-UI context-window toggle),
this skill becomes obsolete and can be removed.
