Cursor Rules MDC Generator — Auto-Generate from Docs
Auto-generate Cursor .mdc rule files for any library using Exa semantic search and LLM-powered documentation extraction.
What it is
Cursor Rules MDC Generator is a Python tool that creates Cursor AI rule files (.mdc) for any programming library. It uses Exa semantic search to find documentation, best practices, and coding patterns for a specified library, then feeds that information through an LLM (Gemini, OpenAI, or Anthropic) to produce structured rule files that Cursor follows during code generation.
This tool targets developers who want Cursor to follow library-specific conventions automatically rather than repeating the same instructions in every conversation. Instead of manually writing .mdc files, you generate them from the library's actual documentation.
How it saves time or tokens
Manually writing a comprehensive .mdc rule file for a framework like FastAPI or Next.js takes hours of reading documentation and encoding conventions. This generator does it in minutes by crawling real documentation via Exa and distilling it into structured rules. The generated rules then save tokens in every future Cursor session by reducing the need to re-explain conventions.
How to use
- Clone the repository and install dependencies:
git clone https://github.com/sanjeed5/awesome-cursor-rules-mdc.git && cd awesome-cursor-rules-mdc && uv sync. - Add your API keys to a
.envfile (EXA_API_KEY plus your LLM provider key). - Generate rules for a library:
uv run src/generate_mdc_files.py --library react.
Example
# Generate rules for FastAPI
uv run src/generate_mdc_files.py --library fastapi
# Generate rules for a category
uv run src/generate_mdc_files.py --tag backend
# Batch generation with concurrency
uv run src/generate_mdc_files.py --workers 4 --rate-limit 10
# Test mode (preview without writing)
uv run src/generate_mdc_files.py --library react --test
Output is a .mdc file you drop into .cursor/rules/ in your project.
Related on TokRepo
- AI Tools for Coding -- explore coding assistants and rule systems for AI-powered development
- Prompt Library -- browse reusable prompts and configuration templates
Common pitfalls
- Exa API has rate limits; batch generation with high concurrency may hit throttling. Use the
--rate-limitflag to stay within bounds. - Generated rules reflect documentation at the time of generation; re-run the generator when libraries release major version updates.
- The quality of generated rules depends on the LLM used; Claude and GPT-4 produce more nuanced rules than smaller models.
Frequently Asked Questions
The generator works with Gemini, OpenAI, and Anthropic models. You configure your preferred provider and API key in the .env file. Each provider produces slightly different rule quality.
Yes. The generated .mdc files are plain text that you can edit after generation. Many teams generate a baseline and then add project-specific conventions manually.
Yes. The generator uses Exa for semantic search of library documentation. You need an EXA_API_KEY along with your chosen LLM provider key.
cursor.directory provides manually curated rules for popular frameworks. This generator creates rules for any library, including niche or internal ones, by crawling their actual documentation.
The .mdc format is Cursor-specific, but the content can be adapted into CLAUDE.md files for Claude Code or .github/copilot-instructions.md for GitHub Copilot with minor formatting changes.
Citations (3)
- awesome-cursor-rules-mdc GitHub— Cursor Rules MDC Generator with Exa semantic search
- Exa Documentation— Exa semantic search API for web content
- Cursor Docs— Cursor AI rule files documentation
Related on TokRepo
Source & Thanks
Created by sanjeed5. Licensed under CC0 (Public Domain). awesome-cursor-rules-mdc — ⭐ 3,400+
Thanks to sanjeed5 for building a generator rather than just a collection — create Cursor rules for any library on demand.
Discussion
Related Assets
HumHub — Open-Source Enterprise Social Network
A flexible, open-source social networking platform built on Yii2 for creating private communities, intranets, and collaboration spaces within organizations.
Dolibarr — Open-Source ERP & CRM for Business Management
A modular open-source ERP and CRM application written in PHP for managing contacts, invoices, orders, inventory, accounting, and more from a single web interface.
PrestaShop — Open-Source PHP E-Commerce Platform
A widely adopted open-source e-commerce platform written in PHP with a rich module marketplace, multi-language support, and a strong European user base.