Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Prompt CompilerNew to Visual Studio Code? Get it now.
Prompt Compiler

Prompt Compiler

Ha Trong Nguyen

|
2 installs
| (1) | Free
Turn rough coding prompts into clear, actionable ones with your own LLM API, then copy the result instantly.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Prompt Compiler

Select a prompt. Run Prompt Compiler: Optimize & Copy. Paste the result into your AI coding assistant.

Prompt Compiler turns a rough developer prompt into a clear, actionable one — then puts it straight on your clipboard.

Raw Developer Prompt → Prompt Compiler → Optimized Coding Prompt → Clipboard

It does not carry out the task in your prompt. It only rewrites the prompt.


Features

  • One step. Select text, run the command, the result is already in your clipboard.
  • Sidebar panel. Write and optimize a prompt right in the panel — no file needed.
  • Keeps your language. A Vietnamese prompt produces Vietnamese output; English produces English; a mixed prompt keeps its natural mix. Technical terms (API, middleware, refactor, migration, …) are never translated.
  • Preserves intent. No invented requirements, files, APIs, frameworks, or bug causes. When information is missing, the rewritten prompt asks the assistant to inspect the repository or check back with you.
  • No prompt bloat. A short prompt stays short. It never bolts on "You are a senior software engineer…" or "Think deeply…".
  • Your key, your provider. No account, no backend, no telemetry.
  • Any OpenAI-compatible API. OpenAI, OpenRouter, LM Studio, Ollama, and compatible gateways.
  • Model list loaded for you from the /models endpoint, picked through a filterable combo box.
  • Automatic retry on transient provider failures (429/500/502/503/504) with 1s then 2s backoff.

The extension UI and its messages are currently in Vietnamese. Output language always follows your prompt.


Installation

From a .vsix file:

code --install-extension promptc-0.1.0.vsix

Or in VS Code: Extensions → … menu → Install from VSIX…

Build from source

npm install
npm run compile

Press F5 to launch the Extension Development Host.


Configuration

Open the Prompt Compiler icon in the Activity Bar → Cấu hình (Settings) tab.

Field Meaning Default
Base URL OpenAI-compatible endpoint https://api.openai.com/v1
Model Model used for optimization (required)
API Key Stored in VS Code SecretStorage —
Timeout Request timeout, 5000–120000 ms 30000
Send temperature = 0 Turn off for models that reject the field on
Meta prompt as system role Turn off to fold the meta prompt into the user message on

One Lưu (Save) button persists everything, including the API key.

Test model sends one tiny request — any content coming back means the model works.

These fields also live in VS Code Settings under the promptOptimizer.* namespace. The API key does not — it stays in SecretStorage only.


Supported Providers

Anything that serves POST {baseUrl}/chat/completions in OpenAI format.

Provider Base URL
OpenAI https://api.openai.com/v1
OpenRouter https://openrouter.ai/api/v1
Ollama http://localhost:11434/v1
LM Studio http://localhost:1234/v1

These four are one-click preset chips. For any other gateway, paste its URL.


Usage

From the editor

  1. Write a prompt in any file.
  2. Select it.
  3. Ctrl+Shift+P → Prompt Compiler: Optimize & Copy.
  4. Ctrl+V into your AI coding assistant.

From the sidebar

  1. Open the Prompt Compiler icon in the Activity Bar.
  2. Type into the prompt box, or click Từ selection to pull in the current editor selection.
  3. Click Tối ưu & Copy, or press Ctrl+Enter.
  4. The result appears and is already on the clipboard.

Commands

Command Does
Prompt Compiler: Optimize & Copy Optimize the current selection, copy the result
Prompt Compiler: Set API Key Enter the API key through an input box
Prompt Compiler: Clear API Key Remove the API key from SecretStorage
Prompt Compiler: Show Log Open the Output channel with request/response metadata

Example

Input:

đổi tên biến x thành userId

Output:

Đổi tên biến `x` thành `userId`.

- Cập nhật tất cả reference liên quan.
- Không thay đổi behavior.
- Kiểm tra các lỗi compile/type-check sau khi thay đổi.

A short prompt stays short. It is never inflated into 500 words.


Privacy

Prompts go directly from the VS Code extension to the LLM provider you configured. The extension runs no backend of its own and collects no prompts, source code, or API keys.

If your third-party provider has its own policy, checking it is up to you.

Precisely what the extension does:

  • Sends: only the fixed meta prompt and exactly the text you selected (or typed into the panel). No other source code, no environment variables, no git history.
  • Stores: the API key in VS Code SecretStorage; settings in VS Code settings. Nothing else.
  • Logs: the Output channel records metadata only — URL, model name, HTTP status, body size, API key length. Never prompt content, response content, or the key itself.
  • Telemetry: none.

Troubleshooting

Run Prompt Compiler: Show Log from the Command Palette to see request details.

Symptom Usual cause
Missing API key Key not saved — open the Settings tab, paste it, click Save
Invalid or rejected API key (401) Wrong or revoked key
Model not covered by your key (403) Key is valid but your plan excludes that model — pick another
Provider server error (5xx) Provider or model is down. The extension already retried 3 times. Use Test model with a different model to confirm
Endpoint or model not found (404) Wrong Base URL or model name
Network error Wrong Base URL, or a local provider that is not running
Request timed out Raise Timeout in the Settings tab
Prompt exceeds the context limit Select a shorter passage, or use a model with a larger context
Model list will not load Provider has no /models endpoint — type the model name directly
Provider rejects temperature or the system role Turn off the matching toggle in the Settings tab

Development

npm install
npm test                 # typecheck + lint + unit tests
npm run lint             # eslint with type-aware rules
npm run typecheck        # tsc --noEmit
npm run test:unit        # unit tests (node:test)
npm run test:coverage    # unit tests with coverage
npm run test:integration # runs inside real VS Code against a mock LLM server
npm run bundle           # esbuild → dist/extension.js
npm run package          # build the .vsix

The shipped extension is a single esbuild bundle (dist/extension.js), so the VSIX stays around 24 KB and activation stays fast. npm run watch rebuilds it on change; press F5 to launch the Extension Development Host.

Releasing

# 1. update CHANGELOG.md, then:
npm version patch    # or minor / major — writes package.json and tags
git push --follow-tags

The Release workflow verifies the tag matches package.json, runs the full test suite, packages the VSIX, and attaches it to a GitHub release. No secrets required.

Publishing to the Marketplace stays manual: download the VSIX from the release and upload it at Manage Publishers & Extensions.

Architecture:

src/
├── extension.ts              # activate, register commands and the view
├── commands/                 # VS Code layer: selection, notifications, clipboard
├── core/                     # pure logic, NEVER imports vscode
│   ├── optimizer.ts          # pipeline orchestration
│   ├── promptBuilder.ts      # meta prompt + language hint
│   ├── responseNormalizer.ts # strips an outer code fence
│   ├── languageDetector.ts   # vi/en/mixed/unknown heuristic
│   └── errorMessages.ts      # error code → user-facing message
├── providers/                # HTTP layer, NEVER imports vscode
├── config/                   # settings resolver + SecretStorage
├── constants/metaPrompt.ts   # the meta prompt (verbatim from SPEC-001)
└── ui/configView.ts          # sidebar webview

core/ and providers/ do not depend on the VS Code API, so unit tests run directly under node --test without booting VS Code.


License

MIT

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