Supported Platforms
Relevant source files
The following files were used as context for generating this wiki page:
Token Optimizer is designed to function across multiple AI-assisted development environments and runtimes. The system employs a runtime detection logic to identify the host platform and adapt its optimization strategies, hooks, and path resolutions accordingly. The primary supported runtimes include Claude Code, Codex, OpenCode, and GitHub Copilot.
The project differentiates between these environments to ensure that platform-specific configurations (such as ~/.claude vs ~/.codex) are handled correctly and that tools do not inadvertently mutate the wrong configuration directories.
Sources: skills/token-optimizer/SKILL.md:14-53, skills/token-coach/SKILL.md:18-42
Runtime Detection Logic
The system utilizes a multi-step detection process that checks environment variables and process tree signals to determine the active runtime. This detection occurs before any optimization phases are executed to prevent cross-platform configuration errors.
The diagram shows the hierarchical check where explicit environment overrides take priority, followed by directory existence and environment signatures, concluding with an authoritative check via measure.py.
Sources: skills/token-optimizer/SKILL.md:14-88, skills/token-coach/SKILL.md:18-50
Environment Variables and Signals
Different platforms are identified by specific environment variables or directory structures:
| Runtime | Environment Signals / Key Indicators | Reference Target |
|---|---|---|
| Claude Code | CLAUDE_PLUGIN_ROOT, CLAUDE_PLUGIN_DATA | ~/.claude |
| Codex | CODEX_HOME, directory ~/.codex | ~/.codex |
| OpenCode | OPENCODE_BIN, OPENCODE_CONFIG_DIR, OPENCODE_DATA_DIR | ~/.config/opencode |
| GitHub Copilot | COPILOT_HOME, TOKEN_OPTIMIZER_COPILOT_HOME | N/A |
Sources: skills/token-optimizer/SKILL.md:20-42, skills/token-coach/SKILL.md:19-33
Platform-Specific Implementations
Claude Code
Claude Code is the primary platform, supporting the full suite of optimization phases (0 through 5). It uses the ~/.claude directory for storing global configuration, rules, commands, and skills.
- Key Files:
CLAUDE.md,MEMORY.md,settings.json. - Version Awareness: Optimizations vary by version (e.g., v2.1.86+ handles native deduplication).
- Features: Supports "Keep-Warm" pings for prompt cache maintenance and "Smart Compaction" via
PreCompactandPostToolUsehooks.
Sources: skills/token-optimizer/references/implementation-playbook.md:178-212, skills/token-optimizer/references/optimization-checklist.md:387-434
Codex
When a Codex environment is detected, the optimizer shifts to a "chat-first" workflow and adapts its terminology and toolset to Codex-native concepts.
The class diagram represents the abstraction layer where runtime-specific concepts (like file names and model tiers) are swapped based on the detected platform.
Sources: skills/token-coach/SKILL.md:118-129, skills/token-optimizer/SKILL.md:86-88
- Terminology Mapping:
CLAUDE.mdbecomesAGENTS.md.MEMORY.mdbecomes Codex memories.- Claude models (Opus/Sonnet/Haiku) map to Codex Intelligence Levels (GPT-5.5, GPT-5.4, etc.).
- Codex Hooks: Uses "balanced hooks" and "compact prompt guidance" instead of standard Claude hooks.
Sources: skills/token-coach/SKILL.md:118-129
OpenCode and GitHub Copilot
For OpenCode and GitHub Copilot, the SKILL.md defines a "hard stop." The Claude-based optimization phases are blocked because they target the wrong configuration directories (e.g., trying to mutate ~/.claude while in OpenCode).
- OpenCode: The optimizer runs as a native plugin. Users are directed to follow the workflow in
references/opencode-workflow.md. - Copilot: Users are redirected to platform-specific guidance as the Claude-centric audit is not applicable.
Sources: skills/token-optimizer/SKILL.md:44-51, skills/token-optimizer/SKILL.md:81-85
Operating System Support
Platform support also extends to the underlying operating system for specific features like the Keep-Warm Scheduler:
- macOS: Full support for the Keep-Warm scheduler, allowing automatic pings to maintain prompt cache.
- Other OSes: The scheduler is currently "pending" or "watchdog-only," requiring manual interaction or limited automation compared to the macOS implementation.
Sources: skills/token-optimizer/SKILL.md:126-128, skills/token-coach/SKILL.md:73-75
Summary of Integration
Token Optimizer ensures continuity across these platforms by porting "Session Continuity" (Cold-Resume-Lean) logic to Claude Code, Codex, OpenClaw, and OpenCode. While the richness of checkpoints varies by platform, the core logic for reconstructing lean context blocks adapts to the available metadata of each runtime.
Sources: skills/token-optimizer/SKILL.md:214-230