Skip to main content

A CLI tool that generates comprehensive AI coding agent rules for Cursor and Claude Code

Project description

AI Rules Generator

A CLI tool that generates comprehensive AI coding agent rules for Cursor and Claude Code based on your project configuration and best practices.

Features

  • Interactive Setup: Configure once, use everywhere - no shell config editing needed!
  • Multi-Tool Support: Generates rule files for 6 AI coding tools (Cursor, Claude Code, Windsurf, GitHub Copilot, Warp, Janie)
  • Shared AI Rules: Creates .ai-rules/ directory - single source of truth referenced by all tools
  • Multiple AI Providers: Support for OpenAI and Anthropic Claude models
  • Monorepo Support: Automatically detects and generates rules for each package
  • Language & Framework Specific: Tailored rules for 20+ languages and 100+ frameworks
  • Template Fallback: Works even without AI API keys using template-based generation

Quick Start

1. Install

Choose your preferred package manager:

macOS (Homebrew):

brew tap rpupo63/ai-rules-generator
brew install ai-rules-generator

Arch Linux (AUR):

yay -S ai-rules-generator

Debian/Ubuntu (APT):

sudo apt install ai-rules-generator

Linux (Flatpak):

flatpak install flathub com.github.ai_rules_generator.AIRulesGenerator

Windows (Chocolatey):

choco install ai-rules-generator

Windows (WinGet): Coming in v1.0.1 - Use Chocolatey for now

Any Platform (pip):

pip install ai-rules-generator

2. Configure (One-Time Setup)

Run the interactive setup:

ai-rules-generator init

This will:

  • Let you choose your AI provider (OpenAI, Anthropic, or None)
  • Let you select a model
  • Store your API keys securely in the config file
  • Let you choose which AI coding tools you use

No need to modify .bashrc, .zshrc, or PowerShell profile! Everything is stored in:

  • Linux: ~/.config/ai-rules-generator/config.json
  • macOS: ~/Library/Application Support/ai-rules-generator/config.json
  • Windows: %APPDATA%\ai-rules-generator\config.json

3. Generate Rules for Your Project

Navigate to your project and run:

cd /path/to/your/project
ai-rules-generator project-init

Done! Your project now has AI rules configured for all your selected AI coding tools.

Installation Details

Homebrew (macOS/Linux)

# Add the tap (first time only)
brew tap rpupo63/ai-rules-generator

# Install
brew install ai-rules-generator

# Update
brew upgrade ai-rules-generator

AUR (Arch Linux)

# Using yay
yay -S ai-rules-generator

# Or using paru
paru -S ai-rules-generator

# Update
yay -Syu ai-rules-generator

APT (Debian/Ubuntu)

# Add PPA (first time only)
sudo add-apt-repository ppa:rpupo63/ai-rules-generator
sudo apt update

# Install
sudo apt install ai-rules-generator

# Update
sudo apt update && sudo apt upgrade ai-rules-generator

Or install from .deb file:

wget https://github.com/rpupo63/ai-rules-generator/releases/download/v1.0.0/ai-rules-generator_1.0.0-1_all.deb
sudo apt install ./ai-rules-generator_1.0.0-1_all.deb

Flatpak (Linux - Universal)

# Install from Flathub
flatpak install flathub com.github.ai_rules_generator.AIRulesGenerator

# Run
flatpak run com.github.ai_rules_generator.AIRulesGenerator

# Update
flatpak update com.github.ai_rules_generator.AIRulesGenerator

Chocolatey (Windows)

# Install
choco install ai-rules-generator

# Update
choco upgrade ai-rules-generator

winget (Windows)

# Install
winget install AIRulesGenerator.AIRulesGenerator

# Update
winget upgrade AIRulesGenerator.AIRulesGenerator

pip (All Platforms)

# Install from PyPI
pip install ai-rules-generator

# Install with AI provider support
pip install ai-rules-generator[all]        # Both OpenAI and Anthropic
pip install ai-rules-generator[openai]     # OpenAI only
pip install ai-rules-generator[anthropic]  # Anthropic only

# Update
pip install --upgrade ai-rules-generator

# Install from source (development)
git clone https://github.com/rpupo63/ai-rules-generator.git
cd ai-rules-generator
pip install -e .[all]

Usage

Available Commands

# Global configuration (one-time setup)
ai-rules-generator init              # Interactive setup
ai-rules-generator config show       # View current configuration
ai-rules-generator config edit       # Edit configuration
ai-rules-generator config reset      # Reset to defaults

# Project-level commands
ai-rules-generator project-init      # Initialize rules for current project

Or use the shorter alias:

ai-rules init
ai-rules project-init

Configuration Management

The init command provides an interactive setup. You can also manage configuration manually:

# Set AI provider
ai-rules-generator config set provider openai

# Set AI model
ai-rules-generator config set model gpt-4o

# Set API keys
ai-rules-generator config set openai-key sk-...
ai-rules-generator config set anthropic-key sk-ant-...

# Set enabled tools (comma-separated)
ai-rules-generator config set enabled-tools cursor,claude-code,windsurf

What Gets Generated

After running project-init, your project will have:

Shared Rules (always created):

  • .ai-rules/ - Directory with organized rule files
    • project-rules.md - Main project rules
    • language-*.md - Language-specific best practices
    • framework-*.md - Framework-specific rules
    • universal-*.md - Universal best practices
    • README.md - Index of all rule files

Tool-Specific Files (based on your selection):

  • Cursor: .cursorrules + .cursor/rules/*.mdc
  • Claude Code: CLAUDE.md + .claude/rules/
  • Windsurf: .windsurfrules
  • GitHub Copilot: .github/copilot-instructions.md
  • Warp: .warp/rules.md
  • Janie: .janie/rules.md

All tool files reference the shared .ai-rules/ directory, keeping rules DRY and maintainable.

Supported AI Coding Tools

The tool supports 6 AI coding tools. During init, select which tools you use:

  1. Cursor - .cursorrules + .cursor/rules/*.mdc files
  2. Claude Code - CLAUDE.md + .claude/rules/ directory
  3. Windsurf - .windsurfrules file
  4. GitHub Copilot - .github/copilot-instructions.md
  5. Warp - .warp/rules.md file
  6. Janie - .janie/rules.md file

To change which tools are enabled:

ai-rules-generator config edit

Supported Languages

Python, TypeScript, JavaScript, Rust, C++, Java, Go, Kotlin, Swift, Elixir, PHP, Ruby, Scala, R, Solidity, HTML, CSS, and more.

Supported Frameworks

100+ frameworks including:

  • Python: FastAPI, Django, Flask, Temporal
  • TypeScript/JavaScript: Next.js, React, Vue, Svelte, Angular, Astro, Node.js
  • And many more...

During interactive mode, you'll see framework options specific to your selected language.

AI Providers

OpenAI

  • gpt-4o (recommended)
  • gpt-4o-mini (faster, cheaper)
  • gpt-4-turbo
  • gpt-4
  • gpt-3.5-turbo

Anthropic Claude

  • claude-3-5-sonnet-20241022 (recommended)
  • claude-3-5-haiku-20241022 (faster)
  • claude-3-opus-20240229
  • claude-3-sonnet-20240229
  • claude-3-haiku-20240307

None (Template-based)

Use template-based generation without AI API calls.

API Key Management

API keys are stored securely in the config file. No need to manually edit environment variables!

Storing API Keys

Option 1: Interactive setup (recommended)

ai-rules-generator init
# Enter API keys when prompted

Option 2: Command line

ai-rules-generator config set openai-key sk-...
ai-rules-generator config set anthropic-key sk-ant-...

Option 3: Environment variables (optional)

export OPENAI_API_KEY='sk-...'
export ANTHROPIC_API_KEY='sk-ant-...'

Environment variables take precedence if set, but the config file is more convenient.

Security Note

  • Config file is stored with user-only read/write permissions
  • API keys are stored as plain text in the config file
  • Both config file and environment variables have similar security profiles
  • Use --show-keys flag cautiously when displaying configuration

Examples

Single Project Setup

# One-time global setup
ai-rules-generator init

# In your project
cd my-fastapi-project
ai-rules-generator project-init

Monorepo Setup

# One-time global setup
ai-rules-generator init

# In your monorepo root
cd my-monorepo
ai-rules-generator project-init
# Automatically detects packages and creates rules for each

Template-based (No API Key)

# Configure to use template mode
ai-rules-generator init
# Select: none -> template

# Generate rules without AI
cd my-project
ai-rules-generator project-init

Configuration File

Your configuration is stored in a platform-appropriate location:

Linux:

~/.config/ai-rules-generator/config.json

macOS:

~/Library/Application Support/ai-rules-generator/config.json

Windows:

%APPDATA%\ai-rules-generator\config.json

Example config:

{
  "ai_provider": "openai",
  "ai_model": "gpt-4o-mini",
  "openai_api_key": "sk-...",
  "anthropic_api_key": null,
  "enabled_tools": ["cursor", "claude-code", "windsurf"]
}

Troubleshooting

Command not found after installation

Make sure your PATH includes the installation directory:

  • pip: ~/.local/bin (Linux/macOS) or %APPDATA%\Python\Scripts (Windows)
  • Homebrew: /usr/local/bin (Intel) or /opt/homebrew/bin (Apple Silicon)

Config file location

View your config path:

python -c "from ai_rules_generator.config_manager import get_config_path; print(get_config_path())"

Reset configuration

ai-rules-generator config reset
ai-rules-generator init

Contributing

Contributions welcome! Please read DEVELOPMENT.md for development setup and publishing instructions.

License

MIT

Credits

Built using best practices from awesome-cursorrules.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_rules_generator-1.0.0.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_rules_generator-1.0.0-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file ai_rules_generator-1.0.0.tar.gz.

File metadata

  • Download URL: ai_rules_generator-1.0.0.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ai_rules_generator-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e198e948c0bab5048a78904463e07e8fe891f761e4fe8a762d9194fd226c9898
MD5 a2faf1321f61841ed4730a271bd36387
BLAKE2b-256 c0c8bf3dfe5c8356e04affc5fdef3f03c433f8b1ee63626b9456c23fa126f5ed

See more details on using hashes here.

File details

Details for the file ai_rules_generator-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_rules_generator-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 940165f783c2ba9bc72b4bf4d8cf698ba3fd153bcdb7137799bfc582fb78f55a
MD5 6a2c3b66831182824e96269a1b9911b5
BLAKE2b-256 74520b3390d4dfb1f77dd5a2e17b3573fa970addc335157771b9002a64149fe2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page