Prompt Optimizer

Optimize prompts, use local memory/cache, forecast credits, and send to Copilot only when you choose.

fully local zero telemetry MIT v{{PROMPT_OPTIMIZER_VERSION}}

Prompt Optimizer reads local context, removes noise, forecasts cost, and keeps your setup across updates.

Meaning-preserving sentence shortening

The compressor removes noise and shortens English only when intent stays intact.

  • Removes politeness, hedging, and repeated context.
  • Shortens phrases such as “in order to” → “to”.
  • Leaves code, imports, paths, and stack traces exact.

How your prompt gets optimized for Copilot

Local steps run before Copilot sees anything:

  1. Compress prompt text without touching code-like content.
  2. Scan secrets before any send.
  3. Check cache for exact or semantic matches.
  4. Pack context from files, diagnostics, memory, KG, and peers.
  5. Apply mode/agent from slash commands, rules, or custom skills.
  6. Forecast tokens, cost, and credits for the selected plan/model.
  7. Remember conversation so “fix it” resolves correctly.
  8. Preserve your setup across updates; reset is manual and selective.
promptoptimizer://demo Idle — press ▶ Play to run the pipeline
user ›

📥 Ingest

Read raw prompt + active editor + open files.
prompt selection editors

🧭 Classify

Detect SDLC intent and target model.
/code auth bugfix

🧠 Augment

Pull memory, KG neighbours, peers.
AGENTS.md auth.ts peer cache

🗜️ Compress

Strip filler, shorten sentences, format for target.
248 → 248 tokens

📊 Forecast

Estimate cost, check cache, decide route.
$0.00041 cache hit
Optimized prompt ready — 71% smaller · semantic cache hit (94%) · est. $0.00041
Optimized prompt GPT · 71 tokens

          
⎇ main UTF-8

Three modes — pick the send behavior

Switch via the status-bar item, the sidebar dropdown, or @promptoptimizer /mode <name>.

🤖

Agent auto-send

Optimize locally, open Copilot Chat, and submit the optimized prompt. No @promptoptimizer prefix.

streams sidebar
✨

Optimize only default

Show analysis, cache status, credit forecast, and optimized prompt. You decide when to send.

no send analysis
💬

Direct send

Open Chat with @promptoptimizer <your prompt> prefilled. You hit Enter.

chat panel prefilled

Status-bar labels

ModeStatus bar labelBehaviour
Optimize only (default)$(wand) Proxy [Optimize]Show analysis & optimized prompt. No send.
Agent$(robot) Proxy [Agent]Optimize, then open Copilot Chat with the optimized prompt and submit it directly.
Direct send$(comment-discussion) Proxy [Direct]Open Chat panel with @promptoptimizer pre-filled.

Switch any time by clicking the label → QuickPick · or the sidebar dropdown · or @promptoptimizer /mode agent|optimize|direct.

Built-in SDLC modes

Slash roles add the right checklist and tone. Without a slash, skills are scored from intent, files, and keywords.

/planDecompose the work
/archHigh-level design
/codeImplementation
/testUnit / integration tests
/reviewCode review
/securityOWASP & threat model
/qaQA & test plans
/devopsCI/CD, infra
/docsDocs & READMEs
/prPR description
/fullEnd-to-end SDLC
/bug-fixBug triage flow
/refactorSafe refactor

Custom skills

Workspace skills live in .promptoptimizer/skills/*.md. Global skills can come from PROMPT_OPTIMIZER_SKILLS_DIR.

Supported frontmatter

  • id, label, readOnly
  • slashAliases, intentPatterns, keywords
  • requires, filePatterns, priority, tags
  • rolePreface as scalar or block (|)
  • checklist as frontmatter items or markdown bullets under ## Checklist

Skill files hot-reload on the next prompt. Diagnostics: Prompt Optimizer: Diagnose Skill Loading Errors.

🤖 Agents button

The Agents chip manages bundled and custom workspace agents.

  • Tick an agent to enable it for the current workspace.
  • Untick to disable it.
  • Click the ✎ pencil to enable-and-open the workspace copy for editing.
  • Click ↺ reset to restore the bundled definition over local edits.
  • Remove user-created agents without touching bundled definitions.
  • Use the title-bar + to create a custom agent from a template.

Enabled agents are copied into .promptoptimizer/skills/ — customize them like any other skill.

🎬 Live walkthrough — every control in the sidebar

Press ▶ Play tour to spotlight each control. Click a control to jump, or step with ‹ Prev / Next ›.

Prompt Optimizer · Sidebar
Mode:

↳ Optimized prompt (Optimize mode)

Refactor auth middleware → async/await. Add Jest unit tests for token validation, expiry, and error paths. Files: src/auth/*.ts. Cache: 71% hit.
—
0 / 0

—

Click any control to jump to its step.

Sidebar — Prompt Optimizer Control

Open it from the Chat sidebar or status bar. Chips are shortcuts:

  • 🚀 Visual Tour — reopen this onboarding guide.
  • 🎓 Guide — single-screen list of every common action.
  • 🕒 History — prior prompts with side-by-side diff, restore, send to chat.
  • 🌿 Versions — Git-style log: commit, branch, tag, checkout, diff.
  • ✨ Try example — inserts a sample prompt so you can see it work.
  • 📓 Memory — opens AGENTS.md / CLAUDE.md / .promptoptimizer/memory.md.
  • 🔗 Peers — federate cache with peer workspaces.
  • 🤖 Agents — enable bundled or custom SDLC agents.
  • ↻ Refresh — re-index status overview on demand.
  • ⚙ — secret settings and selective reset to defaults.

Analysis table (Optimize mode)

Cost / Saved
Total USD cost · tokens saved
Tokens
Raw → optimized count · est. output
Cache
exact hit / semantic match (%) / miss
Pricing
Input + output cost breakdown

💬 Chat participant — @promptoptimizer

In the VS Code Chat panel just type:

@promptoptimizer refactor the auth middleware to use async/await

Messages are optimized before Copilot receives them.

Slash commands

/mode agent|optimize|direct
Switch run mode
/memory
Show stored conversation turns for this workspace
/clear
Clear conversation memory for this workspace
/context
Show what local context (files, logs, cache) is available

Conversation memory

Up to 12 turns per workspace are remembered, so “now add tests for it” can reference the prior task.

● Live memory snapshot · this workspace

Real-time local index view. Letters and digits are masked as •; click a row to open the real source.

— files
— bytes
— est. tokens
— versions
— cache entries
Loading memory snapshot…
never

📊 What's inside the memory — abstract dashboard

Panels use local counts and timestamps, rendered as abstract shapes so content stays private.

Knowledge graph

— nodes · workspace, memory files & cache entries cross-linked.

Semantic cache density

— embeddings indexed locally.

Version-log activity

— commits in the recent window.

Token budget

—

The memory lifecycle — three distinct stages

Saved files, prompt versions, and memory files pass through three local stages.

① Ingestion

Workspace memory, git log, README/package metadata, active editors, diagnostics, and recent saves are indexed.

Files stream into the semantic cache (animated).

② Storage

Tokens, embeddings, conversation turns, and prompt versions are stored in local SQLite/JSON state.

Embedding bricks falling into the SQLite vault.

③ Retrieval

Prompt arrives → cache lookup → context repacked → optimized payload and forecast are ready. Secrets are warned before send.

Radar sweep finds the matching prompt embeddings.

Optimized prompt → Copilot context

user prompt semantic cache + workspace memory copilot (only optimized payload)

Semantic cache thresholds

ResultWhat happens
Exact matchReturns the cached optimized version instantly.
Semantic match ≥ 68%Returns the cached result and boosts its confidence score.
MissOptimizes fresh and writes the result to cache for next time.

Seed sources: git log, Prompt Optimizer history, README.md, package.json, and instruction files. Manage with cache statistics, clear cache, or reset-to-defaults.

🔒 Privacy & security

Data processing100% on your machine — no cloud backend, no remote API except the Copilot request you approve.
Prompt storageCached locally in a SQLite file (promptProxy.dbPath). Never uploaded.
Secret scanningAPI keys and tokens are detected before any network call and blocked with a warning.
TelemetryNone. Zero usage or diagnostic data collected.
Network callsOnly the GitHub Copilot inference request you explicitly send via the VS Code Chat API.
UpdatesSettings, cache, memory, prompt versions, and custom agents are preserved across marketplace updates.
Open sourcegithub.com/PawanDBalapure/prompt-optimizer — audit it yourself.

To verify: open out/extension.js or engine/dist/. Search for http, fetch, axios, request — you'll find zero outbound calls outside the Copilot API.

🚨 Secret detection patterns

If your prompt contains anything that looks like one of these, a warning appears in the panel before the prompt is sent:

  • OpenAI keys — sk-…
  • Anthropic keys — sk-ant-…
  • GitHub tokens — ghp_…, ghs_…
  • AWS access keys — AKIA…
  • PEM private key headers
  • Generic assignments — password=, token=, api_key=

Manage patterns via the panel ⚙ Secret detection menu — add or remove regex / startsWith / contains rules per workspace.

Command palette — Ctrl+Shift+P → Prompt Optimizer:

Select Mode (Agent / Optimize / Direct)Open mode QuickPick
Open Chat ParticipantJump to @promptoptimizer in Chat
Focus Control PanelFocus the sidebar panel
Open Prompt Optimizer GuideReopen this guide any time
Optimize Clipboard & Cost ForecastOptimize whatever is on the clipboard
Copy Last Optimized PromptCopy the last result to clipboard
Send Last Optimized Prompt To ChatOpen Chat with the last result
Show Cache StatisticsEntry count, avg confidence, total hits
Clear Semantic CacheWipe the local SQLite cache
Clear Conversation MemoryReset this workspace's conversation history
Reset to DefaultsChoose settings, cache, memory, or custom agents to restore
Show Prompt HistoryQuickPick of prior prompts with diff/restore/send actions
Commit / Log / Branch / Tag PromptGit-style versioning of prompts
List Agent Skills (Modes)Every registered built-in and custom mode
Create / Edit Agent SkillCreate a workspace skill or override a built-in
Diagnose Skill Loading ErrorsOpen files that failed parsing/loading
Manage SDLC Agent SkillsEnable/disable/edit/reset bundled agents

⚙ Configuration

SettingDefaultDescription
promptProxy.dbPath(global storage)Custom path for the SQLite cache file.
promptProxy.processingModeblockingblocking or non-blocking cache lookup.
promptProxy.enableSessionContexttrueFeed recent turns back as session history.
promptProxy.pricingInput0.0015Input cost per 1K tokens (USD).
promptProxy.pricingOutput0.002Output cost per 1K tokens (USD).
promptProxy.subscriptionPlanproMonthly credit allowance used by the forecast.
promptProxy.forecastRequestsPerDay20Requests/day used for monthly overage.
promptProxy.secretPatterns[]Custom scanner rules.
promptProxy.versions.authoryouAuthor name stamped on prompt commits.

All settings live under File → Preferences → Settings → Extensions → Prompt Optimizer.