Token Optimization Guide
Practical guide to reducing GitHub Copilot token spend while keeping answers and code useful.
Start with Part 1 Jump to Practical Setup Concise practitioner briefing Full 8-hour workshop
What This Covers
- Why token usage actually costs money under Usage-Based Billing
- Why output control usually beats prompt compression on raw ROI
- How to shrink always-on context, history, and tool overhead
- How model-specific prompt guides improve first-pass quality and reduce rework
- When Ask Mode, Edit Mode, and Agent Mode make financial sense
- How to set enterprise guardrails without relying on unsupported controls
- How to turn this repo into repeatable team habits
Fastest Wins
- Constrain output by default:
Code only, no explanation.andNo explanations unless asked. - Keep
.github/copilot-instructions.mdsmall and specific. - Protect cache in long sessions: keep
{model, reasoning effort, loaded skills, active MCP/tool set, agent/profile}stable; if you must change one, start a fresh chat with a short handoff summary. - Use Ask Mode for questions that do not need tools.
- Retune prompts and instructions against the official guide for your target model.
- Disable MCP servers you are not using.
- Convert DOCX/PDF/Office/media inputs to Markdown before AI work; start with MarkItDown.
- Audit long-running agent sessions and repeated back-and-forth.
- Install one shell-output filter: RTK or
snip. These CLI proxies filtergit, test runners,grep, build tools, and other command output before it reaches the agent. Use one filter layer per command path; do not stack them by default. - Build a persistent codebase graph with Graphify — map code once via tree-sitter AST, write
graphify-out/graph.json, then let agents query the graph instead of re-reading project files each session. Install:uv tool install graphifyy.
Read by Topic
Foundations
Techniques
- Prompt Compression
- Language Comparison
- Context Management
- Output Control
- Workflow Optimization
- Always-On Context Problem
- MCP & Tool Costs
Comparisons
Implementation
Quick Terms
- UBB: usage-based billing. Copilot Business and Enterprise spend is tracked through AI-credit usage rather than request counters.
- AI credits: the pooled billing unit used after the cutover.
- Auto mode: Copilot's default model selector. Good default lane when you do not need to pin a model.
- Ask Mode: single-shot interaction. Lowest-overhead choice for simple questions.
- Agent Mode: multi-step interaction. Higher leverage, higher cost.
- Content Exclusion: admin control for keeping selected repo content out of Copilot context.
- Format tax: extra tokens from rich file metadata and layout noise in DOCX, PDF, HTML, slides, spreadsheets, images, and audio/video extraction. Convert to Markdown first.
Useful Links
- Official GitHub Copilot docs
- Usage-based billing for organizations and enterprises
- OpenAI Tokenizer
- Awesome GitHub Copilot Customizations
- LLMLingua
- Caveman project
- RTK — Rust Token Killer
- snip — YAML-extensible shell-output filter for Copilot CLI and other agent shells
- Tokentop — local live dashboard for agent token, cost, and burn-rate visibility; supports Copilot CLI
- minimal-context-tools — skill pack for lower-context CLI search/query patterns
- Graphify — build a persistent knowledge graph of your codebase; agents query
graphify-out/graph.jsoninstead of re-reading files. Supports GitHub Copilot, VS Code workflows, and other assistants. PyPI package:graphifyy - Microsoft MarkItDown — convert PDF, Office files, images, audio, HTML, ZIP contents, YouTube URLs, EPUBs, and more to Markdown for LLM workflows
- Marc Bara: "Your .docx Is Wasting 33% of Your AI Budget"
- Dina Berry: "How I Cut Token Usage from 52% to 13%" — real measured numbers from a Copilot CLI production setup (Microsoft/GitHub content contributor)
Notes
/chronicleis Copilot CLI only (also available inside JetBrains via interactive Copilot CLI sessions). It is not available in VS Code — use AI Engineering Coach there. Subcommands includecost tips,improve,tips,standup,search, andreindex.- Usage-Based Billing is labeled UBB in this repo.