Skip to content
| Marketplace
Sign in
Visual Studio Code>AI>Copilot Prompt Optimizer + Graphify ContextNew to Visual Studio Code? Get it now.
Copilot Prompt Optimizer + Graphify Context

Copilot Prompt Optimizer + Graphify Context

Dontaraju Sai Praneeth

|
14 installs
| (0) | Free
Reduces token usage in GitHub Copilot Chat while maintaining accuracy. Features a 3D interactive knowledge graph, node exclusion, context-strength recommendations, session export, and multi-language workspace scanning.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Copilot Prompt Optimizer + Graphify   v1.1.0

Save 20–60 % of your Copilot tokens on every message — automatically, locally, with zero AI calls.

A VS Code extension that rewrites your GitHub Copilot prompts before they are sent, stripping filler words and compressing verbose phrasing while keeping every bit of meaning intact. It also builds a live 3D knowledge graph of your entire codebase so the AI always has pinpoint context — not a wall of irrelevant text.


What This Does (Plain English)

Think of it like a smart editor that sits between you and Copilot. Before your message reaches the AI, it:

  1. Removes noise — polite filler ("Please could you...", "I was wondering if..."), redundant hedges ("basically", "essentially", "just"), and role-play prefixes ("You are a helpful assistant") that add zero information for an AI.
  2. Compresses intent — long phrases like "write a function that handles" become fn: → handle; "tell me about" becomes explain:; "what's the difference between" becomes diff:.
  3. Fixes your typos — a 250-word dictionary catches common developer misspellings (extention → extension, recieve → receive, scracth → scratch) before anything else runs.
  4. Protects what matters — code identifiers (camelCase, PascalCase), URLs, file paths, negations (shouldn't, cannot), and backtick-quoted code are never touched.
  5. Learns your codebase — a background scanner builds a graph of every class, function, method and import in your workspace. When you query it, only the truly relevant nodes are injected as context.

The result: the AI gets a tighter, cleaner signal and you spend fewer tokens getting to the answer.


How to Use

Step 1 — Install

Search "Copilot Prompt Optimizer" in the VS Code Extensions panel and click Install. The extension activates automatically when VS Code starts.

Step 2 — Optimize a prompt

Open Copilot Chat and type:

@optimize Please tell me about this extension from scratch

The extension rewrites it to:

explain: this extension from scratch

...and sends the compressed version. You see both versions in the chat response alongside a token-savings breakdown.

Step 3 — Pick your compression level

The Token Analysis panel opens automatically after every @optimize call. It shows four versions side-by-side:

Level What it does Typical saving
🌿 Light Removes only obvious filler (polite phrases, hedges) ~10–20 %
⚡ Moderate Also compresses verbose patterns and strips articles ~25–40 %
🔥 Aggressive Maximum compression — abbreviates and uses DP selection ~45–60 %
🧠 Intelligent Auto-picks the right level based on your prompt's information density best balance

Click Copy Optimized on any level to use that version.

Step 4 — Use the knowledge graph (optional but powerful)

@optimize /graphify how does authentication work in this project

A 3D graph of your codebase opens. Green nodes are the ones that matched your query. The extension injects those symbols as context so Copilot answers about your code, not generic examples.


Real-World Examples

Example 1 — Simple question

Prompt
You type Please could you tell me what the difference is between async and await in JavaScript?
Sent to Copilot diff: async await JS
Saving 19 tokens → 5 tokens (74 % reduction)

Example 2 — Code request

Prompt
You type I would like you to write a function that fetches data from an API endpoint and handles errors properly
Sent to Copilot fn: → fetch API endpoint → handle errors
Saving 24 tokens → 8 tokens (67 % reduction)

Example 3 — Short intent-heavy prompt (guardrail kicks in)

Prompt
You type explain this extension from scratch
Sent to Copilot explain: this extension from scratch
Saving Minor cleanup only — the guardrail protects meaning on short prompts

Example 4 — Explain a concept

Prompt
You type Can you please help me understand how the authentication middleware works in this codebase?
Sent to Copilot explain: auth middleware this codebase
Saving 20 tokens → 6 tokens (70 % reduction)

Example 5 — Debug request

Prompt
You type I'm getting a null pointer exception in the UserService class and I need you to help me fix it
Sent to Copilot fix: null pointer exception UserService
Saving 22 tokens → 6 tokens (73 % reduction)

Example 6 — Graph-assisted query

@optimize /graphify where is the database connection configured

The 3D graph highlights the DatabaseConfig, connectionPool, and dbInit nodes in your codebase. Copilot answers using your actual file paths and class names, not a hypothetical example.


Quick Reference — All Commands

In Copilot Chat

Command What it does
@optimize <your prompt> Compress + send; opens Token Analysis panel
@optimize /stats Show total tokens saved this session
@optimize /compare Side-by-side: last original vs optimized
@optimize /graphify <query> Query codebase graph → 3D viz + inject context
@optimize /export Export full session context to paste in a new chat

In the Command Palette (Cmd+Shift+P / Ctrl+Shift+P)

Command What it does
Prompt Optimizer: Show Optimization Panel Open the history sidebar
Prompt Optimizer: Toggle Auto-Optimization Turn on/off
Prompt Optimizer: Show Knowledge Graph Open the 3D graph
Prompt Optimizer: Rebuild Knowledge Graph Re-scan the whole workspace
Prompt Optimizer: Export Session Context Open the export panel
Prompt Optimizer: Clear Optimization History Reset history
Optimize Selection (right-click in editor) Optimize highlighted text in-place

Keyboard shortcut: Cmd+Shift+Alt+O (Mac) / Ctrl+Shift+Alt+O (Windows/Linux) — optimize selected text instantly.


Carrying Context to a New Chat

Token limits mean long Copilot sessions eventually lose context. Use /export to carry everything forward:

  1. Type @optimize /export in the chat.
  2. Click Copy All in the export panel.
  3. Open a new Copilot Chat.
  4. Paste as your very first message — Copilot now has your full workspace context and optimization history with zero re-explaining.

Managing Graph Nodes

Sometimes you want to keep certain files out of the context (auto-generated files, test fixtures, etc.):

  1. Run @optimize /graphify <any query> — the 3D graph opens.
  2. Click any node.
  3. Choose Exclude from Context — the node turns grey and stays excluded across sessions.
  4. Click it again → Re-include to restore it.

Features

Token Optimization

  • Smart prompt compression — removes filler, deduplicates instructions, compresses verbose patterns
  • Zero accuracy loss — preserves semantic meaning while reducing token count 20–60 %
  • Three optimization levels + Intelligent auto mode
  • Token Analysis panel — word-level token heatmap + four-way comparison with diff highlighting
  • Role/persona stripping — "You are a helpful assistant" and similar prefixes removed automatically
  • 70+ developer abbreviations — response → resp, request → req, error → err, authentication → auth, and more
  • Auto spell-correction — 250-entry dictionary (extention → extension, scracth → scratch, etc.)
  • Selection optimizer — right-click any selected text to optimize in-place

Mathematical Intelligence Layer

Every optimization is guided by local information theory — zero LLM tokens consumed:

Algorithm What it does
Zipf IDF table ~210 word scores calibrate information value
Shannon entropy Measures vocabulary diversity before and after
TF-IDF vectors Per-sentence weighted vectors for importance scoring
Cosine similarity Information Preservation Ratio — semantic content retained
Jensen-Shannon Divergence Symmetric word-distribution drift measurement
0/1 Knapsack DP Sentence selection: maximise information within token budget
Word-level DP Fine-grained token removal in aggressive mode
PMI collocation guard 55+ high-PMI pairs (async await, from scratch, etc.) never split
Short-prompt guardrail Prompts ≤ 10 words capped at Light level to protect intent
Meaning-preservation guardrail Auto-falls back to Light if cosine similarity drops below 0.72

3D Knowledge Graph (Built-in, Zero Setup)

  • Auto-builds on activation — scans workspace in background; no CLI, no config
  • Interactive 3D visualization — drag to rotate, scroll to zoom, click to focus
  • Relevant nodes highlighted in green; suggested additions in yellow
  • Node exclusion — persisted across sessions
  • Context-strength indicator — 🟢/🟡/🔴 score + suggestions after every /graphify
  • Auto-updates when you save, create, or delete files

Session Export (/export)

  • Full context export panel — 3D session graph + structured text document
  • Copy Last 3 / Copy All — paste at the top of a new chat for zero context loss

Activity Bar Panel

  • Visual history — all original vs optimized prompts side-by-side
  • Session statistics — total tokens saved, average reduction, best reduction
  • Context quality score per session

Status Bar Integration

  • Live token savings — percentage and absolute reduction
  • Session stats on hover
  • Quick enable/disable toggle

Knowledge Graph

Supported Languages

TypeScript, JavaScript, Python, Java, Kotlin, Go, Rust, C/C++, C#, Ruby, Swift, Vue, Svelte, Markdown / MDX

What Gets Indexed

  • Classes, interfaces, functions, methods, arrow-function exports
  • Import/export relationships between files
  • Markdown headings, frontmatter titles, keyword tags

Performance

  • Max 500 files scanned per build
  • node_modules, dist, out, build, media, minified files auto-excluded
  • 3-second debounced rebuild on file changes

Configuration

Setting Default Description
promptOptimizer.enabled true Enable auto-optimization
promptOptimizer.aggressiveness "moderate" Optimization level: light / moderate / aggressive
promptOptimizer.graphifyAutoContext true Auto-inject graph context into every prompt
promptOptimizer.showTokenCount true Show token count in status bar
promptOptimizer.maxHistoryItems 50 Max history entries to keep

Optimization Pipeline (Under the Hood)

  1. Technical token guard — camelCase, PascalCase, URLs, file paths, negations, backtick code protected as placeholders
  2. Spell correction — 250-entry dictionary, plain-English text only
  3. Sentence deduplication — Jaccard similarity removes near-duplicate sentences (≥ 65 % word overlap)
  4. Normalize whitespace
  5. Remove filler — polite wrappers, role/persona prefixes, hedging adverbs
  6. Structural compression — strip articles, copulas, there is/are, question scaffolding
  7. Pattern compression — "write a function that handles" → fn: → handle; intent phrases compressed rather than erased
  8. Abbreviate — JavaScript → JS, authentication → auth, response → resp, 70+ entries
  9. Compress connectors — and → &
  10. Deduplicate lines — exact duplicate instructions removed
  11. Inject graph context — relevant codebase symbols prepended (with /graphify only)
  12. Final cleanup — trim, restore protected tokens

License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft