MCP Server for automatically generating production-quality, modular cursor rules in .cursor/rules/ format for any project
npm install cursor-rules-generator-mcpAutomatically generate production-quality, modular cursor rules with .mdc format and AGENTS.md support


> _"Empowering developers with official Cursor rules format"_
---
Cursor Rules Generator is an intelligent system that automatically analyzes your codebase and generates comprehensive, organized cursor rules using the official Cursor format with zero manual input.
NEW in v3.1: Full support for the official Cursor rules format with .mdc (MDC) frontmatter metadata and AGENTS.md alternative format!
Instead of writing rules manually or using generic templates, this system:
- π Scans your repository - Dependencies, structure, code patterns, git workflow, environment variables
- π Analyzes everything - Compares your patterns against best practices
- π― Gives you options - Use current patterns, adopt best practices, or hybrid
- π Generates modular structure - Organized files with official .mdc format
- β¨ MDC Frontmatter - Each rule includes metadata for intelligent application
- π AGENTS.md Support - Optional simple markdown alternative
- π Includes role-based system - Cursor automatically adopts appropriate expert roles
---
.mdc format with nested rules:
your-project/
βββ AGENTS.md # Optional: Simple markdown alternative
βββ frontend/ # π³ NEW: Nested rules for frontend
β βββ .cursor/
β βββ rules/
β βββ main.mdc # Frontend-specific rules
βββ backend/ # π³ NEW: Nested rules for backend
β βββ .cursor/
β βββ rules/
β βββ main.mdc # Backend-specific rules
βββ .cursor/
βββ rules/ # Topic-specific rules with MDC frontmatter
β βββ main.mdc # Main entry point with project context
β βββ architecture.mdc # Each includes metadata for intelligent application
β βββ code-style.mdc # description: Applied based on context
β βββ git-workflow.mdc # globs: File patterns (optional)
β βββ testing.mdc # alwaysApply: Auto-application flag
β βββ security.mdc
β βββ performance.mdc
βββ prompts/ # Modular role-based system (custom extension)
β βββ README.mdc # Role announcement guide
β βββ documentation-writer.mdc
β βββ frontend-developer.mdc
β βββ backend-developer.mdc
β βββ software-architect.mdc
β βββ code-reviewer.mdc
β βββ qa-engineer.mdc
β βββ security-analyst.mdc
β βββ performance-engineer.mdc
β βββ database-administrator.mdc
βββ quick-reference.mdc # Commands & patterns
`π³ Nested Rules: Automatically creates subdirectory-specific rules that apply when working in:
-
frontend/ - UI components, state management, styling
- backend/ - API logic, database, authentication
- api/ - Endpoint definitions and validation
- services/ - Business logic layer
- packages/ - Monorepo package development
- apps/ - Monorepo applications
- terraform/ - Infrastructure as code (IaC)
- packer/ - Image building automation
- kubernetes/ or k8s/ - Container orchestration
- ansible/ - Configuration management
- docker/ - Containerization
- helm/ - Kubernetes package managementLearn more: https://cursor.com/docs/context/rules | Community: https://cursor.directory/rules
$3
- π Technology Folder Support: Detects and creates nested rules for DevOps/infrastructure folders (terraform, packer, kubernetes, ansible, docker, helm)
- π Community Resources: All rules now reference cursor.directory/rules for examples
- π§ Comprehensive Templates: Specialized guidelines for each technology with best practices
- π― Smart Detection: Recognizes both standard and shorthand directory names (kubernetes/k8s)
$3
- π³ Nested Rules Support: Automatically generates subdirectory-specific rules for better organization
- π Smart Directory Detection: Identifies frontend/, backend/, api/, and other key directories
- π― Context-Aware Rules: Rules automatically apply when working in specific directories
- π Enhanced Structure: Follows official Cursor nested rules pattern
$3
- β¨ Official MDC Format: All
.mdc files now include frontmatter metadata
- π AGENTS.md Support: Optional simple markdown alternative
- ποΈ Removed Deprecated .cursorrules: Now uses .cursor/rules/main.mdc as main entry
- π Updated Documentation: Aligned with official Cursor documentation
- π― Rule Metadata: Each rule includes description, globs, and alwaysApply fields
- π Official Links: References to https://cursor.com/docs/context/rules$3
- Languages: JavaScript/TypeScript, Python, Go, Rust, Ruby, Java, PHP, Dart, Elixir, Swift
- Frameworks: React, Vue, Angular, Next.js, FastAPI, Django, Flask, Express, and more
- Project Types: Web apps, APIs, mobile apps, CLI tools, libraries, microservices$3
Cursor automatically announces and adopts appropriate expert roles:
- π Documentation Writer
- βοΈ Frontend Developer
- π§ Backend Developer
- ποΈ Software Architect
- π§ͺ QA Engineer
- π Security Analyst
- And more...$3
Start with pre-built templates for popular tech stacks, then let our analyzer customize them for your project:Available Templates:
Frameworks:
- βοΈ React + TypeScript + Tailwind
- β‘ Next.js App Router
- π Python FastAPI
- π Django REST Framework
- π Vue 3 + TypeScript
- π Express + TypeScript
Full Stacks:
- π― Full-Stack TypeScript
- ποΈ Microservices Architecture
Languages:
- π Python Best Practices
- π¦ Rust Patterns
DevOps & Cloud (NEW!):
- π§ Terraform + AWS
- βΈοΈ Kubernetes + Helm
- π³ Docker Compose
- π GitHub Actions CI/CD
How It Works:
1. Optional: Choose a template:
"List available templates"
2. Automatic: Analyzer scans your codebase
3. Smart Merge: Template best practices + your patterns
4. Result: Best of both worlds!See TEMPLATES.md for details on each template.
---
π Quick Start
$3
Set up once, use everywhere! The MCP server integrates directly with Cursor.
No installation needed - uses npx to run automatically!
`json
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"cursor-rules-generator": {
"command": "npx",
"args": ["-y", "cursor-rules-generator-mcp@latest"],
"env": {
"TEMPLATE_REPO_URL": "https://github.com/ankitpro/cursor-rules-generator.git"
}
}
}
}
`That's it! Restart Cursor, then use in any project:
`
"Generate cursor rules for /path/to/my/project"
`The MCP server automatically:
- β
Fetches latest templates from GitHub
- β
Analyzes your project
- β
Generates cursor rules
- β
No manual installation required!
π Full MCP Setup Guide: MCP_SETUP.md
$3
Copy the folder to each project:
`bash
Clone and copy to your project
git clone https://github.com/ankitpro/cursor-rules-generator.git
cp -r cursor-rules-generator /path/to/your/project/
cd /path/to/your/projectIn Cursor:
@cursor-rules-generatorScan my repository and generate comprehensive cursor rules based on my actual codebase.
Commit and cleanup
git add .cursor/ AGENTS.md
git commit -m "chore: Add cursor rules"
rm -rf cursor-rules-generator
`---
π Documentation
| File | Purpose |
|------|---------|
| README.md | Project overview - Start here! |
| TEMPLATES.md | NEW v3.0! Template library guide |
| CHANGELOG.md | v3.0 features and changelog |
| MCP_SETUP.md | MCP Server setup guide |
| QUICK_START.md | 5-minute setup guide (folder method) |
| docs/USER_GUIDE.md | Complete user guide |
| docs/GENERATOR_TEMPLATE.md | Master template (for Cursor AI) |
| docs/STRUCTURE_EXAMPLE.md | Visual example of generated structure |
| CONTRIBUTING.md | Contribution guidelines |
---
π‘ How It Works
$3
Cursor scans your repository:
- π¦ Dependencies - package.json, requirements.txt, go.mod, etc.
- ποΈ Structure - Monorepo, frontend/backend split, folder organization
- π Code Patterns - Naming conventions, error handling, function patterns
- π³ Git Workflow - Branches, commits, versioning
- βοΈ Environment - .env files, configuration
- π§ͺ Testing - Framework, patterns, coverage
$3
Cursor generates comprehensive report:
`
π Repository Analysis Completeπ¦ Detected Technologies:
- Frontend: React 18.2.0 with TypeScript
- Backend: Node.js 20.x with Express 4.x
- Database: PostgreSQL
- Testing: Jest + React Testing Library
π Code Patterns Found:
β
Consistent camelCase for functions
β οΈ Mixed error handling (suggest standardization)
β No JSDoc comments found
π‘ Recommendations:
1. Add JSDoc to public APIs
2. Standardize error handling
3. Adopt conventional commits
π― Choose:
A) Use current patterns (as-is documentation)
B) Apply best practices (with improvements)
C) Hybrid approach (choose per topic)
`$3
Based on your choice, Cursor creates:
-
.cursor/rules/main.mdc with quick context (main entry point)
- .cursor/rules/ with detailed topic files
- .cursor/prompts/ with individual role files (each role has its own file for easy customization!)
- .cursor/quick-reference.mdc with commands
- Optional AGENTS.md for simple setups---
π― Use Cases
$3
- π New Projects - Set up quality standards from day one
- π Existing Projects - Document actual patterns and conventions
- π Multiple Projects - Maintain consistency across repos$3
- π₯ Onboarding - New members learn standards progressively
- π Code Reviews - Standardized patterns for consistent reviews
- π Collaboration - Share and sync coding standards$3
- π’ Multi-team Projects - Ensure consistency across teams
- π Quality Standards - Enforce best practices automatically
- π§ Maintenance - Easy updates to standards over time---
π Examples
$3
Automatically detects and documents:
- React hooks patterns
- Material-UI component usage
- Express service layer
- Jest + React Testing Library
- PostgreSQL parameterized queries$3
Automatically detects and documents:
- Async/await patterns
- Type hints usage
- Pydantic models
- pytest patterns
- SQLAlchemy queries$3
Automatically detects and documents:
- Package organization
- Error handling patterns
- Testing with table-driven tests
- Docker deployment
- gRPC or REST API design---
π Learning Path
$3
1. Read QUICK_START.md - 5-minute setup
2. Try in a test project first
3. Review generated files
4. Explore docs/STRUCTURE_EXAMPLE.md
5. Read docs/USER_GUIDE.md for details$3
1. Review docs/CHANGELOG.md
2. Regenerate with v2.0 for modular structure
3. Migrate custom rules to appropriate files---
π€ Contributing
Contributions are welcome and encouraged! Whether you're fixing bugs, adding features, or improving documentation, your input is valued.
π See CONTRIBUTING.md for complete guidelines
$3
1. Fork the repository
2. Create a feature branch:
git checkout -b feature/your-feature
3. Make your changes
4. Test thoroughly
5. Commit: git commit -m "feat: Your feature description"
6. Push and create a Pull Request$3
- [ ] π Add support for more languages/frameworks
- [ ] π Create rule templates for common project types
- [ ] π§ͺ Add comprehensive tests
- [ ] π§ Add CI/CD integration checks
- [ ] π Build rule validation tool
- [ ] π Create community rule sharing platform
- [ ] π Improve documentation and examples
All skill levels welcome! See CONTRIBUTING.md for detailed guidelines.
---
π¨βπ» Author
Ankit Agarwal
- π§ Email: ankitagarwalpro@gmail.com
- π GitHub: @ankitpro
- π‘ Mission: Making Cursor development more efficient for everyone
_"Born from real-world needs, built for real-world developers."_
---
π License
MIT License - See LICENSE file for details
---
π Acknowledgments
- Inspired by the Cursor community
- Based on production experience and best practices from real-world usage
- Built for developers, by developers
---
π Support
- π¬ GitHub Issues: For bug reports and feature requests
- π Documentation: Comprehensive guides in this repository
---
π Get Started Now
$3
`json
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"cursor-rules-generator": {
"command": "npx",
"args": ["-y", "cursor-rules-generator-mcp@latest"],
"env": {
"TEMPLATE_REPO_URL": "https://github.com/ankitpro/cursor-rules-generator.git"
}
}
}
}Restart Cursor, then use in any project:
"Generate cursor rules for /path/to/my/project"
`$3
`bash
Clone and copy to your project
git clone https://github.com/ankitpro/cursor-rules-generator.git
cp -r cursor-rules-generator /path/to/your/project/Open in Cursor:
@cursor-rules-generator
Scan my repository and generate comprehensive cursor rules
`Transform your development workflow with intelligent, automated cursor rules! π
---
π¦ Installation Scripts
-
./install-mcp.sh - Automated MCP server setup
- ./verify-setup.sh` - Verify installation is correct---
Version: 3.4.0
Last Updated: December 10, 2024
Status: β
Production Ready