Token导航 LogoToken导航

Agent Skill · 开发

claude-code-api-optimizer-skill(Claude 代码 API 优化器技能)

用于辅助 API 设计、接口文档、请求响应结构和服务集成说明。它适合让 Agent 梳理 endpoint、生成 OpenAPI 草稿、检查字段命名、整理错误码或辅助前后端联调。使用时需要确认真实业务语义、鉴权方式、分页和错误处理规则;涉及生成接口文档时,应避免凭空补字段,最好从现有代码、schema 或接口样例中提取事实。

claude-code-api-optimizer-skill 是开发类 Agent Skill,可用宿主为 OpenClaw,通过ClawHub获取,权限为接触敏感数据;许可证为 MIT-0,第三方扫描有提醒项,按安装量在开发类的 21,746 个 Skill 里排第 8,584。

总安装 3,096周安装 129GitHub Stars 公开资料未说明下载 1,032核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
MIT-0
版本
1.0.0

安装方式

通过对话安装

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

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

命令行安装

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

ClawHubOpenClaw
openclaw skills install claude-code-api-optimizer-skill

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

通过上下文压缩等技术减少 LLM API 令牌消耗 20%-35%。适用于高频调用或成本控制严格的场景。安装命令:openclaw skills install claude-code-api-optimizer-skill。需测试压缩率与语义完整性平衡点。原始 README 未提供压缩算法具体实现细节。

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 OpenClaw;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 openclaw skills install claude-code-api-optimizer-skill;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要接触敏感数据,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

claude-code-api-optimizer-skill 怎么安装?

在终端执行 openclaw skills install claude-code-api-optimizer-skill。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

claude-code-api-optimizer-skill 支持哪些 AI 工具?

公开资料标注支持 OpenClaw。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

claude-code-api-optimizer-skill 需要什么权限?

权限级别是接触敏感数据。该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

claude-code-api-optimizer-skill 是免费的吗?

来源标注的许可证是 MIT-0。本站不代收任何费用,也不托管安装包;能否商用、要不要署名,以许可证原文为准。

claude-code-api-optimizer-skill 用的人多吗?

公开数据是累计安装 3,096 次,近一周安装 129 次,下载 1,032 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

claude-code-api-optimizer-skill 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 专注 OpenClaw 一种宿主,触发方式和使用习惯不用来回切换。
  • 许可证明确为 MIT-0,商用和分发边界好判断。

先想清楚的地方

  • 需要接触敏感数据,装到常用环境前要先评估影响面。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 OpenClaw,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 环境里有大量密钥、凭证,不方便给第三方 Skill 读取的人。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
claude-code-api-optimizer-skill

Claude 代码 API 优化器技能 · 本页

3,096—接触敏感数据MIT-0有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

name
token-optimizer
description
Reduce LLM API token consumption by 20-35% through pre-send estimation, memory extraction, and context compression.
version
1.0.0
author
OpenClaw Community
tags
[optimization, tokens, cost-reduction, context-management, memory]
model
any

Token Optimizer

Reduce your LLM API costs by 20-35% with three proven mechanisms: pre-send token estimation, structured memory extraction, and context compression. Model-agnostic, zero dependencies.


Mechanism 1 — Pre-Send Token Estimation

Estimate token count *before* sending a request. If the payload exceeds a threshold, compress or truncate it. Never pay for tokens you could have avoided.

Rules

  1. Estimate before every API call. Use these formulas:

- Plain text: tokens ≈ character_count / 4 - JSON / structured data: tokens ≈ character_count / 2 - Code (mixed): tokens ≈ character_count / 3.5 - Images / PDFs: tokens ≈ 2000 (flat per asset, regardless of size)

  1. Set a token budget per request. Default threshold: 8 000 tokens. Adjust per use case.
  1. If estimated tokens exceed the budget:

- Summarize or truncate the longest sections first. - Strip intermediate reasoning, keep conclusions only. - For JSON: remove null/empty fields, shorten keys if feeding to a model that doesn't need human-readable keys. - For code: send only the relevant function/class, not the full file.

  1. Log the estimate vs. actual usage (from the API response) to calibrate over time.

Example

Input: 24,000 characters of plain text
Estimated tokens: 24000 / 4 = 6,000 → under budget, send as-is.

Input: 40,000 characters of JSON
Estimated tokens: 40000 / 2 = 20,000 → over budget.
Action: strip null fields, remove redundant nested objects → 14,000 chars → 7,000 tokens → send.

Reference

See references/token-formula.md for the full formula breakdown with worked examples.


Mechanism 2 — Memory Extraction

Instead of re-reading the entire conversation history every turn, extract and persist key information into structured memory files. On subsequent turns, load only the memory index — not the raw history.

Rules

  1. Use a lightweight secondary model (Haiku, GPT-4o-mini, Gemini Flash) as the memory extraction agent. Never burn expensive model tokens on bookkeeping.
  1. Maintain a session cursor. Track which messages have already been processed. On each extraction pass, only read *new* messages since the last cursor position.
  1. Limit extraction to 5 rounds max per session. Each round processes a batch of new messages. Stop early if no new information is found.
  1. Parallelize I/O within rounds:

- Round 1: all reads in parallel (gather raw content). - Round 2: all writes in parallel (persist extracted memories).

  1. Structure memory as index + detail files:

- MEMORY.md — index file, max 200 lines. Contains only pointers: - [topic-name](memory/topic-name.md) — one-line description. - memory/topic-name.md — full content for each topic with frontmatter (name, description, type).

  1. Memory types (categorize each entry):

- user — who the user is, their preferences, expertise level. - feedback — corrections and confirmed approaches (what to do / not do). - project — current goals, deadlines, decisions, constraints. - reference — pointers to external resources (URLs, dashboards, issue trackers).

  1. Do not store what can be derived. No code snippets, no git history, no file paths — these are always available from the source. Store only non-obvious context.

Example — Extraction Prompt

You are a memory extraction agent. Read the following new messages (since cursor position {cursor}).

For each piece of non-obvious information, output a JSON object:
{
  "topic": "short-kebab-case-name",
  "type": "user | feedback | project | reference",
  "description": "one-line summary for the index",
  "content": "full memory content, structured with Why and How-to-apply"
}

Rules:
- Max 5 memories per pass.
- Skip anything derivable from code, git, or existing memory.
- Convert relative dates to absolute (today is {date}).
- If a memory already exists for this topic, output an update, not a duplicate.

Reference

See references/memory-extraction-pattern.md for the full pattern with prompt templates.


Mechanism 3 — Context Compression

As conversations grow, compress older exchanges into dense summaries. Keep only the last N messages in full fidelity. This prevents context windows from filling with stale reasoning.

Rules

  1. Keep the last 6 messages uncompressed (3 user + 3 assistant). These are "fresh" — they contain active context.
  1. Summarize everything older into a single <compressed-context> block at the top of the conversation. Format:
   <compressed-context>
   ## Decisions Made
   - Chose PostgreSQL over MongoDB for the user table (reason: relational queries).
   - API rate limit set to 100 req/min per user.

   ## Current State
   - Auth module: complete, merged to main.
   - Payment integration: in progress, blocked on Stripe webhook config.

   ## Key Constraints
   - Must ship by 2026-04-15.
   - No breaking changes to public API v2.
   </compressed-context>
  1. What to keep in summaries:

- Decisions and their rationale. - Current state of work (done / in-progress / blocked). - Constraints and deadlines. - User preferences and corrections.

  1. What to discard:

- Intermediate reasoning ("I considered X but..."). - Exploratory questions that were already answered. - Tool call details (file reads, grep results, build output). - Repeated or superseded information.

  1. Trigger compression when the conversation exceeds 60% of the model's context window. Use Mechanism 1's estimation formula to check.
  1. Never compress system prompts or skill instructions. These must remain intact.

Example — Savings Calculation

Before compression:
  42 messages, ~32,000 tokens total.

After compression:
  Compressed block: ~2,000 tokens.
  Last 6 messages: ~4,500 tokens.
  Total: ~6,500 tokens.

  Savings: 32,000 - 6,500 = 25,500 tokens (80% reduction on history).
  Per-request savings (ongoing): ~25,500 tokens × $0.003/1K = $0.077 per request.

Combined Savings Estimate

MechanismTypical SavingsWhen It Hits
Pre-send estimation10-15%Every request with large payloads
Memory extraction5-10%Multi-session workflows
Context compression15-25%Long conversations (>20 messages)
Combined20-35%Sustained usage over a session

These are conservative estimates based on real-world agent workflows. Actual savings depend on conversation length, payload sizes, and how aggressively you compress.


Quick Start

  1. Copy this skill into your agent's skill directory (or paste SKILL.md into your system prompt).
  2. Apply Mechanism 1 immediately — add token estimation before your API calls.
  3. Set up Mechanism 2 if you run multi-turn or multi-session workflows.
  4. Enable Mechanism 3 for any conversation that runs beyond 15-20 messages.

No code to install. No dependencies. Just rules your agent follows.

平台分布

OpenClaw

71.6%
按下载量换算739

安全审计

VirusTotal

通过

ClawScan

可疑

Static analysis

通过

权限和风险

接触敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills