Communitygithub.com

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

Claude Code の応答フローに介入し、応答の深さ(トークン消費量)を事前にユーザーが選択できるようにするスキルです。

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

Token Budget Advisor (TBA) は、Claude Code 上で動作する AI エージェントスキルです。ユーザーのプロンプトから入力トークン数を推定し、複雑度に応じた応答トークンの範囲を算出します。そして、ユーザーに「最小限(25%)」「標準(50%)」「詳細(75%)」「網羅的(100%)」の4段階から応答の深さを選択させ、選択されたレベルに応じた詳細度で回答を生成します。ユーザーが「tldr」「詳細な回答」などのキーワードを発言した場合、質問をスキップして即座に対応するレベルで応答するショートカット機能も備えています。このスキルはヒューリスティックな推定(精度約85~90%)に基づいており、実際のトークナイザーは使用しません。同じセッション内で一度レベルが設定されると、変更がない限りそのレベルが静かに維持されるため、効率的な対話が可能です。

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

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

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

ドキュメント

Token Budget Advisor (TBA)

Claude が回答する 前に、応答の深さをユーザーが選択できるよう、応答フローに割り込みます。

使用するタイミング

  • ユーザーが応答の長さや詳細度を制御したい場合
  • ユーザーがトークン、予算、深さ、応答長に言及した場合
  • ユーザーが「short version」「tldr」「brief」「al 25%」「exhaustive」などを発言した場合
  • ユーザーが事前に詳細度/深さを選択したい場合

トリガーしない場合:ユーザーがすでにセッション内でレベルを設定している(そのレベルを静かに維持する)、または回答が明白に1行である場合。

仕組み

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

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

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%の深さで応答してください。」
  • 「要約ではなく、網羅的な回答が欲しい。」
  • 「最初に短い版、次に詳細版をください。」

トリガーされない場合

  • 「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/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

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.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

関連スキル