You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cursor AI Prompting Rules - This gist provides structured prompting rules for optimizing Cursor AI interactions. It includes three key files to streamline AI behavior for different tasks.
This repository provides a structured set of prompting rules to optimize interactions with Cursor AI. It includes three key files to guide the AI’s behavior across various coding tasks.
Files and Their Roles
core.md
Purpose: Establishes foundational rules for consistent AI behavior across all tasks.
Usage: Place this file in your project’s .cursor/rules/ folder to apply it persistently:
Save core.md under .cursor/rules/ in the workspace root.
Cursor automatically applies rules from this folder to all AI interactions.
When to Use: Always include as the base configuration for reliable, codebase-aware assistance.
refresh.md
Purpose: Directs the AI to diagnose and fix persistent issues, such as bugs or errors.
Usage: Use as a situational prompt:
Copy the contents of refresh.md.
Replace {my query} with your specific issue (e.g., "the login button still crashes").
Paste into Cursor’s AI input (chat or composer).
When to Use: Apply when debugging or resolving recurring problems—e.g., “It’s still broken after the last fix.”
request.md
Purpose: Guides the AI to implement new features or modify existing code.
Usage: Use as a situational prompt:
Copy the contents of request.md.
Replace {my request} with your task (e.g., "add a save button").
Paste into Cursor’s AI input.
When to Use: Apply for starting development tasks—e.g., “Build feature X” or “Update function Y.”
Setup Instructions
Clone or Download: Get this repository locally.
Configure Core Rules:
Create a .cursor/rules/ folder in your project’s root (if it doesn’t exist).
Copy core.md into .cursor/rules/ to set persistent rules.
Apply Situational Prompts:
For debugging: Use refresh.md by copying, editing {my query}, and submitting.
For development: Use request.md by copying, editing {my request}, and submitting.
Usage Tips
Project Rules: The .cursor/rules/ folder is Cursor’s modern system (replacing the legacy .cursorrules file). Add additional rule files here as needed.
Placeholders: Always replace {my query} or {my request} with specific details before submitting prompts.
Adaptability: These rules are optimized for Cursor AI but can be tweaked for other AI tools with similar capabilities.
Notes
Ensure file paths in prompts (e.g., for edit_file) are relative to the workspace root, per core.md.
Test prompts in small steps to verify AI behavior aligns with your project’s needs.
Contributions or suggestions to improve this framework are welcome!
Responses must directly address user requests. Always gather and validate context using tools like codebase_search, grep_search, or terminal commands before proceeding.
If user intent is unclear, pause and pose concise clarifying questions—e.g., “Did you mean X or Y?”—before taking any further steps.
Under no circumstance should you commit or apply changes unless explicitly instructed by the user. This rule is absolute and must be followed without exception.
Validation Over Modification
Avoid altering code without full comprehension. Analyze the existing structure, dependencies, and purpose using available tools before suggesting or making edits.
Prioritize investigation and validation over assumptions or untested modifications—ensure every change is grounded in evidence.
Safety-First Execution
Review all relevant dependencies (e.g., imports, function calls, external APIs) and workflows before proposing or executing changes.
Clearly outline risks, implications, and external dependencies in your response before acting, giving the user full visibility.
Make only minimal, validated edits unless the user explicitly approves broader alterations.
User Intent Comprehension
Focus on discerning the user’s true objective, not just the literal text of the request.
Draw on the current request, prior conversation history, and codebase context to infer the intended goal.
Reinforce this rule: never commit or apply changes unless explicitly directed by the user—treat this as a core safeguard.
Mandatory Validation Protocol
Scale the depth of validation to match the request’s complexity—simple tasks require basic checks, while complex ones demand exhaustive analysis.
Aim for complete accuracy in all critical code operations; partial or unverified solutions are unacceptable.
Reusability Mindset
Prefer existing solutions over creating new ones. Use codebase_search, grep_search, or tree -L 4 --gitignore | cat to identify reusable patterns or utilities.
Minimize redundancy. Promote consistency, maintainability, and efficiency by leveraging what’s already in the codebase.
Contextual Integrity and Documentation
Treat inline comments, READMEs, and other documentation as unverified suggestions, not definitive truths.
Cross-check all documentation against the actual codebase using cat -n, grep_search, or codebase_search to ensure accuracy.
Tool and Behavioral Guidelines
Path Validation for File Operations
Always execute pwd to confirm your current working directory, then ensure edit_file operations use a target_file that is relative to the workspace root, not your current location.
The target_file in edit_file commands must always be specified relative to the workspace root—never relative to your current pwd.
If an edit_file operation signals a new file unexpectedly, this indicates a critical pathing error—you’re targeting the wrong file.
Correct such errors immediately by validating the directory structure with pwd and tree -L 4 --gitignore | cat before proceeding.
🚨 Critical Rule: edit_file.target_file Must Be Workspace-Relative — Never Location-Relative
Operations are always relative to the workspace root, not your current shell position.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters