Context Budget logo

Context Budget

Community
felvieira
context-budget

Mede e reduz o peso de contexto carregado pelo agente. Trigger em: "contexto inchado", "context overflow", "quanto contexto estou usando", "sessao lenta", "respostas degradadas", "context budget", "tokens carregados", "custo fixo de contexto", "overhead de rules", "overhead dos agents", "impacto do MCP no contexto", "headroom de contexto".

Overview

Publisherfelvieira
Repositoryclaude-skills-fv
Skill namecontext-budget
Stars
28
Forks
5
Bundled files
Instructions only
LicenseApache-2.0
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 felvieira 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.
    https://github.com/felvieira/claude-skills-fv/tree/main/skills/49-context-budget
  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/felvieira/claude-skills-fv.git /tmp/claude-skills-fv
mkdir -p .claude/skills
cp -r /tmp/claude-skills-fv/skills/49-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.

Skill 49 — Context Budget

Objetivo

Auditar o peso observável de contexto carregado nesta sessão: instruções raiz, saída de hooks, regras ativas, skills invocadas e catálogo de tools MCP habilitadas. Não confunda bytes em disco com tokens enviados ao modelo.

Distinção crítica:

  • Skill 30 (cost-tracker) → rastreia tokens/$ gastos em runtime (completions, tool calls)
  • Skill 49 (context-budget) → audita tokens carregados no contexto antes de qualquer completion (system prompt, CLAUDE.md, rules, skills, MCP descriptions)

Quando usar

  • Sessão com latência alta ou model degradation (possível context overflow)
  • Repo novo com .bot/ — auditoria do que foi instalado
  • Antes de habilitar novo MCP server ou subagent
  • Após instalar rules system path-scoped — verificar overhead real
  • Quando /savings mostrar contexto inchado

Protocolo

Fase 0 — Identificar componentes carregados

Listar o que está no contexto da sessão:

1. Instruções raiz efetivamente carregadas (AGENTS.md/CLAUDE.md, global e projeto, conforme host)
2. Catalogo de skills do plugin: name + description de TODAS as skills habilitadas (todo turno; nao e lazy)
3. Body de SKILL.md / subagents invocados nesta sessao (lazy — so os disparados)
4. Rules path-scoped ativas nesta tarefa
5. Descrições/schema de tools MCP realmente anunciadas pelo host (todo turno, por servidor enabled)
6. Contexto adicional emitido por hooks, arquivos lidos e histórico desta sessão

Fase 1 — Estimar peso por componente

Estimar tokens somente para componentes observados, com caracteres ÷ 4 como proxy explícito:

  • Bytes no arquivo medem armazenamento, não provam que o host carregou aquele arquivo.
  • scripts/skill-catalog-budget.mjs e scripts/skill-health.mjs reportam inventário local em chars e bytes; seus tokens são proxy, não medição.
  • Descrições/schema de MCP ou agents são diferentes dos corpos completos em agents/*.md; sem catálogo runtime, reportar como não mensurado.
  • Histórico, prefixo de sistema e cache do provedor exigem telemetria da sessão para medição real; não inventar percentual de headroom.

Para separar as camadas:

  1. Em disco: bytes UTF-8 dos arquivos conhecidos.
  2. Inventário de catálogo: name + description encontrados no frontmatter; não afirmar que o host injetou todos.
  3. Payload observado: capture o JSON do hook e passe --observed <arquivo> aos scripts; conte systemMessage/additionalContext.
  4. Host não exposto: MCP, prefixo, cache, histórico e skills não anunciadas permanecem “não mensurados”.

Não execute --apply durante uma auditoria. A compactação pode descartar triggers; revise o relatório e rode os evals antes de qualquer mudança.

Fase 2 — Categorizar por urgência

CategoriaFonteComo medir
Sempre presente quando o host carregaInstruções raiz, name+description de cada skill do plugin, schema das tools MCP enabledMedir os arquivos/payloads reais. Catalogo do kit: node scripts/skill-catalog-budget.mjs
Sob demandaBody do SKILL.md e corpos de subagents invocadosVerificar os invocados
Path-scoped.claude/rules/*.mdVerificar paths/globs ativados
HistóricoConversa acumuladaConsultar telemetria do host

Fase 3 — Relatório de budget

Reporte, quando observável, caracteres e estimativa por fonte: instruções raiz (global/projeto), saída real dos hooks, skills invocadas, rules ativas e catálogo MCP habilitado. Informe separadamente o que está apenas em disco e o que o host não expôs. Use tamanho de janela do modelo somente se comprovado pela sessão; sem isso, não estime headroom nem use tabelas fictícias como evidência.

Fase 4 — Alertas de overflow

Use o limite efetivo da janela do modelo fornecido pelo host, se disponível. Calcule alertas em 80% e 95% da janela medida; sem limite ou histórico da sessão, apenas descreva crescimento observado, sem declarar overflow.

Sinais de overflow iminente:

  • Respostas ficam genéricas ou "esquecem" instruções anteriores
  • Tool calls começam a falhar com erros estranhos
  • /savings mostra context_tokens subindo exponencialmente

Ações corretivas: reduza leitura/reinjeção desnecessária; carregue skill e rule quando o alvo justificar; desabilite MCP não usado apenas após verificar os ativos e obter aprovação para modificar configuração. Para histórico longo, compacte de forma controlada ou abra sessão nova com handoff. Não altere agentes globais baseado só no inventário de arquivos.

Integração com kit

  • Invocar após /savings quando contexto parecer inchado
  • Invocar antes de habilitar novo MCP server
  • Usar em conjunto com skill 30 (cost-tracker) para visão completa: custo fixo (contexto) + custo variável (completions)
  • Output de Fase 3 pode ser salvo em memory/context-budget-YYYY-MM-DD.md

Exemplo de invocação

Skill({ skill: "dev-team-kit-fv:49-context-budget" })
// Carrega playbook; agente executa Fases 0-3 e reporta

Ou via comando:

/context-budget

Frequently asked questions

What does the Context Budget AI skill do?

Mede e reduz o peso de contexto carregado pelo agente. Trigger em: "contexto inchado", "context overflow", "quanto contexto estou usando", "sessao lenta", "respostas degradadas", "context budget", "tokens carregados", "custo fixo de contexto", "overhead de rules", "overhead dos agents", "impacto do MCP no contexto", "headroom de contexto".

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/felvieira/claude-skills-fv/tree/main/skills/49-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 felvieira under the Apache-2.0 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 👇