Stop writing Cursor rules by hand.
Feed your codebase to Gemini. Get rules based on patterns it finds in your code, not generic templates from a package.json scan.
export GEMINI_API_KEY=your-key-here
npx rulegen-aiGet a free API key at aistudio.google.com/apikey.
$ npx rulegen-ai ./my-express-api
Scanning ./my-express-api...
Found 47 files · Selected 32 for analysis · ~89,200 tokens
Generating rules with gemini-2.5-flash-lite...
Written 7 files:
✓ .cursor/rules/zod-validation-before-handlers.mdc
✓ .cursor/rules/prisma-singleton-import.mdc
✓ .cursor/rules/consistent-error-response-shape.mdc
✓ .cursor/rules/route-file-structure.mdc
✓ .cursor/rules/barrel-exports-from-src.mdc
✓ .cursor/rules/test-naming-convention.mdc
✓ .cursor/rules/middleware-ordering.mdc
Not "use TypeScript" or "write clean code". Rules like:
- "Import prisma from
../db— never instantiate PrismaClient directly" - "Route files validate with Zod schemas before handlers, return
{ data }or{ error }shapes" - "Tests live in
__tests__/and mirror thesrc/directory structure"
| Format | Flag | Output |
|---|---|---|
| Cursor | --format cursor (default) |
.cursor/rules/*.mdc |
| Claude Code | --format claude-md |
CLAUDE.md |
| AGENTS.md | --format agents-md |
AGENTS.md |
| GitHub Copilot | --format copilot |
.github/copilot-instructions.md |
| Windsurf | --format windsurf |
.windsurfrules |
- Scans your project tree (respects
.gitignore, skips binaries) - Detects your stack — Node.js, Python frameworks (Django, Flask, FastAPI), testing tools, linters, type checkers
- Prioritizes config files, entry points, routes, and pattern-rich files to fit Gemini's context window
- Sends everything in one request — Gemini's 1M token context sees your whole codebase at once. No chunking, no lost context.
- Writes valid rule files in your chosen format
rule-gen auto-detects:
Python
- Frameworks: Django, Flask, FastAPI, Tornado, Sanic, and 10+ more
- Testing: pytest, unittest, nose, tox, coverage
- Type checking: mypy, pyright, pyre, pytype
- Linting: ruff, flake8, pylint, black, isort, bandit
- Package managers: Poetry, Pipenv, pip, setuptools
Node.js/TypeScript
- Detects from
package.jsondependencies - Identifies module type (ESM/CommonJS)
This context helps Gemini generate rules specific to your stack — e.g., Django best practices for Django projects, FastAPI patterns for FastAPI apps.
--format <format> cursor, claude-md, agents-md, copilot, windsurf
--model <model> Gemini model (default: gemini-2.5-flash-lite)
--dry-run Preview without writing files
--verbose Show which files are sent
--max-files <n> Max source files (default: 50)
--api-key <key> Or set GEMINI_API_KEY env var
Zero dependencies. Built with Node.js builtins only.
rule-gen creates rules. cursor-doctor makes sure they actually work.
npx cursor-doctor scan # Health check with letter grade
npx cursor-doctor lint # Detailed rule-by-rule linting100+ checks for broken globs, vague instructions, conflicts, and token waste. Also: rule-porter converts rules between Cursor, Claude, Copilot, and Windsurf.
MIT