Communitygithub.com

トークンバジェットアドバイザー (TBA)

Claude が応答する前に、ユーザーに応答の深さを選択してもらうためのスキルです。

トークンバジェットアドバイザー (TBA) とは?

Token Budget Advisor (TBA) は、Claude Code などの AI エージェント上で動作するスキルで、ユーザーが応答の詳細度や長さを事前に選択できるようにします。プロンプトの入力トークン数と複雑さをヒューリスティックに推定し、複数の深さレベル(25%: 簡潔、50%: 適度、75%: 詳細、100%: 網羅)を提示します。ユーザーがレベルを指定した場合はそのレベルで即座に応答し、セッション中は一度設定したレベルを維持します。これにより、無駄な長文回答を避け、状況に応じた効率的な対話が可能になります。このスキルは特に開発者やパワーユーザーがトークン消費を管理したい場面で有用です。

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

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

トークンバジェットアドバイザー (TBA) は何をしますか?

Claude が応答する前に、応答の深さをユーザーに選んでもらうためのスキルです。

使用タイミング

  • ユーザーが応答の長さや詳細度を制御したい場合
  • ユーザーが「トークン」「予算」「深さ」「応答長」に言及した場合
  • ユーザーが「短く」「簡潔に」「25% で」「詳細に」「網羅的に」などと言った場合
  • ユーザーが最初から詳細度/深さを選びたい場合

トリガーしない場合: ユーザーがすでにこのセッションでレベルを設定している(その設定を暗黙的に維持する)、または答えが簡単に 1 行で済む場合。

仕組み

ステップ 1 — 入力トークンの推定

リポジトリの標準的なコンテキスト予算ヒューリスティックを使用して、プロンプトのトークン数を頭の中で推定します。

context-budget と同じ較正ガイダンスを使用します:

  • 散文: 単語数 × 1.3
  • コード主体または混合/コードブロック: 文字数 / 4

混合コンテンツの場合は、主要なコンテンツタイプを採用し、推定ヒューリスティックを維持します。

ステップ 2 — 複雑さによる応答サイズの推定

プロンプトを分類し、乗数範囲を適用して応答ウィンドウ全体を求めます:

複雑さ乗数範囲プロンプトの例
単純3× – 8×「Xとは?」、はい/いいえ、単一の事実
中程度8× – 20×「Xはどう動くの?」
中高10× – 25×コンテキスト付きのコードリクエスト
複雑15× – 40×多項目分析、比較、アーキテクチャ
創造的10× – 30×ストーリー、エッセイ、ナラティブライティング

応答ウィンドウ = 入力トークン数 × 最小乗数 ~ 入力トークン数 × 最大乗数 (ただし、モデルの設定された出力トークン制限を超えないこと)。

ステップ 3 — 深さオプションの提示

実際の推定値を使用して、回答の前にこのブロックを表示します:

プロンプトを分析中...

入力: ~[N] トークン  |  タイプ: [type]  |  複雑さ: [level]  |  言語: [lang]

深さレベルを選択してください:

[1] 簡潔     (25%)  ->  ~[トークン数]   直接回答のみ、前置きなし
[2] 適度     (50%)  ->  ~[トークン数]   回答 + コンテキスト + 1つの例
[3] 詳細     (75%)  ->  ~[トークン数]   代替案を含む完全な回答
[4] 網羅    (100%)  ->  ~[トークン数]   すべて、制限なし

どのレベルにしますか? (1-4 または「25% 深さ」「50% 深さ」「75% 深さ」「100% 深さ」)

精度: ヒューリスティック推定 約85-90% (±15%)。

レベル別トークン推定(応答ウィンドウ内):

  • 25% → 最小 + (最大 - 最小) × 0.25
  • 50% → 最小 + (最大 - 最小) × 0.50
  • 75% → 最小 + (最大 - 最小) × 0.75
  • 100% → 最大

ステップ 4 — 選択されたレベルで応答

レベル目標の長さ含める内容省略する内容
25% 簡潔最大2~4文直接回答、主要な結論コンテキスト、例、ニュアンス、代替案
50% 適度1~3段落回答 + 必要なコンテキスト + 1つの例詳細分析、エッジケース、参考文献
75% 詳細構造化された応答複数の例、長所/短所、代替案極端なエッジケース、網羅的な参考文献
100% 網羅制限なしすべて — 完全な分析、すべてのコード、すべての視点なし

ショートカット — 質問をスキップ

ユーザーがすでにレベルを指定している場合は、質問せずにそのレベルで即座に応答します:

ユーザーの発言レベル
「1」/「25% 深さ」/「短く」/「簡潔に」/「tldr」25%
「2」/「50% 深さ」/「適度に」/「バランスよく」50%
「3」/「75% 深さ」/「詳細に」/「ちゃんと答えて」75%
「4」/「100% 深さ」/「網羅的に」/「完全に深堀りして」100%

セッション中にユーザーがレベルを設定した場合、以降の応答では暗黙的にその設定を維持し、変更があればそれに従います。

精度に関する注意

このスキルはヒューリスティック推定を使用しており、実際のトークナイザーは使用していません。精度は約85-90%、ばらつき±15%です。常に免責事項を表示してください。

例

トリガーする場合

  • 「まず簡潔なバージョンを教えて。」
  • 「あなたの回答は何トークンになりますか?」
  • 「50% の深さで答えて。」
  • 「要約ではなく網羅的な回答が欲しい。」
  • 「短いバージョンを最初に、その後詳細なバージョンをください。」

トリガーしない場合

  • 「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.

関連スキル