Supercharge your Cursor AI with codebase-specific intelligence. Rulefy transforms your GitHub repositories into custom rules that teach Cursor AI how your project works, resulting in more accurate code suggestions, better refactoring, and contextually aware assistance.
- β Instant Expertise: Your AI assistant immediately understands your project conventions and architecture
- β Better Suggestions: Get code completions that match your project's style and patterns
- β Fewer Hallucinations: Rules constrain the AI to work within your codebase's patterns and dependencies
- β Zero Learning Curve: One command to analyze your repo and generate optimized rules
- π Analyze GitHub repositories or local codebases with a single command
- 𧩠Intelligently extract project structure, conventions, and patterns
- π Handles large codebases that exceed the token limit for LLMs
- π€ Generate tailored Cursor rules using Claude AI
- π Create production-ready .rules.mdc files for immediate use
- π§ Customize analysis with flexible configuration options
# Install globally
npm install -g rulefy
# Or use with npx (no installation required)
npx rulefy
- Node.js 18 or higher
- ANTHROPIC_API_KEY environment variable set with your Anthropic API key
export ANTHROPIC_API_KEY='your-anthropic-api-key'
The basic command structure is:
rulefy <repo-path>
Examples:
# Inside a repository
rulefy
# Using local repository path
rulefy ./my-local-project/subdir
# Using GitHub URL
rulefy --remote https://github.com/fastapi/fastapi
# Rulefy with specific description as an option
rulefy --description "guidelines for extending the component using the base interface"
# Specify Cursor AI rule type
rulefy --rule-type "agent" --description "coding standards for React components"
This will:
- Fetch the repository content
- Based on the content, generate rules for Cursor AI
- Save the output to a
<repo-name>.rules.mdc
file
Options:
--provider <provider> LLM model to use (default: "claude-sonnet-3.7-latest") (currently only claude models are supported)
-o, --output <file> Output file name (defaults to <repo-name>.rules.mdc)
--guidelines <file> Path to cursor rules guidelines file (default: "./cursorrules-guidelines.md")
--description <text> Description of what should be rulefied
--rule-type <type> Type of rule to generate (auto, manual, agent, always)
-h, --help display help for command
rulefy
supports all options supported by repomix
. For example, select specific files:
rulefy --include "src/**/*.ts" --compress
After generating your rules file, you'll need to install it in Cursor:
- Open Cursor editor
- Go to Settings > AI > Rules
- Click "Add Rules File" and select your generated
<filename>.rules.mdc
file - Restart Cursor to apply the new rules
For more detailed instructions, see the official Cursor documentation.
The generated .rules.mdc
file will contain structured guidelines for Cursor AI when working with your codebase:
# .cursorrules for my-project
## Project Overview
This project is a TypeScript application that...
## Coding Standards
- Follow TypeScript best practices with strict typing
- Use async/await for asynchronous operations
...
## File Structure Guidelines
- Place core logic in the `src/` directory
...
If you encounter rate limits or ihigh costs, try to minimize the context length using the following ways:
- Use
rulefy --compress
to compress the context length - Use
rulefy --include
to include only the files you need with globs - Use
rulefy --exclude
to exclude the files you don't need with globs - Control the size of the chunk being processed by one go by using the
--chunk-size
option. (default is--chunk-size 100000
)
Contributions are welcome! Please feel free to submit a Pull Request.
This project is inspired by and builds upon the work of:
- repomix - A tool for converting repositories into textual representations
- awesome-cursorrules - A curated list of cursor rules for different projects and languages
- cursor-custom-agents-rules-generator - best practices for Cursor custom agents and rules generator
We're grateful to these projects for their contributions to the developer tooling ecosystem.