Skip to content
| Marketplace
Sign in
Visual Studio Code>Machine Learning>Copilot Token OptimizerNew to Visual Studio Code? Get it now.
Copilot Token Optimizer

Copilot Token Optimizer

Unnati Vyas

|
1 install
| (0) | Free
Scan your workspace, MCP tools, and settings to reduce GitHub Copilot token usage and cost
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Copilot Token Optimizer

A VS Code extension that scans your workspace, MCP tools, and Copilot settings to identify token waste and suggest fixes — reducing GitHub Copilot cost and improving completion quality.


What it scans

Category What it checks
Workspace .copilotignore presence, large generated files, test snapshots, missing copilot-instructions.md
MCP / Tools Always-on servers, redundant tool schemas, cold servers (< 10 calls/30d)
Settings Implicit context scope, chat history retention, model selection, debounce
Code patterns Large Vue SFCs, verbose Python docstrings, heavy Javadoc, CDK assets in context

Installation

# Clone and build
git clone https://github.com/your-org/copilot-token-optimizer
cd copilot-token-optimizer
npm install
npm run compile

# Install the VSIX
npx vsce package
code --install-extension copilot-token-optimizer-0.1.0.vsix

Or press F5 in VS Code to launch the Extension Development Host directly.


Commands

Command Description
Copilot Token Optimizer: Open Dashboard Opens the scanner panel
Copilot Token Optimizer: Run Full Scan Re-runs all scanners
Copilot Token Optimizer: Generate .copilotignore Auto-generates exclusion file for your stack
Copilot Token Optimizer: Generate copilot-instructions.md Scaffolds .github/copilot-instructions.md

Configuration

Add to your VS Code settings.json:

{
  "copilotOptimizer.githubOrg": "your-org",
  "copilotOptimizer.githubToken": "ghp_...",
  "copilotOptimizer.autoScanOnOpen": true,
  "copilotOptimizer.largeFileThreshold": 500,
  "copilotOptimizer.awsCloudWatchRegion": "us-east-1"
}

GitHub PAT scopes required

To enable the Copilot Metrics API (per-seat usage data):

  • read:org
  • copilot (or manage_billing:copilot)

Generated files

.copilotignore

Auto-detects your stack (Python, Java, VueJS, AWS CDK, Playwright) and generates exclusion patterns. Inherits from .gitignore. Review and commit.

.github/copilot-instructions.md

Pre-loads project conventions into every Copilot session — stack, naming rules, patterns. A well-crafted file saves 20–30% of prompt tokens by eliminating re-explanation.


AWS CloudWatch integration

Set copilotOptimizer.awsCloudWatchRegion to export metrics to namespace CopilotTokenOptimizer:

  • EstimatedMonthlyTokens
  • ActiveUsers

Ensure your environment has AWS credentials (AWS_PROFILE or IAM role) with cloudwatch:PutMetricData permission.


Development

npm run watch          # incremental build
F5 in VS Code          # launch extension dev host
npm run lint           # ESLint

Adding a new scanner rule

  1. Add a PatternCheck entry in src/scanner/patternDetector.ts
  2. Define file extensions and the run() function returning a Finding | null
  3. The finding is automatically displayed in the Code Patterns tab

Adding a new settings rule

Add a SettingRule entry in src/scanner/settingsAnalyzer.ts with the VS Code setting key, bad values, and recommended value.


Roadmap

  • [ ] Per-developer token leaderboard (from Metrics API)
  • [ ] Prompt template library generator
  • [ ] Multi-root workspace splitter
  • [ ] GitHub Actions workflow for CI token budget enforcement
  • [ ] Slack/Teams notification when monthly token budget exceeded
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft