Instant Context Query
A Cursor extension that automatically creates and inputs prompts to get AI explanations for selected text
Features
- 📝 Get AI explanations for selected text in the editor or chat screen using Cursor AI
- ⌨️ Execute instantly with a shortcut key (
Alt+- / Option+-)
- 🖱️ Select "Ask Cursor AI" from the right-click menu
- 💬 Automatically opens Cursor's chat tab and inputs the prompt
- 🔧 Works in both editor and chat screens
Installation
Install from VS Code Marketplace (Recommended)
- Open VS Code (or Cursor)
- Open the Extensions view (
Ctrl+Shift+X / Cmd+Shift+X)
- Search for "Instant Context Query"
- Click "Install"
Manual Installation (Development Version)
- Clone or download this repository
- Install dependencies:
npm install
- Build the extension:
npm run compile
- Package the extension:
npm install -g @vscode/vsce
vsce package
- Install the generated
.vsix file:
- Press
Ctrl+Shift+P (Mac: Cmd+Shift+P) in VS Code
- Select "Extensions: Install from VSIX..."
- Select the
.vsix file
Usage
- Select the text you want to explain in the editor or chat screen
- Press
Alt+- (Windows/Linux) or Option+- (Mac)
- Or select "Ask Cursor AI" from the right-click menu
- Cursor's chat tab will open and the prompt will be automatically entered
- Press Enter to send
Configuration
This extension uses Cursor's chat functionality, so no additional configuration is required.
Customizing the Prompt
You can customize the prompt template used when asking AI to explain selected text:
- Open VS Code settings (
Ctrl+, / Cmd+,)
- Search for "Instant Context Query"
- Set "Instant Context Query: Prompt Template"
- Use
{selectedText} as a placeholder for the selected text
Example:
Please explain the following code in detail:
{selectedText}
Focus on the logic and purpose of each part.
If the prompt template is empty, the default prompt based on your VS Code language setting will be used.
Changing the Shortcut Key
To change the shortcut key:
- Open keyboard shortcut settings with
Ctrl+K Ctrl+S (Mac: Cmd+K Cmd+S)
- Search for "Instant Context Query" or "Ask Cursor AI"
- Change the shortcut key
Development
Requirements
- Node.js 18 or higher
- TypeScript 5.0 or higher
- VS Code 1.74 or higher
Development Commands
# Compile
npm run compile
# Watch mode (auto-compile)
npm run watch
Debugging
Basic Debugging Steps
Open the project
- Open this project folder in VS Code
Launch Extension Development Host
- Press
F5 or select "Run Extension" from the debug panel
- A new VS Code window (Extension Development Host) will open
Set Breakpoints
- Click on the left side of any line in
src/extension.ts to set a breakpoint
- A red circle will appear
Test the Extension
- In the development host window, open an editor and select text
- Press
Alt+- (Windows/Linux) or Option+- (Mac) to execute the command
- Or right-click and select "Ask Cursor AI"
- Execution will stop at the breakpoint
Check Debug Information
- View Variables: Check variable values in the left debug panel
- Watch Expressions: Add expressions to monitor values
- Call Stack: View function call history
- Debug Console: Check
console.log output
Debugging Tips
- Log Output:
extension.ts includes detailed log output
- Check emoji logs like
🚀, 📝, ✅, ❌ in the debug console
- Watch Mode: Running
npm run watch will auto-compile when code changes
- Restart: If you change the extension code, restart the development host (
Ctrl+R or Cmd+R)
Common Issues
Breakpoints not working:
- Run
npm run compile to check if source maps are generated
- Check if the
out/extension.js.map file exists
Extension not loading:
- Run "Reload Extension" in the development host window
- Or close the development host and launch again with
F5
License
MIT License
Copyright (c) 2025 Toshihide KAWAI
See the LICENSE file for details.
Contributing
Pull requests and issue reports are welcome!