# Token Optimization

> Claude Code token optimization — CLAUDE_AUTOCOMPACT_PCT_OVERRIDE, MAX_THINKING_TOKENS, behavioral patterns for selective reads, grep-first discovery, and cache awareness. Use to reduce cost on multi-day projects or recurring sessions.

- Skill: `hermeticormus/token-optimization` (Agent Skill)
- Install (CLI): `npx skillmds@latest add hermeticormus/token-optimization`
- Raw SKILL.md: https://api.skillmd.com/api/skills/hermeticormus/token-optimization/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Product & Planning
- License: MIT
- Author: hermeticormus (https://skillmd.com/u/hermeticormus)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/hermeticormus/token-optimization

---


# Token optimization

## Two env vars

```bash
export CLAUDE_AUTOCOMPACT_PCT_OVERRIDE=70
export MAX_THINKING_TOKENS=16000
```

## Patterns

- Read with offset/limit, not whole files
- Grep before Read
- Compact at phase transitions
- Don't leave prompts cold > 5min (cache TTL)
- Separate sessions: routine vs. complex

## When to raise thinking budget

Architecture, debugging, refactoring, critical review.

## When to lower

File ops, lint fixes, trivial edits, lookups.

---

Full content at https://github.com/HermeticOrmus/token-optimization-skills.

