A CLI tool to help initialize and manage Cursor Editor rules for your projects.
# Install with Homebrew
brew install fireharp/tap/cursor-rules
# Initialize with just the init template
cursor-rules init
# Auto-detect project type and setup appropriate rules
cursor-rules setup
This tool makes it easy to set up and manage .cursor/rules
configuration for Cursor editor. It provides:
- Pre-defined templates for various languages (Python, Go, etc.)
- Pre-defined templates for frameworks (React, etc.)
- Ability to create custom rule templates
- Interactive CLI interface
# Initialize Cursor Rules with just the init template
cursor-rules init
# Auto-detect project type, then add rules
cursor-rules setup
# Add a rule from a local file path
cursor-rules add ./custom-rules/my-rule.mdc
# Add a rule from a GitHub URL
cursor-rules add https://github.com/username/repo/blob/main/rules/myrule.mdc
# Alternative method for adding from references (alias for 'add')
cursor-rules add-ref /Users/me/custom-rule.mdc
# Remove an installed rule
cursor-rules remove python
# Reinstall / upgrade a rule
cursor-rules upgrade python
# List installed rules
cursor-rules list
# List installed rules with detailed information
cursor-rules list --detailed
# Set lockfile location (project root or .cursor/rules)
cursor-rules set-lock-location --root # Store in project root
cursor-rules set-lock-location # Store in .cursor/rules
The cursor-rules tool supports adding rules from various references, similar to how npm or pip handle dependencies:
# Add a rule from a local file (absolute path)
cursor-rules add /Users/username/rules/python-style.mdc
# Add a rule from a local file (relative path)
cursor-rules add ./custom-rules/go-style.mdc
# Add a rule from a GitHub file
cursor-rules add https://github.com/username/repo/blob/main/rules/react-style.mdc
# Add a rule from a GitHub file with specific commit
cursor-rules add https://github.com/username/repo/blob/a1b2c3d/rules/python-style.mdc
When rules are added from references, they can be managed just like built-in rules:
# Upgrade a rule (will re-fetch from the original source)
cursor-rules upgrade python-style
# Remove a rule added from a reference
cursor-rules remove python-style
# View detailed information about installed rules
cursor-rules list --detailed
By default, the lockfile (cursor-rules.lock
) is stored in the .cursor/rules
directory. However, you can configure it to be stored in your project root directory instead:
# Set lockfile location to project root
cursor-rules set-lock-location --root
# Set lockfile location back to .cursor/rules
cursor-rules set-lock-location
This can be useful for tracking the lockfile in version control or for better visibility of installed rules.
# Show help and usage information
cursor-rules help
Cursor Rules are stored in the .cursor/rules
directory in your project root. Each rule is a file with a .mdc
extension containing instructions for Cursor AI. When you use the package manager commands, a cursor-rules.lock
file is created to track installed rules.
Templates tailored for specific programming languages, including:
- Python
- Go
- (more coming soon)
Templates tailored for specific frameworks, including:
- React
- (more coming soon)
A general template with common coding rules that apply to most projects.
You can create your own templates with custom rules that fit your specific needs.
# Install directly
brew install fireharp/tap/cursor-rules
# Or, tap first and then install
brew tap fireharp/tap
brew install cursor-rules
go install github.com/fireharp/cursor-rules/cmd/cursor-rules@latest
This project uses Task as a task runner. First, install Task.
Then you can run:
# Build the binary
task build
# Run the application
task run
# Run tests
task test
# Install the binary
task install
# Clean build artifacts
task clean
git clone https://github.com/fireharp/cursor-rules.git
cd cursor-rules
go build -o cursor-rules ./cmd/cursor-rules
- Clone the repository
- Make your changes
- Run tests with
task test
- Build and test locally with
task run
To add more templates:
- Fork the repository
- Add your templates to the
pkg/templates/templates.go
file - Make sure tests pass with
task test
- Submit a pull request
MIT License