A package for managing reusable Cursor rules across projects. Crules allows you to define, share, and reuse AI coding guidelines in different projects.
npm install -g @bastienyoussfi/crules
Enable tab completion in your shell to easily navigate commands, rules, and profiles:
# Add this to your ~/.bashrc or ~/.zshrc
source <(crules completion)
After sourcing the completion script, you can use tab completion for commands and arguments:
crules add <TAB> # Shows available rules
crules add-group <TAB> # Shows available rule groups
crules apply-profile <TAB> # Shows available profiles
Add a rule to your project:
crules add typescript
List available rules:
crules list
Create a new rule template:
crules create my-rule
Add a group of related rules at once:
crules add-group typescript
Create a rule in your user registry (accessible across all projects):
crules create my-custom-rule --global
Export a project rule to your user registry:
crules export my-rule
Import a rule from your user registry to your current project:
crules import my-custom-rule
Save all your current project rules as a profile:
crules save-profile my-typescript-project
Apply a saved profile to a new project:
crules apply-profile my-typescript-project
List all saved profiles:
crules list-profiles
Export your rules to a JSON file for sharing with the community:
crules export-json my-awesome-rules.json
Import rules from a shared JSON file:
crules import-json my-awesome-rules.json
Use the --overwrite
flag to replace existing rules when importing:
crules import-json my-awesome-rules.json --overwrite
The exported JSON file includes metadata (project name, description, export date) and all rule contents, making it easy to share on GitHub, in blog posts, or other community platforms.
To contribute rules to the community, you can structure your repository like this:
my-cursor-rules/
├── README.md # Description and usage instructions
├── rules/ # Directory containing individual rule files
│ ├── typescript.mdc # Individual rule file
│ └── react.mdc # Individual rule file
└── packages/ # Pre-configured rule packages for easy import
├── typescript-basic.json # Package with basic TypeScript rules
└── react-best-practices.json # Package with React best practices
To define custom rule groups, modify the getRuleGroups
function in the src/index.ts
file.
MIT