ConfigsMar 28, 2026·2 min read

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.

TL;DR
Generate Cursor .mdc rule files for any library automatically using Exa semantic search and LLM extraction.
§01

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.

§02

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.

§03

How to use

  1. Clone the repository and install dependencies: git clone https://github.com/sanjeed5/awesome-cursor-rules-mdc.git && cd awesome-cursor-rules-mdc && uv sync.
  2. Add your API keys to a .env file (EXA_API_KEY plus your LLM provider key).
  3. Generate rules for a library: uv run src/generate_mdc_files.py --library react.
§04

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.

§05

Related on TokRepo

§06

Common pitfalls

  • Exa API has rate limits; batch generation with high concurrency may hit throttling. Use the --rate-limit flag 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

What LLM providers does the generator support?+

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.

Can I customize the generated rules?+

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.

Do I need an Exa API key?+

Yes. The generator uses Exa for semantic search of library documentation. You need an EXA_API_KEY along with your chosen LLM provider key.

How are these rules different from cursor.directory rules?+

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.

Can I use the generated rules with other AI coding tools?+

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)
🙏

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

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets