{"id":51330316,"url":"https://github.com/olivomarco/github-copilot-token-optimization","last_synced_at":"2026-07-01T22:04:37.907Z","repository":{"id":361784514,"uuid":"1237987533","full_name":"olivomarco/github-copilot-token-optimization","owner":"olivomarco","description":"Techniques to optimize token usage on GitHub Copilot","archived":false,"fork":false,"pushed_at":"2026-06-19T12:48:43.000Z","size":1384,"stargazers_count":57,"open_issues_count":0,"forks_count":10,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-19T14:28:18.429Z","etag":null,"topics":["github-copilot","github-copilot-training","token-optimization"],"latest_commit_sha":null,"homepage":"https://olivomarco.github.io/github-copilot-token-optimization/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/olivomarco.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-13T17:46:55.000Z","updated_at":"2026-06-19T12:48:46.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/olivomarco/github-copilot-token-optimization","commit_stats":null,"previous_names":["olivomarco/github-copilot-token-optimization"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/olivomarco/github-copilot-token-optimization","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivomarco%2Fgithub-copilot-token-optimization","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivomarco%2Fgithub-copilot-token-optimization/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivomarco%2Fgithub-copilot-token-optimization/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivomarco%2Fgithub-copilot-token-optimization/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olivomarco","download_url":"https://codeload.github.com/olivomarco/github-copilot-token-optimization/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olivomarco%2Fgithub-copilot-token-optimization/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35024388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-01T02:00:05.325Z","response_time":130,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github-copilot","github-copilot-training","token-optimization"],"created_at":"2026-07-01T22:04:33.555Z","updated_at":"2026-07-01T22:04:37.895Z","avatar_url":"https://github.com/olivomarco.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Token Optimization Guide for GitHub Copilot\n\n\u003e [!IMPORTANT]\n\u003e **This is not official GitHub or Microsoft guidance.** This guide is a community resource born from real-world field experience — patterns observed, techniques tested, and lessons learned by practitioners adopting AI for development purposes. It reflects industry backspark: practical knowledge gathered from the ground up, not top-down product documentation. Use it to inform about optimization strategies, and adapt what works for the context of your customer. Official guidance lives at [docs.github.com/copilot](https://docs.github.com/copilot).\n\n\u003e A practical, data-driven guide to reducing token consumption while maintaining code quality.\n\u003e Covers Chat, Inline, and Coding Agent workflows.\n\n---\n\n## Quick Start — 12 Things to Do Right Now\n\n\u003e **June 1, 2026 — Usage-Based Billing (UBB) is live.** GitHub Copilot now bills real tokens (input + output + cached) drawn from pooled AI credits ($30/seat Business, $70/seat Enterprise) instead of request counters. Every technique in this guide translates directly into credit savings — and cache-friendly habits matter more than ever. See [Enterprise Governance](docs/12-enterprise-governance.md) for customer guardrails and [Model Selection \u0026 Pricing](docs/11-models-and-pricing.md) for model-cost guidance.\n\n\u003e **Output tokens cost much more than input tokens.** That's the most important pricing fact in this guide. Anthropic's public pricing makes the asymmetry concrete ($1/$5 Haiku, $3/$15 Sonnet, $5/$25 Opus per MTok input/output). Copilot's exact per-model UBB pricing table is not public yet, but UBB still makes verbose output disproportionately expensive. Most input tokens come from file context, history, and tool schemas — not from what you type. Your typed prompt is a tiny fraction of total input. Start with output control, then tackle structural input wins.\n\nDon't have time to read the full guide? Do these today and cut your token usage:\n\n| # | Action | Primary Effect | Time to Set Up |\n|---|--------|----------------|----------------|\n| 1 | **Request code-only responses** — add `Code only, no explanation.` to `copilot-instructions.md`. Highest per-token ROI: output costs 5× more than input, and this cuts 40-70% of output on every code task, permanently | Shrinks response length | 0 minutes |\n| 2 | **Constrain output format by default** — add `Bullets over paragraphs. No explanations unless asked.` to `copilot-instructions.md` | Keeps answers terse | 0 minutes |\n| 3 | **Shrink your always-on context** — compress `copilot-instructions.md` AND prune `AGENTS.md` to landmines only. Every token in either file is billed on every interaction (and every agent step). Strip filler, delete anything the agent discovers by reading code, delete LLM-generated `/init` boilerplate | Reduces always-on input/context | 15 minutes |\n| 4 | **Default to Auto model selection + protect cache stability** — use Auto as the baseline because it chooses from the supported Auto pool and gives a paid-plan discount. In long expensive threads, keep `{model, active MCP set, active agent/profile}` stable. If you must switch lanes, start a fresh chat with a short handoff summary. See [Model Selection \u0026 Pricing](docs/11-models-and-pricing.md) | Lowers billed rate on eligible usage and preserves cached-input discounts | 0 minutes |\n| 5 | **Use Ask Mode for simple questions** — reserve Agent Mode for multi-step tasks | Avoids agent overhead | 0 minutes (just choose the right mode) |\n| 6 | **Scope context with `applyTo:` paths** — split one large instructions file into small scoped ones that load only when relevant | Reduces always-on input/context | 15 minutes |\n| 7 | **Be precise in your prompts** — \"Add null check to `getUser()`\" not \"Can you please look at this and maybe add some error handling?\" Note: your typed prompt is a small fraction of total input; precision matters more for quality than for raw token savings | Improves task targeting | 0 minutes |\n| 8 | **Retune prompts to the target model** — provider prompting guides change by model/version. Paste the official guide URL into Copilot and ask it to adapt `.github/copilot-instructions.md`, agent profiles, or app prompts for the model you actually use | Reduces rework | 10 minutes per model change |\n| 9 | **Audit your MCP servers and injected tools** — disable unused MCP servers and VS Code extensions that add skills/tools; use a clean coding profile or focused custom agent for repeat workflows. Each MCP tool costs ~100-500 tokens per agent step | Removes tool/schema overhead | 5-10 minutes |\n| 10 | **Convert rich files to Markdown before AI work** — `.docx`, `.pdf`, `.pptx`, `.xlsx`, HTML, images, audio, video, and ZIPs carry format tax. [Marc Bara's writeup](https://medium.com/@marc.bara.iniesta/your-docx-is-wasting-33-of-your-ai-budget-86a3d229d042) shows the cost; use [Microsoft MarkItDown](https://github.com/microsoft/markitdown) before chat, agent, or RAG ingestion | Reduces noisy input context | 5 minutes |\n| 11 | **Run `/chronicle cost tips` and `/chronicle improve` weekly** (**Copilot CLI only**, experimental) — these slash commands work in interactive Copilot CLI sessions (not VS Code), not as a general Copilot Chat feature. `cost tips` analyzes your token spend and suggests reductions; `improve` finds recurring confusion in your CLI session history and generates custom-instruction fixes so the same misread intent stops costing tokens forever | Cuts recurring rework and direct token spend | 2 minutes per run |\n| 12 | **Try CodeAct for long tool chains** (**Copilot CLI only**, optional external plugin) — [`copilot-codeact-plugin`](https://github.com/jsturtevant/copilot-codeact-plugin) collapses multi-step tool chains into one sandboxed execution, which can reduce repeated replay of system prompt, prior messages, and tool definitions | Reduces tool-loop replay | 10-15 minutes |\n| 13 | **Plan first, then execute in a fresh session** — use plan mode (CLI) or Ask mode (VS Code) to agree the approach with a strong model, save the plan to `plan.md` or an issue, then run the execution from that plan in a clean session — often with a cheaper model. Reaching the right outcome the first time avoids the expensive rework of an agent coding in the wrong direction. See [Plan First, Then Execute §2.5.9](docs/06-workflow-optimization.md#259-plan-first-then-execute-and-route-the-phases) | Avoids wrong-direction rework; cheaper execution lane | 0 minutes (just sequence the work) |\n\n**Looking at this from an enterprise or customer-governance angle instead of an individual setup angle?** Start with [Enterprise Governance](docs/12-enterprise-governance.md). That chapter covers AI-credit budgets, per-user tightening, model-access policy, org instructions, and separate-organization tradeoffs.\n\n*Figures above are scoped to the mechanism named in each row, are not additive, and do not equal total bill reduction.*\n\nOutput control (#1, #2) pays off immediately and compounds — set it once, save on every call. Structural input control (#3, #6) compounds across every interaction. Model routing (#4, #5) reduces cost at the billing tier. Model-specific prompt tuning (#8) cuts waste by improving first-pass quality. MCP audit (#9) eliminates thousands of hidden tokens per agent task. Markdown conversion (#10) removes DOCX/PDF/HTML layout noise before the model ever sees it.\n\n---\n\n## Guide Contents\n\n### Part 1: Why Tokens Matter\n\nUnderstand BPE tokenization, why tokens matter for cost/speed/limits, and how GitHub Copilot uses tokens behind the scenes.\n\n→ **[Read Part 1](docs/01-why-tokens-matter.md)**\n\n---\n\n### Part 2: The Techniques\n\n#### [2.1 Prompt Compression](docs/02-prompt-compression.md)\n\nCaveman-speak, intensity levels (lite/full/ultra), structured formats, abbreviations, and code-centric prompting. 30-50% input token savings; combine with output control (2.4) for output savings.\n\n#### [2.2 Language Comparison](docs/03-language-comparison.md)\n\nData-backed comparison: English is the most token-efficient language in these examples. CJK costs 1.7-2.4x more. Includes tokenization tables for 8 languages.\n\n#### [2.3 Context Management](docs/04-context-management.md)\n\nCompress system instructions, compress memory files, scope context with `applyTo`, close unused editor tabs, convert non-text files to Markdown before AI work, configure Content Exclusion (Business/Enterprise admins), start fresh conversations. Control what gets sent to the model.\n\n#### [2.4 Output Control](docs/05-output-control.md)\n\n\"Code only, no explanation.\" Constrain response format. Set terse output as project default.\n\n#### [2.5 Workflow Optimization](docs/06-workflow-optimization.md)\n\nTerse commit messages, one-line PR reviews, Ask vs Agent mode selection, model-specific prompt tuning, and when NOT to compress.\n\n#### [2.6 The Always-On Context Problem](docs/07-agents-md-problem.md)\n\nResearch on LLM-generated context files suggests they often hurt agent correctness while inflating token cost. The same lesson applies to both `AGENTS.md` and `.github/copilot-instructions.md` — they are distinct conventions (different filenames, different historical owners) that nonetheless function as always-on context for Copilot today. Apply the \"landmines only\" approach to whichever file(s) your repo uses. Treat context files like a bug tracker, not a wiki.\n\n#### [2.7 MCP \u0026 Tool Costs](docs/08-mcp-tool-costs.md)\n\nThe hidden token tax: each MCP tool costs 100-500 tokens per agent step. 15 servers × 15 steps = 265K tokens of overhead. Audit guide included.\n\n---\n\n### Part 3: Comparisons \u0026 Data\n\nHead-to-head prompt comparisons, language tokenization tables, the complete technique-by-technique matrix (40+ techniques), and quality impact assessment with the diminishing returns curve.\n\n→ **[Read Part 3](docs/09-comparisons-data.md)**\n\n---\n\n### Part 4: Practical Setup\n\nStep-by-step: configure Copilot, optimize the Coding Agent, configure agent mode, and build the habit. Includes VS Code settings, decision frameworks, and a 4-week adoption plan.\n\n→ **[Read Part 4](docs/10-practical-setup.md)**\n\n---\n\n### Part 4.2: Model Selection \u0026 Pricing\n\nDedicated page on models, PRU-era multiplier history, current Auto guidance, plan availability, and where vendor input/output token pricing fits while Copilot's exact per-model UBB table remains unpublished. Includes links to the official GitHub Docs pages for Auto model selection, billing, and plan/model availability.\n\n→ **[Read Part 4.2](docs/11-models-and-pricing.md)**\n\n---\n\n### Part 4.3: Enterprise Governance\n\nDedicated chapter for customer-facing admin guidance: usage-based billing guardrails, AI-credit budgets, spend cohorts, FinOps-as-code automation, model-access policy, org-level instructions, and separate-organization tradeoffs.\n\n→ **[Read Part 4.3](docs/12-enterprise-governance.md)**\n\n---\n\nNeed the glossary, quick terms, tools, or core external links? Go to [Guide Home](docs/index.md).\n\n---\n\n## Highest-Impact Techniques\n\nRanked by cost impact. Output first — it costs 5× more per token than input.\n\n1. **Output control** — \"Code only, no explanation\" + terse default in `copilot-instructions.md`. 40-70% output savings on code tasks, 30-60% across all interactions. One instruction, permanent.\n2. **Shrink always-on context** (`copilot-instructions.md` + `AGENTS.md`) — compress filler, prune to landmines only, delete LLM-generated boilerplate. Compounds on every interaction and agent step; 20-23% agent-task reduction plus better correctness\n3. **Ask Mode for simple questions** — 60-90% savings by avoiding Agent overhead\n4. **Audit MCP servers and injected tools** — disable unused servers/extensions, or use a clean coding profile/custom agent, to save 5K-190K tokens per agent task\n5. **Auto model selection** — lower-cost default routing plus paid-plan discount on eligible usage, zero effort\n6. **Convert rich files to Markdown first** — avoid paying for Word/PDF/HTML layout noise in chat, agent, and RAG workflows\n7. **Retune prompts to the target model** — better first-pass output reduces repeated clarification turns\n8. **Precise prompts** — 20-40% of user-prompt input tokens; more important for quality than raw savings\n\n---\n\n*This is a living document. As tokenizer technology evolves, model capabilities change, and new techniques emerge, this guide will be updated. Check the repository for the latest version.*\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivomarco%2Fgithub-copilot-token-optimization","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folivomarco%2Fgithub-copilot-token-optimization","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folivomarco%2Fgithub-copilot-token-optimization/lists"}