rulegen
v0.3.0
Published
One config to rule them all — generate AI coding rules for every agent.
Downloads
282
Maintainers
Readme
rulegen
One config to rule them all.
Generate AI coding rules for 16 agents — Claude, Cursor, Copilot, Windsurf, Gemini, Cline, and more — from a single config file.
The Problem
You use Claude Code and Cursor and Copilot.
Each needs its own config file. They drift out of sync.
You waste time maintaining CLAUDE.md, .cursorrules, and copilot-instructions.md separately.
The Solution
npx rulegen # That's it. Zero-arg mode does everything.One config → 16 agent files, always in sync.
Supported Agents
| Agent | Config File | Format |
|-------|-------------|--------|
| Claude Code | CLAUDE.md | Markdown |
| Cursor | .cursorrules | Markdown |
| GitHub Copilot | .github/copilot-instructions.md | Markdown |
| Windsurf | .windsurfrules | Markdown |
| Aider | .aider.conf.yml + CONVENTIONS.md | YAML + Markdown |
| Codex | codex.md | Markdown |
| Gemini CLI | GEMINI.md | Markdown |
| Cline | .clinerules/project.md | Markdown |
| OpenCode | .opencode/rules.md | Markdown |
| Roo Code | .roo/rules.md | Markdown |
| Junie | .junie/guidelines.md | Markdown |
| Continue.dev | .continue/rules.md | Markdown |
| Sourcegraph Cody | .vscode/cody.json | JSON |
| AGENTS.md | AGENTS.md | Markdown |
| Goose | .goose/config.yaml | YAML |
| Amp | .amp/rules.md | Markdown |
Features
- AI-Powered Rules —
rulegen aianalyzes your codebase and generates optimal rules automatically - Zero-Config Setup —
npx rulegenone command does everything - Smart Detection — Auto-scans your project for language, framework, dependencies
- 16 Agents — Every major AI coding tool supported
- Agent-Optimized — Each file uses the format best for that tool (Markdown, JSON, YAML)
- Import Existing —
rulegen importreads your existing agent files into a config - Stay in Sync — One source of truth. Change config, regenerate all files instantly
- Fully Customizable — Custom rules, per-agent overrides, do/don't instructions
Quick Start
# Zero-arg mode: auto-detect → generate
npx rulegen
# Or step by step:
npx rulegen init # Interactive project setup
npx rulegen generate # Generate all agent files
npx rulegen doctor # Verify everything is in syncImport existing config files
Already have .cursorrules or CLAUDE.md? Import them:
npx rulegen import # Auto-detect all agent files
npx rulegen import --from claude # Import from specific agent
npx rulegen import --from cursor,copilot # Multiple agentsAI-Powered Rule Generation
Why write rules manually when AI can analyze your codebase?
Setup
# Option 1: Environment variable
export ANTHROPIC_API_KEY=sk-ant-xxx
npx rulegen ai
# Option 2: Config command
npx rulegen config set provider claude
npx rulegen config set api-key sk-ant-xxx
npx rulegen ai
# Option 3: Use OpenAI or Gemini
OPENAI_API_KEY=sk-xxx npx rulegen ai --provider openai
GEMINI_API_KEY=xxx npx rulegen ai --provider geminiWhat it does
- Scans your codebase (language, framework, dependencies)
- Analyzes code patterns (style, naming, architecture)
- AI generates optimal rules tailored to YOUR project
- Creates config files for all 16 AI coding agents
One command, zero config
ANTHROPIC_API_KEY=xxx npx rulegen aiThat's it. AI analyzes your project and generates everything.
CLI Commands
| Command | Description |
|---------|-------------|
| rulegen | Zero-arg: init (if no config) or generate (if config exists) |
| rulegen init | Interactive project setup and config generation |
| rulegen generate | Generate agent config files from config |
| rulegen import | Import existing agent files into rulegen.config.json |
| rulegen ai | AI-powered rule generation from codebase analysis |
| rulegen config | Manage global config (API keys, provider) |
| rulegen sync | Sync files (use --watch for auto-sync) |
| rulegen doctor | Validate config and check file status |
Common options
rulegen generate --target claude,cursor # Specific agents only
rulegen generate --dry-run # Preview without writing
rulegen generate --force # Overwrite without asking
rulegen generate --diff # Show changes
rulegen generate --output ./out/ # Custom output directory
rulegen ai --provider openai # Use specific AI provider
rulegen ai --dry-run # Generate config only
rulegen ai --explain # Show reasoning for each rule
rulegen sync --watch # Auto-regenerate on config changeConfiguration
{
"version": "1",
"project": {
"name": "my-app",
"description": "A modern web application",
"type": "web-app",
"language": "typescript",
"framework": "next.js",
"runtime": "node",
"packageManager": "pnpm"
},
"rules": {
"style": {
"indentation": "spaces",
"indentSize": 2,
"quotes": "single",
"semicolons": false,
"maxLineLength": 100,
"trailingComma": "all"
},
"naming": {
"files": "kebab-case",
"components": "PascalCase",
"functions": "camelCase",
"constants": "UPPER_SNAKE_CASE",
"types": "PascalCase"
},
"patterns": {
"server-components": "Use server components by default"
}
},
"structure": {
"src/app": "Next.js App Router pages",
"src/components": "Reusable React components",
"src/lib": "Utility functions and shared logic"
},
"instructions": {
"do": [
"Use TypeScript strict mode",
"Write unit tests for all functions"
],
"dont": [
"Use 'any' type",
"Use class components"
],
"guidelines": [
"Prefer composition over inheritance"
]
},
"targets": ["claude", "cursor", "copilot", "windsurf", "gemini", "cline"],
"overrides": {
"claude": {
"extraInstructions": ["Always run tests before committing"]
}
}
}Key sections
- project — Name, language, framework, runtime
- rules — Code style, naming conventions, patterns
- structure — Directory descriptions for AI context
- instructions — Do/Don't/Guidelines for AI behavior
- targets — Which agent files to generate
- overrides — Per-agent customizations
How It Works
┌─────────────────┐ ┌──────────┐ ┌───────────────┐
│ Your Project │────▶│ Scanner │────▶│ Config │
│ (auto-detect) │ │ │ │ .json file │
└─────────────────┘ └──────────┘ └───────┬───────┘
│
┌───────────────────────────────────┼───────────────────┐
▼ ▼ ▼ ▼ ▼ ▼ ▼
CLAUDE.md .cursorrules copilot GEMINI.md cody.json ... 16 agentsWhy rulegen?
- Zero-config:
npx rulegen— one command does everything - AI-powered:
rulegen aianalyzes your code and generates rules automatically - Import existing: Already have agent files? Import them, don't start over
- 16 agents: The most comprehensive agent support available
rulegen vs rulesync
| Feature | rulegen | rulesync |
|---------|---------|----------|
| AI-powered rule generation | Yes | No |
| Zero-config setup | Yes (npx rulegen) | No (manual .md files) |
| Agents supported | 16 | 21 |
| Import existing configs | Yes | Yes |
| One-command setup | Yes | No |
| API key required | Only for AI mode | N/A |
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT
