Quickly create Cursor project rules from selected text or terminal output. Opens Cursor chat with a comprehensive prompt to generate properly scoped .mdc rule files.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
A Cursor extension that helps you quickly create Cursor project rules (.mdc files) from selected text or terminal output. Simply select text in your editor or terminal, and the extension will open Cursor chat with a comprehensive prompt to generate a properly scoped rule file.
Features
Quick Rule Creation: Select text in editor or terminal and create a rule with one command
Smart Prompting: Automatically generates a comprehensive prompt following Cursor best practices
Proper Scoping: Guides the AI to create rules with appropriate globs, alwaysApply, and nested directory placement
Context-Aware: Works with both editor selections and terminal output
Usage
From Editor: Select text in any editor, right-click, and choose "Create Cursor Rule from Selection"
From Terminal: Select text in the terminal, right-click, and choose "Create Cursor Rule from Selection"
From Clipboard: If no text is selected, the extension will try to use clipboard content
The extension will:
Open Cursor chat
Paste a comprehensive prompt for creating the rule
Guide the AI to generate a properly formatted .mdc file with appropriate metadata
Requirements
Cursor IDE (for the chat functionality)
Extension Settings
This extension contributes the following command:
cursor-rules.createFromSelection: Create a Cursor rule from the current selection
Installation
From VSIX File (Recommended)
Download the cursor-create-rule-from-selection-0.0.2.vsix file from the GitHub repository
Go to Extensions view (Ctrl+Shift+X / Cmd+Shift+X)
Search for "Create Cursor Rule from Selection"
Click Install
License
MIT
Customizing the Prompt
The extension uses a prompt template file to generate the instructions sent to Cursor chat. You can customize this prompt to better suit your needs.
How to Modify the Prompt
Locate the prompt template file: prompt-template.md (in the extension root directory)
Edit the template: Open prompt-template.md and modify the prompt text as needed. The template uses {{INPUT_TEXT}} as a placeholder that will be replaced with the selected text.
Rebuild the extension: After making changes, rebuild the extension:
npm run build
Reload the extension: In Cursor, press Ctrl+Shift+P (or Cmd+Shift+P on Mac) and run "Developer: Reload Window" to apply your changes.
Prompt Template Structure
The prompt template is a Markdown file that contains instructions for the AI. Key points:
Use {{INPUT_TEXT}} as a placeholder for where the selected text will be inserted
The template should guide the AI to create properly formatted .mdc rule files
You can customize the instructions, examples, and formatting requirements
Example Customization
If you want to add specific requirements or change the output format, simply edit prompt-template.md. For example, you could:
Add project-specific conventions
Modify the rule structure requirements
Change the file naming conventions
Add additional validation steps
After editing, remember to rebuild and reload the extension for changes to take effect.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.