Communitygithub.com

Token Budget Advisor (TBA)

在 Claude 回答之前,攔截回應流程,讓使用者選擇回應深度。

Token Budget Advisor (TBA) 是什麼?

Token Budget Advisor (TBA) 是一項 AI 代理技能,可讓使用者在 Claude 產生回覆前,動態選擇回應的詳細程度。它能估算輸入 token 數,根據複雜度分類提示,並提供四個深度等級(精簡、中等、詳細、詳盡)供選擇。使用者可直接指定等級或使用百分比捷徑(如“25% depth”),而無需每次都手動選擇。此技能適用於需要控制回應長度的情境,例如要求簡短摘要或深入分析。它採用啟發式估算方法(準確率約 85-90%,變異 ±15%),無需實際詞元化器即可運作。支援 Claude Code、Cursor 等平台,並能記憶會話中已設定的深度等級,無需重複詢問。

相容平台✓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 回答之前,攔截回應流程,讓使用者選擇回應深度。

使用時機

  • 使用者想要控制回應的長度或詳細程度
  • 使用者提及 token、預算、深度或回應長度
  • 使用者說「短版」、「TL;DR」、「簡短」、「25%」、「詳盡」等
  • 任何使用者想事先選擇深度/細節層級的時候

不要觸發當:使用者已在本次對話中設定過層級(默默維持該設定),或答案顯然只有一行。

運作方式

Step 1 — 估算輸入 token

使用儲存庫的標準上下文預算啟發法,在腦中估算提示的 token 數量。

採用與 context-budget 相同的校準指引:

  • 散文:單字數量 × 1.3
  • 程式碼為主或混合/程式碼區塊:字元數 / 4

對於混合內容,使用主要的內容類型並維持估算啟發法。

Step 2 — 根據複雜度估算回應大小

將提示分類,然後套用倍數範圍以取得完整的回應區間:

複雜度倍數範圍範例提示
簡單3× – 8×「X 是什麼?」、是非題、單一事實
中等8× – 20×「X 如何運作?」
中高10× – 25×包含上下文的程式碼請求
複雜15× – 40×多部分分析、比較、架構探討
創意10× – 30×故事、散文、敘事寫作

回應區間 = 輸入 token × mult_min 到 輸入 token × mult_max(但不超過你模型的設定輸出 token 限制)。

Step 3 — 呈現深度選項

在回答之前呈現以下區塊,使用實際的估算數字:

分析您的提示...

輸入:~[N] tokens  |  類型:[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%)。

層級 token 估算(在回應區間內):

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

Step 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%。務必顯示免責聲明。

範例

觸發情境

  • 「先給我短版。」
  • 「你的回答會用多少 token?」
  • 「以 50% 深度回應。」
  • 「我要詳盡的回答,不是摘要。」
  • 「Dame la version corta y luego la detallada。」

不觸發情境

  • 「什麼是 JWT token?」
  • 「結帳流程使用一個付款 token。」
  • 「這樣正常嗎?」
  • 「完成重構。」
  • 在使用者已為本次對話選擇深度後的後續問題

來源

獨立技能,源自 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.

相關技能