Communitygithub.com

Token Budget Advisor(代币预算顾问)

在 Claude 回答之前拦截响应流程,让用户选择回复的深度或详细程度。通过启发式估算输入和输出代币,提供可选的详细级别(25% 到 100%)。

Token Budget Advisor(代币预算顾问) 是什么?

Token Budget Advisor (TBA) 是一种 AI 代理技能,旨在赋予用户对模型响应详细程度的直接控制权。它通过在 Claude 开始生成回复前,拦截正常的响应流程,并向用户呈现一个基于代币估算的深度选择菜单来实现这一功能。该技能利用启发式方法估算输入代币数量(基于文本/代码特征),然后根据回复的复杂度(简单、中等、复杂或创意)预测输出窗口大小,并提供四个预设深度级别:Essential (25%)、Moderate (50%)、Detailed (75%) 和 Exhaustive (100%)。用户既可以从菜单中选择,也可以使用快捷短语(如“short version”或“50% depth”)直接指定级别。一旦在一个会话中设置了级别,TBA 会静默地维持该级别,直到用户明确更改。该技能支持 Claude Code 等平台,并源自一个独立的 GitHub 仓库,提供了一个轻量级、无需外部工具即可实现预算感知对话的解决方案。其代币估算精度约为 85-90%,并始终包含相关免责声明。

兼容平台✓Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/token-budget-advisor

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Token Budget Advisor (TBA)

在 Claude 回答之前拦截响应流程,让用户选择回复的深度。

适用场景

  • 用户想要控制回复的长度或详细程度
  • 用户提及代币、预算、深度或回复长度
  • 用户说“short version”、“tldr”、“brief”、“al 25%”、“exhaustive”等。
  • 任何用户希望预先选择深度/详细级别的时机

请勿触发当:用户已在本会话中设置了级别(静默维持),或者答案本身很简单只有一行。

工作原理

步骤 1 — 估算输入代币

使用仓库的 canonical context-budget 启发式规则,在头脑中估算提示的代币数量。

使用与 context-budget 相同的校准指南:

  • 纯文本:字数 × 1.3
  • 代码密集型或混合/代码块:字符数 / 4

对于混合内容,使用主导内容类型,并保持估算启发式。

步骤 2 — 根据复杂度估算回复大小

对提示进行分类,然后应用乘数范围以获得完整的回复窗口:

复杂度乘数范围示例提示
简单3× – 8ד什么是 X?”,是/否,单一事实
中等8× – 20דX 是如何工作的?”
中高10× – 25×包含上下文的代码请求
复杂15× – 40×多部分分析、比较、架构设计
创意10× – 30×故事、文章、叙事写作

回复窗口 = input_tokens × mult_min 到 input_tokens × mult_max (但不要超过你模型的配置输出代币限制)。

步骤 3 — 呈现深度选项

在回答之前,使用实际估算的数字呈现以下块:

分析你的提示...

输入:~[N] 个代币  |  类型:[type]  |  复杂度:[level]  |  语言:[lang]

请选择你的详细程度:

[1] 精髓     (25%)  ->  ~[tokens]   仅直接回答,无开场白
[2] 适中     (50%)  ->  ~[tokens]   回答 + 必要上下文 + 1 个示例
[3] 详细     (75%)  ->  ~[tokens]   包含备选方案的完整回答
[4] 详尽    (100%)  ->  ~[tokens]   全部内容,无限制

请选择级别?(1-4 或说“25% depth”、“50% depth”、“75% depth”、“100% depth”)

精度:启发式估算 ~85-90% 准确度(±15%)。

各级别的代币估算(在回复窗口内):

  • 25% → min + (max - min) × 0.25
  • 50% → min + (max - min) × 0.50
  • 75% → min + (max - min) × 0.75
  • 100% → max

步骤 4 — 按所选级别回复

级别目标长度包含内容省略内容
25% 精髓最多 2-4 句话直接回答、关键结论上下文、示例、细微差别、备选方案
50% 适中1-3 段回答 + 必要上下文 + 1 个示例深度分析、边界情况、参考文献
75% 详细结构化回复多个示例、优缺点、备选方案极端边界情况、详尽参考文献
100% 详尽无限制全部内容 — 全面分析、所有代码、所有视角无

快捷方式 — 跳过提问

如果用户已经表明了级别,立即按该级别回复,无需提问:

用户所说级别
“1” / “25% depth” / “short version” / “brief answer” / “tldr”25%
“2” / “50% depth” / “moderate depth” / “balanced answer”50%
“3” / “75% depth” / “detailed answer” / “thorough answer”75%
“4” / “100% depth” / “exhaustive answer” / “full deep dive”100%

如果用户之前在会话中设置了级别,静默维持该级别用于后续回复,除非他们更改。

精度说明

此技能使用启发式估算 —— 无真实分词器。准确度 ~85-90%,偏差 ±15%。始终显示免责声明。

示例

触发场景

  • “先给我一个简短版本。”
  • “你的回答会使用多少个代币?”
  • “以 50% 的深度回复。”
  • “我要详尽的回答,不要摘要。”
  • “Dame la version corta y luego la detallada.”

不触发场景

  • “什么是 JWT 令牌?”
  • “结账流程使用了一个支付令牌。”
  • “这正常吗?”
  • “完成重构。”
  • 用户已为本会话选择了深度后的后续问题

来源

来自 TBA — Token Budget Advisor for Claude Code 的独立技能。 原始项目还附带了一个 Python 估算脚本,但此仓库保持技能自包含且仅使用启发式规则。

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

相关技能