| name | prompt-budget-advisor |
| description | Estimate prompt size, context-window cost, and prompt quality, then rewrite prompts to be shorter, clearer, and easier for Codex, Claude, ChatGPT, or API agents to execute. Use when the user asks how much limit/context/token budget a prompt may consume, wants to improve a prompt before sending it, asks why a prompt is too long or vague, or wants a compact/structured/split version of a prompt. |
Prompt Budget Advisor
Use this skill to audit a prompt before it is sent, or to analyze a prompt the user already wrote.
Do not claim exact total context usage: system messages, conversation history, tool output, files, and model-specific tokenization add overhead the skill cannot always see.
Workflow
-
Identify the prompt text. If the user did not provide it, ask for the prompt or the file that contains it.
-
Measure the visible prompt. When shell access is available, run:
node scripts/estimate_prompt.mjs --file <prompt-file>
Or pipe text to:
node scripts/estimate_prompt.mjs
If tools are unavailable, estimate manually with this rule of thumb: Latin-language prose is roughly 1 token per 4 characters; code, JSON, logs, tables, and dense symbols are often closer to 1 token per 2.5-3.5 characters.
-
Classify the visible prompt:
- Tiny: under 500 estimated tokens.
- Normal: 500-1,500 estimated tokens.
- Heavy: 1,500-4,000 estimated tokens.
- Very heavy: 4,000-12,000 estimated tokens.
- Split recommended: above 12,000 estimated tokens, or when the prompt mixes unrelated goals.
-
Audit quality and waste:
- Duplicated context or repeated constraints.
- Vague success criteria such as "make it better" without target behavior.
- Multiple unrelated tasks in one prompt.
- Long pasted logs, source files, docs, or transcripts without a focused question.
- Missing concrete inputs, file paths, output format, constraints, or acceptance criteria.
- Instructions that belong in a reusable system/developer prompt rather than every user prompt.
-
Rewrite the prompt while preserving the user's intent, non-negotiable constraints, files, commands, and expected output.
Response Format
Reply in the user's language. Keep the response compact unless the user asks for detail.
Use this structure:
**Stima**
- Visibile: ~N token (range X-Y), C caratteri, W parole
- Fascia: <tiny|normal|heavy|very heavy|split recommended>
- Nota: stima del prompt visibile, non del contesto totale reale
**Problemi**
- ...
**Prompt migliorato**
...
**Variante breve**
...
For large prompts, add:
**Meglio spezzarlo cosi**
1. Prompt 1: ...
2. Prompt 2: ...
3. Prompt 3: ...
Rewrite Rules
- Put the task first.
- Keep only context that changes the answer.
- Convert scattered constraints into a short checklist.
- Prefer file paths, repo references, or attached files over pasted bulk text when the agent can read those files.
- State the desired output shape explicitly.
- For coding tasks, include relevant files, failure symptoms, commands already run, acceptance criteria, and whether edits are allowed.
- For API prompts, separate persistent behavior from task-specific input. Suggest system/developer instructions for stable policy and a shorter user prompt for the current request.
- For creative tasks, keep tone, audience, length, examples, and hard constraints; remove repeated adjectives.
- If the original prompt is already good, say so and make only small tightening suggestions.
Cautions
- Token counts are approximate unless a model-specific tokenizer is explicitly available.
- Do not optimize away essential context just to reduce token count.
- Do not invent missing requirements. Mark assumptions clearly or ask one concise question when the missing information changes the rewrite.