|
| 1 | +# Creating Markdown Links to Send Prompts to Cursor AI |
| 2 | + |
| 3 | +This guide explains how to create markdown links that can send prompts to Cursor AI, similar to bugbot functionality. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +While Cursor doesn't have direct URL scheme support for sending prompts like some other tools, there are several approaches to achieve similar functionality: |
| 8 | + |
| 9 | +## Method 1: Using Cursor Rules with Markdown Templates |
| 10 | + |
| 11 | +### 1. Create a Rule Template System |
| 12 | + |
| 13 | +Create a `.cursor/rules/core-rules/prompt-templates-agent.mdc` file: |
| 14 | + |
| 15 | +```markdown |
| 16 | +--- |
| 17 | +description: Handles template-based prompts and quick actions for common development tasks. Activates when users reference specific template keywords or request standardized operations like bug analysis, code review, or documentation generation. |
| 18 | +globs: |
| 19 | +alwaysApply: false |
| 20 | +--- |
| 21 | + |
| 22 | +# Prompt Templates Agent |
| 23 | + |
| 24 | +## Template Keywords |
| 25 | + |
| 26 | +When users mention these keywords, apply the corresponding template: |
| 27 | + |
| 28 | +- `@bugbot` - Analyze code for potential bugs and issues |
| 29 | +- `@reviewer` - Perform comprehensive code review |
| 30 | +- `@documenter` - Generate documentation for code |
| 31 | +- `@optimizer` - Suggest performance optimizations |
| 32 | +- `@tester` - Generate test cases |
| 33 | + |
| 34 | +## Bug Analysis Template (@bugbot) |
| 35 | + |
| 36 | +When `@bugbot` is mentioned: |
| 37 | + |
| 38 | +1. Analyze the provided code for: |
| 39 | + - Logic errors |
| 40 | + - Potential runtime exceptions |
| 41 | + - Security vulnerabilities |
| 42 | + - Performance issues |
| 43 | + - Code smell patterns |
| 44 | + |
| 45 | +2. Provide structured output: |
| 46 | + - **Issue Type**: Category of the problem |
| 47 | + - **Severity**: High/Medium/Low |
| 48 | + - **Description**: Clear explanation |
| 49 | + - **Suggested Fix**: Concrete solution |
| 50 | + - **Prevention**: How to avoid similar issues |
| 51 | + |
| 52 | +## Examples |
| 53 | + |
| 54 | +<example> |
| 55 | +User: "@bugbot analyze this function" |
| 56 | +Response: Structured bug analysis with categorized findings |
| 57 | +</example> |
| 58 | + |
| 59 | +<example type="invalid"> |
| 60 | +User: "@bugbot analyze this function" |
| 61 | +Response: Generic code review without structured bug analysis format |
| 62 | +</example> |
| 63 | +``` |
| 64 | + |
| 65 | +### 2. Create Markdown Documentation with Quick Links |
| 66 | + |
| 67 | +Create a `quick-actions.md` file in your project: |
| 68 | + |
| 69 | +```markdown |
| 70 | +# Quick Action Links for Cursor AI |
| 71 | + |
| 72 | +Click these links to quickly access common AI prompts: |
| 73 | + |
| 74 | +## 🐛 Bug Analysis |
| 75 | +**Markdown to copy:** `@bugbot analyze the selected code for potential bugs and security issues` |
| 76 | + |
| 77 | +## 📝 Code Review |
| 78 | +**Markdown to copy:** `@reviewer perform a comprehensive code review focusing on best practices and maintainability` |
| 79 | + |
| 80 | +## 📚 Documentation |
| 81 | +**Markdown to copy:** `@documenter generate comprehensive documentation for the selected code including examples` |
| 82 | + |
| 83 | +## ⚡ Performance Optimization |
| 84 | +**Markdown to copy:** `@optimizer analyze and suggest performance improvements for the selected code` |
| 85 | + |
| 86 | +## 🧪 Test Generation |
| 87 | +**Markdown to copy:** `@tester generate comprehensive test cases for the selected code including edge cases` |
| 88 | + |
| 89 | +## Usage Instructions |
| 90 | + |
| 91 | +1. Select the code you want to analyze |
| 92 | +2. Copy one of the prompts above |
| 93 | +3. Open Cursor Chat (Cmd/Ctrl + L) |
| 94 | +4. Paste the prompt and press Enter |
| 95 | + |
| 96 | +## Custom Prompts |
| 97 | + |
| 98 | +You can also create custom prompts by combining keywords: |
| 99 | + |
| 100 | +- `@bugbot @reviewer` - Bug analysis + code review |
| 101 | +- `@documenter @tester` - Documentation + test generation |
| 102 | +- `@optimizer @reviewer` - Performance review |
| 103 | + |
| 104 | +## Advanced Usage |
| 105 | + |
| 106 | +For more complex scenarios, reference specific files: |
| 107 | +``` |
| 108 | +@bugbot analyze @src/utils/auth.ts for security vulnerabilities |
| 109 | +``` |
| 110 | +``` |
| 111 | + |
| 112 | +## Method 2: Using Cursor's @ Symbol System |
| 113 | + |
| 114 | +Cursor has built-in @ symbols that can be used in markdown documentation: |
| 115 | + |
| 116 | +```markdown |
| 117 | +# Development Workflow Links |
| 118 | + |
| 119 | +## Quick Actions |
| 120 | + |
| 121 | +### Bug Analysis |
| 122 | +``` |
| 123 | +@Cursor Rules @Files |
| 124 | +Analyze the current file for potential bugs, focusing on: |
| 125 | +- Logic errors and edge cases |
| 126 | +- Security vulnerabilities |
| 127 | +- Performance bottlenecks |
| 128 | +- Code maintainability issues |
| 129 | +``` |
| 130 | +
|
| 131 | +### Code Review |
| 132 | +``` |
| 133 | +@Recent Changes @Lint Errors |
| 134 | +Perform a comprehensive code review of recent changes: |
| 135 | +- Check for adherence to coding standards |
| 136 | +- Identify potential improvements |
| 137 | +- Suggest refactoring opportunities |
| 138 | +``` |
| 139 | +
|
| 140 | +### Documentation Generation |
| 141 | +``` |
| 142 | +@Code @Definitions |
| 143 | +Generate comprehensive documentation including: |
| 144 | +- Function/class descriptions |
| 145 | +- Parameter explanations |
| 146 | +- Usage examples |
| 147 | +- Return value documentation |
| 148 | +``` |
| 149 | +``` |
| 150 | + |
| 151 | +## Method 3: Creating Custom Cursor Modes |
| 152 | + |
| 153 | +You can create custom modes in Cursor that act like specialized bots: |
| 154 | + |
| 155 | +### 1. Create a modes.json file |
| 156 | + |
| 157 | +Create `.cursor/modes.json`: |
| 158 | + |
| 159 | +```json |
| 160 | +{ |
| 161 | + "bugbot": { |
| 162 | + "name": "Bug Detective", |
| 163 | + "description": "Specialized in finding and fixing bugs", |
| 164 | + "systemPrompt": "You are a bug detection specialist. When analyzing code, focus on:\n1. Logic errors and edge cases\n2. Security vulnerabilities\n3. Performance issues\n4. Potential runtime exceptions\n\nAlways provide structured output with severity levels and concrete fixes.", |
| 165 | + "model": "claude-3.5-sonnet", |
| 166 | + "tools": ["terminal", "file_operations"] |
| 167 | + }, |
| 168 | + "reviewer": { |
| 169 | + "name": "Code Reviewer", |
| 170 | + "description": "Comprehensive code review specialist", |
| 171 | + "systemPrompt": "You are a senior code reviewer. Provide thorough reviews focusing on:\n1. Code quality and best practices\n2. Architecture and design patterns\n3. Performance optimization\n4. Security considerations\n5. Maintainability and readability", |
| 172 | + "model": "claude-3.5-sonnet", |
| 173 | + "tools": ["file_operations"] |
| 174 | + } |
| 175 | +} |
| 176 | +``` |
| 177 | + |
| 178 | +### 2. Reference in Markdown |
| 179 | + |
| 180 | +```markdown |
| 181 | +# Quick AI Assistants |
| 182 | + |
| 183 | +## 🐛 Bug Detective |
| 184 | +Switch to Bug Detective mode and ask: "Analyze this code for bugs" |
| 185 | + |
| 186 | +## 👨💻 Code Reviewer |
| 187 | +Switch to Code Reviewer mode and ask: "Review this implementation" |
| 188 | + |
| 189 | +## How to Use |
| 190 | +1. Open Cursor Chat |
| 191 | +2. Select the appropriate mode from the dropdown |
| 192 | +3. Paste your code or reference files with @ |
| 193 | +4. Ask your question |
| 194 | +``` |
| 195 | + |
| 196 | +## Method 4: Browser Bookmarklets (Advanced) |
| 197 | + |
| 198 | +For a more "link-like" experience, you can create browser bookmarklets: |
| 199 | + |
| 200 | +```javascript |
| 201 | +javascript:(function(){ |
| 202 | + const prompt = "Analyze the selected code for potential bugs and security issues"; |
| 203 | + navigator.clipboard.writeText(prompt).then(() => { |
| 204 | + alert("Prompt copied! Switch to Cursor and paste in chat."); |
| 205 | + }); |
| 206 | +})(); |
| 207 | +``` |
| 208 | + |
| 209 | +Save this as a bookmark with the title "Copy Bugbot Prompt". |
| 210 | + |
| 211 | +## Best Practices |
| 212 | + |
| 213 | +1. **Use Descriptive Keywords**: Make your prompt templates easy to remember |
| 214 | +2. **Structure Your Prompts**: Use consistent formatting for better AI responses |
| 215 | +3. **Version Control**: Keep your rules and templates in version control |
| 216 | +4. **Team Sharing**: Share prompt templates with your team through documentation |
| 217 | +5. **Iterate and Improve**: Refine your prompts based on AI responses |
| 218 | + |
| 219 | +## Example Implementation |
| 220 | + |
| 221 | +Here's a complete example of a markdown file with "bugbot-like" functionality: |
| 222 | + |
| 223 | +```markdown |
| 224 | +# AI Assistant Quick Actions |
| 225 | + |
| 226 | +## 🚀 Quick Start |
| 227 | +1. Select code in Cursor |
| 228 | +2. Copy a prompt below |
| 229 | +3. Open Chat (Cmd/Ctrl + L) |
| 230 | +4. Paste and run |
| 231 | + |
| 232 | +## 🐛 Bug Detection |
| 233 | +``` |
| 234 | +@Cursor Rules |
| 235 | +Act as a bug detection specialist. Analyze the selected code and provide: |
| 236 | + |
| 237 | +**BUGS FOUND:** |
| 238 | +- Issue type and severity |
| 239 | +- Exact location and description |
| 240 | +- Recommended fix |
| 241 | +- Prevention strategy |
| 242 | + |
| 243 | +Focus on: logic errors, security issues, performance problems, edge cases. |
| 244 | +``` |
| 245 | +
|
| 246 | +## 📋 Code Review |
| 247 | +``` |
| 248 | +@Recent Changes @Lint Errors |
| 249 | +Perform a senior-level code review covering: |
| 250 | + |
| 251 | +**REVIEW CHECKLIST:** |
| 252 | +- [ ] Code quality and standards |
| 253 | +- [ ] Security considerations |
| 254 | +- [ ] Performance implications |
| 255 | +- [ ] Maintainability |
| 256 | +- [ ] Test coverage needs |
| 257 | + |
| 258 | +Provide specific, actionable feedback. |
| 259 | +``` |
| 260 | +
|
| 261 | +## 📖 Documentation |
| 262 | +``` |
| 263 | +@Definitions @Code |
| 264 | +Generate comprehensive documentation: |
| 265 | + |
| 266 | +**DOCUMENTATION STRUCTURE:** |
| 267 | +- Overview and purpose |
| 268 | +- Parameters and return values |
| 269 | +- Usage examples |
| 270 | +- Edge cases and limitations |
| 271 | +- Related functions/classes |
| 272 | + |
| 273 | +Use clear, professional language. |
| 274 | +``` |
| 275 | +``` |
| 276 | + |
| 277 | +This approach gives you bugbot-like functionality within Cursor's existing framework, allowing you to create reusable, shareable prompts that can be easily accessed through markdown documentation. |
0 commit comments