Agent skill · AI & Agents

cc-cost-engineering

AI Agent 成本工程 — 基於 Claude Code 的成本追蹤、prompt cache 最佳化、token 預算控制逆向分析。Use when: 優化 token 消耗、設計成本控制機制、分析 cache 效率、選擇模型配置。

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill cc-cost-engineering --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 3 KB
Bundled scripts: none
Version: 202603
Path: skills/ai-llm/cc-cost-engineering/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# AI Agent 成本工程 基於 Claude Code v2.1.88 的成本控制機制逆向分析。 ## 模型成本矩陣 | 模型 | Input/MTok | Output/MTok | 相對成本 | |------|-----------|-------------|----------| | Haiku 3.5 | $0.80 | $4.00 | 1x | | Sonnet 4.6 | $3.00 | $15.00 | 3.75x | | Opus 4.6 | $15.00 | $75.00 | 18.75x | | Opus 4.6 Fast | $30.00 | $150.00 | **37.5x** | **Cached tokens 便宜 75-90%。** 這是 Claude Code 整個架構圍繞 cache 設計的原因。 ## Cost Envelope 模式 ```typescript // Claude Code 的 cost-tracker.ts 核心邏輯 function addToTotalSessionCost(inputTokens, outputTokens, model, speed) { const costPerInputToken = MODEL_COSTS[model]?.input ?? UNKNOWN_FALLBACK const cost = inputTokens * costPerInputToken + outputTokens * costPerOutputToken sessionCost += cost // 支援 advisor 模型遞迴計費、Fast Mode OTEL 標記 } ``` **實作要點**: 1. 每個任務設預算上限,累計追蹤,超限就停 2. 未知模型用 fallback 費率 + analytics 警告 3. Session 成本持久化到 project config(以 sessionId 隔離) ## Prompt Cache 12 種 Break 原因 | # | 原因 | 影響 | 防禦 | |---|------|------|------| | 1 | System prompt 內容變化 | 全 bust | 靜態/動態邊界 | | 2 | Tool schema 變化 | 全 bust | 不排序工具陣列 | | 3 | MCP 工具動態載入 | 部分 bust | Deferred loading | | 4 | Agent list 變化 | 全 bust | 移到 attachment | | 5 | `currentDate` 跨日 | 全 bust | **已知缺陷,應移到 dynamic zone** | | 6 | Compaction 改

What's inside
Steps it walks through
  1. 模型成本矩陣
  2. Cost Envelope 模式
  3. Prompt Cache 12 種 Break 原因
  4. 使用者端避坑清單
  5. Token Estimation 三策略
  6. Compaction 成本陷阱
  7. 參考
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the cc-cost-engineering skill do?

AI Agent 成本工程 — 基於 Claude Code 的成本追蹤、prompt cache 最佳化、token 預算控制逆向分析。Use when: 優化 token 消耗、設計成本控制機制、分析 cache 效率、選擇模型配置。

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill cc-cost-engineering --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going