Anthropic Token Optimizer for Openclaw

A comprehensive optimization suite for reducing Anthropic API expenses by mastering cache read reduction and context management within Openclaw Skills.

ngocgd
v1.3.0
Apr 2, 2026
0
846
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install anthropic-token-optimizer

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install anthropic-token-optimizer using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Anthropic Token Optimizer?

The Anthropic Token Optimizer is a specialized framework designed to minimize API billing without compromising the quality of agent reasoning. It specifically targets cache read reduction, which is the primary cost driver for long-running sessions using Claude Opus. By implementing these Openclaw Skills, developers can achieve up to a 90% reduction in code exploration costs and significantly lower daily operational expenses for their AI agents.

This skill combines configuration tuning, workspace hygiene, and behavioral patterns to keep context lean and caches warm. It provides a technical blueprint for partitioning information, managing file budgets, and ensuring critical state survival during context compaction, making it an essential tool for anyone running high-frequency agent workflows.

Anthropic Token Optimizer Use Cases

  • Developers looking to lower their Claude Opus and Sonnet API bills during long coding sessions.
  • Managing large codebases where repeated file scanning causes significant context bloat.
  • Ensuring session continuity and state recovery when using Openclaw Skills with high context limits.
  • Optimizing agent performance in resource-constrained or cost-sensitive environments.
  • Maintaining a clean workspace through automated file budgets and heartbeat-aligned caching.

How Anthropic Token Optimizer Works

  1. Modifies the openclaw.json configuration to use cost-effective models like Claude Sonnet for compaction while reserving Opus for logic.
  2. Implements a 55-minute heartbeat to prevent Anthropic cache expiration, significantly reducing expensive cache write operations.
  3. Enforces strict file budgets for injected workspace documents like AGENTS.md and SOUL.md to keep the base context footprint under 2,800 tokens.
  4. Uses the Atris Pattern to create a persistent codebase map, allowing the agent to navigate files using cached metadata rather than expensive global searches.
  5. Monitors token usage in real-time through diagnostic commands, allowing for manual or automated compaction when context thresholds are met.

Anthropic Token Optimizer Setup

To apply these optimizations to your Openclaw Skills environment, update your openclaw.json configuration with these recommended settings:

{
  "compaction": {
    "mode": "safeguard",
    "model": "anthropic/claude-sonnet-4-20250514"
  },
  "contextPruning": {
    "mode": "cache-ttl",
    "ttl": "1h"
  },
  "params": {
    "cacheRetention": "long",
    "context1m": true
  },
  "heartbeat": {
    "every": "55m"
  }
}

For codebase navigation caching, install the Atris utility:

npx clawhub@latest install atris

Anthropic Token Optimizer Data Schema & Taxonomy

The skill organizes optimization data and budgets according to the following taxonomy:

Component Target Size Purpose
AGENTS.md < 500 tokens Core agent instructions
SOUL.md < 250 tokens Identity and user preferences
MEMORY.md < 400 tokens Recent decision logs
atris/MAP.md Varies Persistent codebase navigation cache
Bootstrap Limit < 30,000 chars Total initial context injection cap

Anthropic Token Optimizer Advanced Features

  • Subagent Delegation: Offload tool-heavy tasks or web research to cheaper models to keep the main agent's context clean.
  • WAL (Write-Ahead Log) Protocol: Automatically records critical state and decisions to SESSION-STATE.md before compaction triggers.
  • Atris Codebase Mapping: High-efficiency navigation pattern that reduces exploration costs by 80-90% on medium to large projects.
  • Cache Heartbeat Alignment: Keeps the Anthropic prompt cache warm during idle periods to avoid $18.75/MTok cache write fees.
  • Intelligent Compaction Survival: Custom summaries that prioritize decision history over raw dialogue to maintain agent coherence.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*