Airsc miễn phí cho tất cả. Nếu nó giúp bạn, hãy ủng hộ $2–$20.

Ủng hộ
Cursor ruleAn toànReview & chất lượng codeCần cài đặt chút

rulefy

niklub · niklub/rulefy

Công cụ này tạo ra các quy tắc tùy chỉnh cho Cursor AI từ các kho GitHub hoặc codebase cục bộ, cung cấp thông tin chuyên sâu theo từng codebase để có các gợi ý code tốt hơn và giảm hiện tượng AI "ảo giác".

Nâng cấp Cursor AI của bạn với thông tin chuyên sâu về cơ sở mã. Rulefy biến các kho lưu trữ GitHub của bạn thành các quy tắc tùy chỉnh dạy Cursor AI cách dự án của bạn hoạt động, mang lại các gợi ý mã chính xác hơn, tái cấu trúc tốt hơn và hỗ trợ nhận biết ngữ cảnh.

28 sao9Giấy phép: MITCập nhật 6 tháng trước0 lượt mở

Xem trước

▍

Bạn có thể làm gì với nó

  • Tạo các quy tắc Cursor để thực thi các phong cách và pattern coding cụ thể của dự án.
  • Cải thiện độ chính xác của các đoạn code do AI hoàn thành bằng cách cung cấp ngữ cảnh codebase.
  • Nhanh chóng đưa Cursor AI vào một codebase mới mà không cần tạo quy tắc thủ công.

Kiểm tra an toàn

An toàn

Không thấy dấu hiệu rủi ro trong các file đã quét.

Quét tự động các file trong repo. Luôn xem lại code trước khi chạy.

Trích từ README

Rulefy

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.

Why Rulefy?

  • ✅ 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

Features

  • 🚀 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

Installation

# Install globally
npm install -g rulefy

# Or use with npx (no installation required)
npx rulefy

Prerequisites

  • Node.js 18 or higher
  • ANTHROPIC_API_KEY environment variable set with your Anthropic API key
export ANTHROPIC_API_KEY='your-anthropic-api-key'

Usage

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:

  1. Fetch the repository content
  2. Based on the content, generate rules for Cursor AI
  3. Save the output to a <repo-name>.rules.mdc file

Options

Options:
  --provider     LLM model to use (default: "claude-sonnet-4-5-20250929")
  --description <text>     Description of what should be rulefied
  --rule-type <type>       Type of rule to generate (auto, manual, agent, always)
  --tokenizer <tokenizer>  Tokenizer used to count tokens (default: "p50k_base")
  --chunk-size <size>      Chunk size for the repository to be processed in one go (default: 100000)
  -h, --help               display help for command

rulefy supports all options supported by repomix. For example, select specific files:

rulefy --include "src/**/*.ts" --compress

Installing Rules in Cursor

After generating your rules file, you'll need to install it in Cursor:

  1. Open Cursor editor
  2. Go to Settings > AI > Rules
  3. Click "Add Rules File" and select your generated <filename>.rules.mdc file
  4. Restart Cursor to apply the new rules

For more detailed instructions, see the official Cursor documentation.

Example Output

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
...

Best Practices

Minimize context length, cost and rate limits

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)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Acknowledgements

This project is inspired by and builds upon the work of:

We're grateful to these projects for their contributions to the developer tooling ecosystem.

Xem mã nguồn trên GitHub