Turn rough AI prompts into specific, structured, constrained ones. One keystroke.
Lens is a VS Code extension that sits between you and your AI coding assistant (Copilot, Cursor, Codex, Claude Code, ChatGPT). Select a rough prompt, press ⌘K L, and Lens rewrites it in place — adding specificity, structure, and safety guards so the downstream model gives you a better answer with fewer retries.
Opt-in per action. Never intercepts silently. Works with any OpenAI-compatible API.
Why
Bad prompts cause expensive retries. You ask vaguely, get a mediocre answer, refine, ask again. That's three LLM calls where one would have sufficed. Lens fixes the prompt before it hits the expensive model.
Before:
can you look into pricing and tell me what files are important
After (⌘K L):
In the current repository, identify the files most relevant to pricing logic. Rank them by importance based on: (1) file size and complexity, (2) how many other files reference them, (3) recency of changes. Return a ranked list with a one-sentence justification per file. Do not modify any files.
Same intent. Vastly better answer downstream. Roughly 15–30% cheaper in downstream LLM spend once you factor in avoided retries.
Install
Install from the VS Code Marketplace or:
code --install-extension your-publisher.prompt-lens
On first use, Lens will prompt you to paste an API key. Any OpenAI-compatible key works. The key is stored in VS Code's SecretStorage — never in settings, never synced to git.
Usage
Improve a prompt in place — ⌘K L (Mac) / Ctrl+K Ctrl+L (Win/Linux)
- Select the rough prompt text (in any file —
.md, code, comments, notebook cells) - Press
⌘K L - Lens replaces it with the improved version
⌘Zto undo if you don't like it
No selection? Lens grabs the current line.
Compose a new prompt — ⌘K ⇧L (Mac) / Ctrl+K Ctrl+Shift+L (Win/Linux)
For sending prompts to chat panels (Copilot Chat, etc.) where in-place editing isn't feasible:
- Press
⌘K ⇧Lfrom anywhere - Type or paste your rough prompt
- Review the improvement
- Hit Enter — Lens copies to clipboard (default) or opens Copilot Chat with the improved prompt
Configuration
Open Settings → Extensions → Lens.
| Setting | Default | Purpose |
|---|---|---|
lens.model |
gpt-4o-mini |
Model for rewriting. Cheap + fast is best. |
lens.baseUrl |
OpenAI | Change for Azure OpenAI, local proxies, other providers |
lens.showDiffAfterRewrite |
true |
Brief status about what changed |
lens.autoDetectTaskType |
true |
Tailor the rewrite to task type |
lens.includeEditorContext |
true |
Include language and filename (never file contents) |
lens.temperature |
0.2 |
Keep low for consistent rewrites |
lens.sendToChatAfterCompose |
clipboard |
copilot, clipboard, or none |
lens.enableTelemetry |
false |
Off. Anonymous counts only if enabled. |
Commands
Lens: Improve Selected Prompt— the main rewrite actionLens: Compose New Prompt— panel for chat-panel workflowsLens: Set API Key— securely store your API keyLens: Clear Stored API Key— remove the stored keyLens: Show Session Stats— how many rewrites, acceptance rate, tokens
Cost
Lens uses a small model for rewrites (default gpt-4o-mini). Each rewrite is roughly $0.0001 — one hundredth of a cent. The downstream model call is where the real money is, and that's where you save 15–30% by having a better prompt.
Privacy
- Prompts you rewrite are sent to the API endpoint you configure (default: OpenAI). Lens is a client — it does not proxy anything through any Lens-owned server.
- File contents are never sent. Lens only sends the prompt text you selected, plus optional metadata (current file language, workspace-relative filename) if
lens.includeEditorContextis on. - API key is stored in VS Code's
SecretStorage(OS keychain on Mac/Linux, Windows Credential Manager on Windows). - Telemetry is opt-in and off by default. When enabled, only anonymous counts (rewrite attempted, accepted, rejected) are sent — never prompt contents.
What Lens is NOT
- Not automatic. It only fires when you press the hotkey. Predictable > clever.
- Not a code assistant. It doesn't answer your prompt — it just improves it before you send it somewhere that will.
- Not proprietary to any provider. Any OpenAI-compatible endpoint works.
Building from source
git clone <this-repo>
cd prompt-lens
npm install
npm run compile
To try it locally: open the folder in VS Code, press F5. This launches an Extension Development Host with Lens loaded.
To package a .vsix:
npm run vsce:package
# → prompt-lens-0.1.0.vsix
code --install-extension prompt-lens-0.1.0.vsix
Testing
npm test
License
MIT. See LICENSE.