Skip to content
| Marketplace
Sign in
Visual Studio Code>Formatters>Prompt OptimizerNew to Visual Studio Code? Get it now.
Prompt Optimizer

Prompt Optimizer

datapipe-labs

|
6 installs
| (0) | Free
Convert loosely formatted markdown prompts into structured XML format optimized for Claude AI
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Prompt Optimizer

A VS Code extension that converts loosely formatted markdown prompts into structured XML format optimized for Claude AI.

Features

  • Smart Conversion: Automatically identifies and structures different prompt sections
  • Multiple Trigger Methods: Command palette, keyboard shortcut, or context menu
  • Flexible Text Selection: Works with selected text or entire document
  • XML Structure: Converts to Claude-optimized XML with proper tags

Installation

Option 1: From VSIX Package (Recommended)

  1. Build the extension package:

    npm install
    npm run compile
    npm run package
    
  2. Install the generated .vsix file:

    • Open VS Code
    • Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
    • Type "Extensions: Install from VSIX"
    • Select the generated prompt-optimizer-1.0.0.vsix file

Option 2: Development Mode

  1. Clone or download this repository
  2. Open the folder in VS Code
  3. Install dependencies:
    npm install
    
  4. Compile the TypeScript:
    npm run compile
    
  5. Press F5 to launch a new Extension Development Host window

Usage

Converting Text

There are three ways to convert markdown prompts to XML:

1. Command Palette

  • Press Ctrl+Shift+P (or Cmd+Shift+P on Mac)
  • Type "Prompt Optimizer: Convert to XML"
  • Press Enter

2. Keyboard Shortcut

  • Select text (optional) or place cursor in document
  • Press Ctrl+Shift+X (or Cmd+Shift+X on Mac)

3. Context Menu

  • Right-click in the editor
  • Select "Convert to XML" from the context menu

Text Selection Behavior

  • With Selection: Converts only the selected text
  • Without Selection: Converts the entire document
  • Result: The original text is replaced with the XML version

Conversion Rules

The extension automatically identifies and converts different sections:

Markdown Pattern XML Output
Main content <instructions>
Bullet points (-, *, •) <constraints> with <constraint> items
Context:, Background:, Setting: <context>
Example:, Examples:, Sample: <examples> with <example> items
Format:, Output:, Return: <output_format>
Requirements:, Must:, Should: <constraints>

Examples

Input (Markdown)

Create a Python function that processes CSV files
- Must handle missing values
- Should return pandas DataFrame
- Include error handling

Example: process_csv("data.csv") → DataFrame

Format: Return working code with docstring

Output (XML)

<prompt>
  <instructions>
    Create a Python function that processes CSV files
  </instructions>
  
  <constraints>
    <constraint>Must handle missing values</constraint>
    <constraint>Should return pandas DataFrame</constraint>
    <constraint>Include error handling</constraint>
  </constraints>
  
  <examples>
    <example>process_csv("data.csv") → DataFrame</example>
  </examples>
  
  <output_format>
    Return working code with docstring
  </output_format>
</prompt>

Development

Project Structure

prompt-optimizer/
├── package.json          # Extension manifest
├── tsconfig.json         # TypeScript configuration
├── src/
│   ├── extension.ts      # Main extension entry point
│   └── converter.ts      # Conversion logic
├── .vscode/
│   └── launch.json       # Debug configuration
└── README.md             # This file

Building and Testing

# Install dependencies
npm install

# Compile TypeScript
npm run compile

# Watch for changes during development
npm run watch

# Create package for distribution
npm run package

# Run linting
npm run lint

Debugging

  1. Open this project in VS Code
  2. Press F5 to launch Extension Development Host
  3. Set breakpoints in the TypeScript files
  4. Test the extension in the new window

Requirements

  • VS Code 1.60.0 or higher
  • Node.js 16.x or higher (for development)

License

MIT License - see LICENSE file for details

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Changelog

1.0.0

  • Initial release
  • Basic markdown to XML conversion
  • Command palette, keyboard shortcut, and context menu integration
  • Smart section detection and structuring
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft