- GitHub: intellectronica/ruler
- NPM: @intellectronica/ruler
Beta Research Preview
- Please test this version carefully in your environment
- Report issues at https://github.com/intellectronica/ruler/issues
Managing instructions across multiple AI coding tools becomes complex as your team grows. Different agents (GitHub Copilot, Claude, Cursor, Aider, etc.) require their own configuration files, leading to:
- Inconsistent guidance across AI tools
- Duplicated effort maintaining multiple config files
- Context drift as project requirements evolve
- Onboarding friction for new AI tools
Ruler solves this by providing a single source of truth for all your AI agent instructions, automatically distributing them to the right configuration files.
- Centralised Rule Management: Store all AI instructions in a dedicated .ruler/ directory using Markdown files
- Automatic Distribution: Ruler applies these rules to configuration files of supported AI agents
- Targeted Agent Configuration: Fine-tune which agents are affected and their specific output paths via ruler.toml
- MCP Server Propagation: Manage and distribute Model Context Protocol (MCP) server settings
- .gitignore Automation: Keeps generated agent config files out of version control automatically
- Simple CLI: Easy-to-use commands for initialising and applying configurations
GitHub Copilot | .github/copilot-instructions.md |
Claude Code | CLAUDE.md |
OpenAI Codex CLI | AGENTS.md |
Cursor | .cursor/rules/ruler_cursor_instructions.mdc |
Windsurf | .windsurf/rules/ruler_windsurf_instructions.md |
Cline | .clinerules |
Aider | ruler_aider_instructions.md and .aider.conf.yml |
Firebase Studio | .idx/airules.md |
Open Hands | .openhands/microagents/repo.md and .openhands/config.toml |
Gemini CLI | GEMINI.md and .gemini/settings.json |
Node.js 18.x or higher is required.
Global Installation (Recommended for CLI use):
Using npx (for one-off commands):
- Navigate to your project's root directory
- Run ruler init
- This creates:
- .ruler/ directory
- .ruler/instructions.md: A starter Markdown file for your rules
- .ruler/ruler.toml: The main configuration file for Ruler
- .ruler/mcp.json: An example MCP server configuration
This is your central hub for all AI agent instructions:
- Rule Files (*.md): Discovered recursively from .ruler/ and alphabetically concatenated
- Concatenation Marker: Each file's content is prepended with --- Source: <relative_path_to_md_file> --- for traceability
- ruler.toml: Master configuration for Ruler's behavior, agent selection, and output paths
- mcp.json: Shared MCP server settings
Granularity: Break down complex instructions into focused .md files:
- coding_style.md
- api_conventions.md
- project_architecture.md
- security_guidelines.md
Example rule file (.ruler/python_guidelines.md):
--project-root <path> | Path to your project's root (default: current directory) |
--agents <agent1,agent2,...> | Comma-separated list of agent names to target |
--config <path> | Path to a custom ruler.toml configuration file |
--mcp / --with-mcp | Enable applying MCP server configurations (default: true) |
--no-mcp | Disable applying MCP server configurations |
--mcp-overwrite | Overwrite native MCP config entirely instead of merging |
--gitignore | Enable automatic .gitignore updates (default: true) |
--no-gitignore | Disable automatic .gitignore updates |
--verbose / -v | Display detailed output during execution |
Apply rules to all configured agents:
Apply rules only to GitHub Copilot and Claude:
Apply rules only to Firebase Studio:
Use a specific configuration file:
Apply rules with verbose output:
Apply rules but skip MCP and .gitignore updates:
Defaults to .ruler/ruler.toml in the project root. Override with --config CLI option.
- CLI flags (e.g., --agents, --no-mcp, --mcp-overwrite, --no-gitignore)
- Settings in ruler.toml (default_agents, specific agent settings, global sections)
- Ruler's built-in defaults (all agents enabled, standard output paths, MCP enabled with 'merge')
MCP provides broader context to AI models through server configurations. Ruler can manage and distribute these settings across compatible agents.
Define your project's MCP servers:
Ruler uses this file with the merge (default) or overwrite strategy, controlled by ruler.toml or CLI flags.
Ruler automatically manages your .gitignore file to keep generated agent configuration files out of version control.
- Creates or updates .gitignore in your project root
- Adds paths to a managed block marked with # START Ruler Generated Files and # END Ruler Generated Files
- Preserves existing content outside this block
- Sorts paths alphabetically and uses relative POSIX-style paths
- CLI flags: --gitignore or --no-gitignore
- Configuration: [gitignore].enabled in ruler.toml
- Default: enabled
- Create .ruler/coding_standards.md, .ruler/api_usage.md
- Commit the .ruler directory to your repository
- Team members pull changes and run ruler apply to update their local AI agent configurations
- Detail your project's architecture in .ruler/project_overview.md
- Describe primary data structures in .ruler/data_models.md
- Run ruler apply to help AI tools provide more relevant suggestions
"Cannot find module" errors:
- Ensure Ruler is installed globally: npm install -g @intellectronica/ruler
- Or use npx @intellectronica/ruler
Permission denied errors:
- On Unix systems, you may need sudo for global installation
Agent files not updating:
- Check if the agent is enabled in ruler.toml
- Verify agent isn't excluded by --agents flag
- Use --verbose to see detailed execution logs
Configuration validation errors:
- Ruler now validates ruler.toml format and will show specific error details
- Check that all configuration values match the expected types and formats
Use --verbose flag to see detailed execution logs:
This shows:
- Configuration loading details
- Agent selection logic
- File processing information
- MCP configuration steps
Q: Can I use different rules for different agents? A: Currently, all agents receive the same concatenated rules. For agent-specific instructions, include sections in your rule files like "## GitHub Copilot Specific" or "## Aider Configuration".
Q: How do I temporarily disable Ruler for an agent? A: Set enabled = false in ruler.toml under [agents.agentname], or use --agents flag to specify only the agents you want.
Q: What happens to my existing agent configuration files? A: Ruler creates backups with .bak extension before overwriting any existing files.
Q: Can I run Ruler in CI/CD pipelines? A: Yes! Use ruler apply --no-gitignore in CI to avoid modifying .gitignore. See the GitHub Actions example above.
Q: How do I migrate from version 0.1.x to 0.2.0? A: Version 0.2.0 is backward compatible. Your existing .ruler/ directory and ruler.toml will continue to work. New features like verbose logging and improved error messages are opt-in.
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
For bugs and feature requests, please open an issue.
MIT
© Eleanor Berger
ai.intellectronica.net