Context Budget logo

Context Budget

Community
mturac
context-budget

エージェント、スキル、MCPサーバー、ルールにわたってOpenAI Codexのコンテキストウィンドウ消費を監査します。肥大化、冗長なコンポーネントを特定し、優先順位付けされたトークン節約の推奨事項を生成します。

Overview

Publishermturac
Repositoryeverything-openai-codex
Skill namecontext-budget
Stars
91
Forks
2
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by mturac on GitHub. Read the source before you install it.

Installation

Install the Context Budget AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/mturac/everything-openai-codex.git /tmp/everything-openai-codex
mkdir -p .claude/skills
cp -r /tmp/everything-openai-codex/docs/ja-JP/skills/context-budget .claude/skills/context-budget
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Context Budget in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Context Budget on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Context Budget is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

コンテキストバジェット

OpenAI Codexセッションで読み込まれたすべてのコンポーネントのトークンオーバーヘッドを分析し、コンテキストスペースを取り戻すための実用的な最適化を表示します。

使用時期

  • セッションのパフォーマンスが低下しているか、出力品質が低下している場合
  • 多くのスキル、エージェント、またはMCPサーバーを追加した後
  • 実際に持っているコンテキストのヘッドルームを確認したい場合
  • コンポーネントを追加する計画があり、スペースがあるか確認したい場合
  • /context-budgetコマンドを実行する場合(このスキルがそれをサポートします)

動作方法

フェーズ1: インベントリ

すべてのコンポーネントディレクトリをスキャンしてトークン消費を推定します:

エージェント (agents/*.md)

  • ファイルごとの行数とトークンをカウント(単語数 × 1.3)
  • descriptionフロントマターの長さを抽出
  • フラグ: 200行超のファイル(重い)、30単語超のdescription(肥大化したフロントマター)

スキル (skills/*/SKILL.md)

  • SKILL.mdごとのトークンをカウント
  • フラグ: 400行超のファイル
  • .agents/skills/の重複コピーを確認 — 二重カウントを避けるために同一コピーをスキップ

ルール (rules/**/*.md)

  • ファイルごとのトークンをカウント
  • フラグ: 100行超のファイル
  • 同一言語モジュール内のルールファイル間のコンテンツの重複を検出

MCPサーバー (.mcp.jsonまたはアクティブなMCP設定)

  • 設定されたサーバー数と合計ツール数をカウント
  • スキーマオーバーヘッドをツールあたり約500トークンと推定
  • フラグ: 20以上のツールを持つサーバー、シンプルなCLIコマンド(ghgitnpmsupabasevercel)をラップするサーバー

CODEX.md (プロジェクト + ユーザーレベル)

  • CODEX.mdチェーンのファイルごとのトークンをカウント
  • フラグ: 合計300行超

フェーズ2: 分類

すべてのコンポーネントをバケットに分類します:

バケット基準アクション
常に必要CODEX.mdで参照されている、アクティブなコマンドをサポート、または現在のプロジェクトタイプに一致保持
時々必要ドメイン固有(例:言語パターン)、CODEX.mdで未参照オンデマンドアクティベーションを検討
めったに必要でないコマンド参照なし、コンテンツ重複、または明らかなプロジェクト一致なし削除または遅延ロード

フェーズ3: 問題の検出

以下の問題パターンを特定します:

  • 肥大化したエージェントdescription — フロントマターに30単語超のdescriptionはすべてのTaskツール呼び出しで読み込まれる
  • 重いエージェント — 200行超のファイルはすべてのスポーン時にTaskツールのコンテキストを膨らませる
  • 冗長なコンポーネント — エージェントロジックを複製するスキル、CODEX.mdを複製するルール
  • MCPの過剰サブスクリプション — 10以上のサーバー、または無料で利用できるCLIツールをラップするサーバー
  • CODEX.mdの肥大化 — 冗長な説明、古いセクション、ルールであるべき指示

フェーズ4: レポート

コンテキストバジェットレポートを生成します:

Context Budget Report
═══════════════════════════════════════

Total estimated overhead: ~XX,XXX tokens
Context model: Codex Standard (200K window)
Effective available context: ~XXX,XXX tokens (XX%)

Component Breakdown:
┌─────────────────┬────────┬───────────┐
│ Component       │ Count  │ Tokens    │
├─────────────────┼────────┼───────────┤
│ Agents          │ N      │ ~X,XXX    │
│ Skills          │ N      │ ~X,XXX    │
│ Rules           │ N      │ ~X,XXX    │
│ MCP tools       │ N      │ ~XX,XXX   │
│ CODEX.md       │ N      │ ~X,XXX    │
└─────────────────┴────────┴───────────┘

WARNING: Issues Found (N):
[ranked by token savings]

Top 3 Optimizations:
1. [action] → save ~X,XXX tokens
2. [action] → save ~X,XXX tokens
3. [action] → save ~X,XXX tokens

Potential savings: ~XX,XXX tokens (XX% of current overhead)

詳細モードでは、ファイルごとのトークン数、最も重いファイルの行ごとの内訳、重複するコンポーネント間の特定の冗長行、ツールごとのスキーマサイズ推定を含むMCPツールリストも出力します。

基本監査

User: /context-budget
Skill: Scans setup → 16 agents (12,400 tokens), 28 skills (6,200), 87 MCP tools (43,500), 2 CODEX.md (1,200)
       Flags: 3 heavy agents, 14 MCP servers (3 CLI-replaceable)
       Top saving: remove 3 MCP servers → -27,500 tokens (47% overhead reduction)

詳細モード

User: /context-budget --verbose
Skill: Full report + per-file breakdown showing planner.md (213 lines, 1,840 tokens),
       MCP tool list with per-tool sizes, duplicated rule lines side by side

拡張前の確認

User: I want to add 5 more MCP servers, do I have room?
Skill: Current overhead 33% → adding 5 servers (~50 tools) would add ~25,000 tokens → pushes to 45% overhead
       Recommendation: remove 2 CLI-replaceable servers first to stay under 40%

ベストプラクティス

  • トークン推定: 散文には単語数 × 1.3を、コードが多いファイルには文字数 / 4を使用
  • MCPが最大のレバー: 各ツールスキーマはおよそ500トークンかかります。30ツールのサーバーはスキル全部よりも多くかかります
  • エージェントdescriptionは常に読み込まれる: エージェントが呼び出されなくても、そのdescriptionフィールドはすべてのTaskツールのコンテキストに存在します
  • デバッグには詳細モード: 特定のファイルがオーバーヘッドを駆動していることを正確に特定する必要がある場合に使用し、通常の監査には使用しない
  • 変更後に監査: エージェント、スキル、またはMCPサーバーを追加した後に実行して、クリープを早期にキャッチ

Frequently asked questions

What does the Context Budget AI skill do?

エージェント、スキル、MCPサーバー、ルールにわたってOpenAI Codexのコンテキストウィンドウ消費を監査します。肥大化、冗長なコンポーネントを特定し、優先順位付けされたトークン節約の推奨事項を生成します。

Why use Context Budget on TypingMind?

Because you install it once and use it with any model. Context Budget is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Context Budget in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/mturac/everything-openai-codex/tree/main/docs/ja-JP/skills/context-budget. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Context Budget?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Context Budget?

As many as you like. As long as a model supports skills, you can use Context Budget with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Context Budget AI skill free?

Yes. It is published on GitHub by mturac under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇