PromptSight AI
Prompt governance for VS Code — every token is checked before it is spent. PromptSight sits between you and the LLM. Before a prompt is sent it tries to avoid the call entirely (local prompt cache), reduce it (lossless compression, deduplication, secret redaction), and govern it (token/cost thresholds, session budgets, team policy) — then stops so you decide. Nothing is sent until you choose.
Features
Everything runs locally and in-process — no Python, no subprocesses, no network calls, and nothing leaves your machine without your explicit decision. Installation
From the Marketplace (recommended):
Or from the command line:
Building from source (contributors):
Then reload VS Code ( How to UseIn Copilot Chat —
|
| Button | What it does |
|---|---|
| 💾 Use cached solution | Reuses the best cached answer — 0 tokens spent |
| ✅ Allow — send original | Sends your prompt unchanged |
| ♻ Reframe — send optimized | Sends the trimmed, compact-encoded, secret-redacted version |
| ⇄ Switch model — send via suggested | Routes the request through the model PromptSight recommends (cheaper for simple tasks, stronger for complex ones) |
| (ignore) | Nothing is sent |
Slash command shortcuts:
| Command | What happens |
|---|---|
@promptsight <prompt> |
Pre-flight report only — you decide after |
@promptsight /send <prompt> |
Pre-flight, then sends original prompt |
@promptsight /optimize <prompt> |
Pre-flight, then sends optimized prompt |
@promptsight /switchmodel <prompt> |
Pre-flight, then sends via the suggested model (e.g. drops a premium model to gpt-4.1-mini for a simple task) |
@promptsight /cached <prompt> |
Reuses the best cached solution — costs 0 tokens |
@promptsight /helpful <prompt> |
Rates the last cached answer 👍 — raises its confidence |
@promptsight /unhelpful <prompt> |
Rates the last cached answer 👎 — lowers its confidence |
@promptsight /feedback up\|down [feature:<name>] <comment> |
Records rollout feedback about PromptSight itself (stored locally) |
@promptsight /feedback summary |
Shows collected feedback: satisfaction %, per-feature counts, recent comments |
After /cached, 👍/👎 rating buttons appear automatically — the cache learns which answers are worth reusing.
Model switching in practice: if you ask a simple question while a premium model (e.g. Claude Opus) is selected, the pre-flight report says "You can likely downgrade to a small / fast model such as 'gpt-4.1-mini' to cut cost" and shows the ⇄ Switch model button. Clicking it sends this request through the suggested model. The suggested model must be enabled in the chat model picker ("Manage Models…") — if it isn't, PromptSight tells you and sends nothing.
In Agent Mode — #promptsight
- Switch Copilot Chat to Agent mode
- Add
#promptsightto your message:#promptsight Refactor all files in this repo to use async/await - A gate dialog appears with Allow, Reframe, and Deny options:
- Allow — agent proceeds with your original request
- Reframe — agent uses the optimized prompt instead
- Deny — agent stops; adjust your prompt and retry
Settings
Open VS Code Settings (Ctrl+,) and search for promptsight:
| Setting | Default | Description |
|---|---|---|
promptsight.defaultModel |
gpt-4.1-mini |
Fallback model for token/cost estimates (the active chat model wins) |
promptsight.warnThreshold |
8000 |
Token count that triggers a ⚠ WARN |
promptsight.blockThreshold |
12000 |
Token count that triggers a 🔴 BLOCK |
promptsight.policyPath |
(bundled) | Path to a custom policy.json (a workspace .promptsight/policy.json is auto-detected) |
promptsight.pricingPath |
(bundled) | Path to a custom pricing.json |
promptsight.cacheEnabled |
true |
Look up / store prompt-solution pairs in the local cache |
promptsight.sessionBudgetTokens |
150000 |
Cumulative session token budget; sends over budget require confirmation (0 disables) |
Team policy via git
Create .promptsight/policy.json in your repository root and commit it — every teammate with PromptSight gets the same governance rules automatically:
{
"warn_total_tokens": 8000,
"block_total_tokens": 12000,
"hard_block": true,
"allowed_models": ["gpt-4.1", "gpt-4.1-mini", "gpt-4o-mini"],
"max_duplicate_ratio": 0.2
}
Troubleshooting
| Problem | Fix |
|---|---|
@promptsight does not appear in chat |
Reload window: Ctrl+Shift+P → Developer: Reload Window |
| Extension not visible in Extensions panel | Reinstall from the Marketplace and reload |
code command not found |
Run Shell Command: Install 'code' command in PATH from Command Palette |
Uninstall
code --uninstall-extension HemantSagar-MS.promptsight-preflight
Then reload VS Code: Ctrl+Shift+P → Developer: Reload Window.
Running the Tests
node --test test/
The suite (109 tests) covers the analyzer units, a 16-scenario validation corpus of technical and non-technical prompt types (code, logs, Terraform, SQL, JSON, transcripts, emails, marketing copy, PII/secrets…), model-selection impact (cost scaling, downgrade/upgrade routing), the feedback store, and a mocked-vscode smoke test of the chat participant (switch-model routing included).
Compare token/cost impact of different models across the whole corpus:
npm run eval:models # or: node scripts/model-impact.js
node scripts/model-impact.js --models gpt-4.1-mini,claude-opus-4
The report shows per-scenario cost by model and where routing advice recommends a cheaper (cost) or stronger (output quality) model.
Repository Layout
PromptSight_AI/
├── package.json Extension manifest (chat participant + agent tool)
├── extension.js Chat participant, agent gate, cache UX, session budget, model switch, feedback
├── build-vsix.ps1 Packages the extension into a .vsix
├── scripts/
│ └── model-impact.js Model-selection impact report over the validation corpus
├── src/ In-process analyzer (no external dependencies)
│ ├── analyzer.js Pre-flight orchestrator (tokens → cost → policy → optimization)
│ ├── tokenizer.js Token counting + output estimation
│ ├── classifier.js Input type / complexity / duplication detection
│ ├── costEstimator.js Per-model pricing → cost
│ ├── policyValidator.js ALLOW / WARN / BLOCK decision
│ ├── optimizer.js Safe cleanup, model routing, secret detection/redaction
│ ├── promptCache.js Local JSON prompt-solution cache (0-token reuse, LRU-capped)
│ ├── feedbackStore.js Local rollout-feedback store (ratings + summary)
│ └── compactEncoder.js JSON → compact tabular lossless compression
├── analyzer/
│ └── config/
│ ├── policy.json Threshold and rule configuration
│ ├── pricing.json Per-model token pricing
│ └── model_rules.json Model routing rules
└── test/
├── analyzer.test.js Analyzer unit tests
├── validation.test.js Recommendation validation over the prompt corpus
├── modelImpact.test.js Model-selection impact on tokens/cost/routing
├── feedbackStore.test.js Feedback store tests
├── extensionSmoke.test.js Chat participant smoke test (mocked vscode)
└── fixtures/
└── promptCorpus.js 16 technical + non-technical validation scenarios
Notes
- Token counts are heuristic (≈¾ word per token); output-token, cost, and CO₂e figures are estimates for pre-flight awareness only.
- The analyzer runs fully in-process — no Python, no subprocesses, no network calls.
- The optimizer only performs deterministic, zero-token edits: deduplication, whitespace cleanup, repeated-line collapsing, lossless compact re-encoding of JSON, and secret masking. No LLM is used to optimize prompts.
- Secret detection is best-effort; high-severity matches are masked in the optimized prompt and always redacted in the report.
- The prompt cache is a local JSON file (per-machine, under VS Code global storage, capped at 500 entries). Nothing is uploaded anywhere.
- Rollout feedback (
/feedback) is also a local JSON file (capped at 1000 entries) — nothing is uploaded anywhere. - Model switching routes the request through the suggested model via the VS Code language-model API; the chat window's model picker UI itself cannot be changed by extensions and keeps showing your manual selection.
- GitHub Copilot Chat is required to use the
@promptsightparticipant and#promptsighttool.