Token导航 LogoToken导航TokenDH.com
研究检索执行命令clawhub未标认证来源可访问clear审计通过

anthropic-token-optimizerAnthropic token 优化器

Agent Skill

anthropic-token-optimizer 用于查找、检索和筛选相关信息,适合在 OpenClaw 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

3,222

周安装

137

GitHub Stars

公开资料未说明

下载量

1,129
OpenClaw

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

MIT-0

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:anthropic-token-optimizer(Anthropic token 优化器)
来源仓库:https://github.com/ngocgd/anthropic-token-optimizer
安装命令:
openclaw skills install anthropic-token-optimizer
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 OpenClaw 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

ClawHubOpenClaw
openclaw skills install anthropic-token-optimizer

简介

anthropic-token-optimizer 优化 OpenClaw 代理的 Anthropic API 令牌使用效率。

  • 采用缓存读取、文本压缩等技术减少上下文膨胀问题。
  • 适合长期运行代理以控制账单增长。
  • 安装命令为 openclaw skills install anthropic-token-optimizer。
  • 优化效果因用例而异,部分场景可能出现精度下降。

SKILL.md

name
anthropic-token-optimizer
description
Reduce Anthropic API costs (cache read, compaction, context bloat) for OpenClaw agents. Use when users ask about token optimization, reducing API costs, cache read expenses, context management, workspace file trimming, codebase navigation caching, or cost-effective Anthropic model usage. Covers config tuning, behavioral patterns, workspace hygiene, cache TTL alignment, bootstrap size limits, context budgeting, compaction survival, and codebase map caching (Atris pattern) for Claude Opus/Sonnet/Haiku.

Anthropic Token Optimizer

Minimize Anthropic API costs without sacrificing quality. Focus on cache read reduction — the #1 cost driver for long sessions with Opus.

Anthropic Pricing Reference

ModelInputCache WriteCache ReadOutput
Haiku$0.80$1.00$0.08$4
Sonnet$3$3.75$0.30$15
Opus$15$18.75$1.50$75

*(per MTok — multiply by millions of tokens)*

Key insight: Cache read = context_size × num_turns. 200k context × 50 turns on Opus = ~$15 just cache reads.


Part 1: Config Optimizations (openclaw.json)

1. Compaction model — use cheaper model (highest ROI ✅)

"compaction": {
  "mode": "safeguard",
  "model": "anthropic/claude-sonnet-4-20250514"
}

Sonnet summarizes at 5x less cost than Opus. Quality comparable for summaries.

2. Context pruning — trim old tool results

"contextPruning": { "mode": "cache-ttl", "ttl": "1h" }
TTLBehaviorVerdict
1hTrims after 1 hour✅ Best balance
30mModerateOK for active sessions
5mAggressive⚠️ Loses tool results

3. Cache retention — keep "long"

"params": { "cacheRetention": "long", "context1m": true }

"long" = fewer cache writes ($18.75/MTok on Opus!). Don't switch to "default".

4. Cache TTL heartbeat alignment

Anthropic cache expires after ~1h idle. Heartbeat at 55min keeps it warm:

"heartbeat": { "every": "55m" }

Prevents expensive cache re-writes when agent resumes after idle.

5. Bootstrap size limits — cap workspace injection

"bootstrapMaxChars": 8000,
"bootstrapTotalMaxChars": 30000

Check current injection: /context list. Prevents oversized files from inflating every turn.


Part 2: Workspace Hygiene (biggest long-term win)

File budgets

FileTargetReview cycle
AGENTS.md<500 tokens (~2KB)Monthly
SOUL.md<250 tokens (~1KB)Rarely
TOOLS.md<500 tokens (~2KB)When tools change
MEMORY.md<400 tokens (~1.5KB)Weekly prune
HEARTBEAT.md<400 tokens (~1.5KB)When done
memory/YYYY-MM-DD.md<30 linesCollapse at EOD
Total injected<2,800 tokens

Reduction tactics

  • Merge redundant files (IDENTITY.md + USER.md → SOUL.md)
  • Move non-essential docs to subfolders (docs/, notes/) — not auto-injected
  • Collapse exploration into decisions: keep "what we decided", delete "how we got here"
  • Prune ghost context: references to old paths, removed tools, fixed bugs
  • Deduplicate: info in SOUL.md shouldn't repeat in MEMORY.md or AGENTS.md

Daily memory rules

Write: decisions + why (1 line), new tools/config, lessons, user preferences. Skip: exploration steps, command outputs, things already in MEMORY.md, delivered content. Format: Bullets, not paragraphs. One fact per line.


Part 3: Behavioral Patterns

6. /compact after each topic (most effective manual action)

/compact Focus on [topic summary]

7. /new when switching topics entirely

Context resets to 0. Don't carry 200k into unrelated work.

8. Subagents for tool-heavy work

Spawn subagents (cheaper model) for: codebase grep, reading 5+ files, research/web fetch. Tool results stay isolated.

9. Tool output discipline

  • Truncate: | head -20, | jq '.key'
  • Request only needed fields from APIs
  • Never paste full JSON when you need one value
  • Output >50 lines → summarize, don't quote

10. File loading discipline

  • Startup: only today + yesterday memory files
  • Read SKILL.md only when task needs that skill
  • Don't re-read files already in context

Part 4: Context Budgeting

Information partitioning

BudgetContent
10%Task instructions + constraints
40%Recent 5-10 turns of dialogue
20%Decision logs ("tried X, failed because Y")
20%High-relevance MEMORY.md snippets
10%Tool schemas + system prompt

Compaction survival

Before compaction hits, critical state must be captured:

  1. WAL Protocol: On corrections, decisions, specific values → write to SESSION-STATE.md before responding
  2. Working buffer: At 60%+ context → append exchange summaries to memory/working-buffer.md
  3. Recovery: After compaction, read buffer + session state first. Never ask "where were we?"

Session lifespan

After 85% context or 3+ compactions → start fresh with /new. Good MEMORY.md means minimal context loss.


Part 5: Codebase Map Caching (Atris Pattern)

Problem: Every code review or exploration session re-reads the same files, burning tokens on repeated grep/read calls. A 500-file project can cost 50k+ tokens just for navigation.

Solution: Generate a persistent codebase map (atris/MAP.md) once, reuse across sessions.

Setup (one-time per project)

# Install atris skill
npx clawhub@latest install atris

# Or manually: create atris/ folder in project root, then scan
rg "^(export|function|class|const|def |async def |router\.|app\.)" \
  --line-number -g "!node_modules" -g "!.git" -g "!dist" -g "!.env*"

MAP.md structure

# MAP.md — [Project] Navigation Guide
> Last updated: YYYY-MM-DD

## Quick Reference
- `src/index.ts:1` — App entry point
- `src/routes/auth.ts:15` — POST /login handler
- `src/models/user.ts:8` — User schema

### Feature: Authentication
- **Entry:** `src/auth/login.ts:45-89` (handleLogin)
- **Validation:** `src/auth/validate.ts:12` (validateToken)
- **Routes:** `src/routes/auth.ts:5-28`

### Feature: Billing
- **Controller:** `src/controllers/billing.ts:20`
- **Service:** `src/services/stripe.ts:1-45`

MAP-first rule

Before searching codebase:

  1. Read atris/MAP.md — found? Go directly to file:line
  2. Not found? Search with rg, then add result to MAP.md

Map gets smarter every session. Never let a discovery go unrecorded.

Keeping fresh

  • New file → add to relevant section
  • Deleted file → remove from map
  • Major refactor → regenerate affected sections only
  • Small updates, not full regeneration

Token savings

CodebaseWithout mapWith mapSavings
Small (50 files)~5k tokens/explore~1k80%
Medium (200 files)~20k tokens/explore~3k85%
Large (500+ files)~50k tokens/explore~5k90%

Diagnostics

/context list    → token count per injected file
/context detail  → full breakdown (tools, skills, system)
/usage tokens    → append token count to every reply
/usage cost      → cumulative cost summary
/status          → model, context %, cost estimate

Decision Matrix

SituationAction
Session >100k context/compact immediately
Switching topics/new or /compact
Reading 5+ filesSpawn subagent
Compaction cost highSet compaction model to Sonnet
Daily cost >$10Audit session count, compact more
Cache writes spikingHeartbeat ≤55min, keep cacheRetention: long
Workspace injection >20KBMerge/move files, set bootstrapMaxChars
Context >85%/new — start fresh

Impact Summary

TechniqueSavingsUX Impact
Compaction model = Sonnet~80% compaction costNone
Workspace file budgets~30-50% base costNone
/compact after topics~40-60% cache readManual step
Cache TTL heartbeat (55m)~20-30% cache writesNone
Bootstrap size limits~20-30% base costNone
Subagent delegation~30% cache readBetter (parallel)
Tool output discipline~10-20% per turnRequires habit
/new for new topics~100% (reset)Lose old context
Codebase map (Atris)~80-90% code explorationOne-time setup

Credits

Incorporates ideas from: openclaw-token-optimizer, context-slimmer, context-budgeting, compaction-survival, context-hygiene, atris (codebase map caching).

适合场景

01

OpenClaw 用户查找和安装 Skill 时

02

用户想查找某类 Agent Skill 时

03

需要根据任务场景推荐可安装能力包时

04

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

OpenClaw

97.76%
按下载量换算1,104

安全审计

VirusTotal

通过

ClawScan

通过

Static analysis

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 openclaw skills install anthropic-token-optimizer 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills