Package Exports
- @intellectronica/ruler
- @intellectronica/ruler/dist/lib.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@intellectronica/ruler) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Experimental Research Preview
- Please test this version with caution in your own setup
- File issues at https://github.com/intellectronica/ruler/issues
Ruler
A CLI tool to manage custom rules and configs across different AI coding agents.
Features
- Centralise AI agent instructions in a single
.ruler/directory - Distribute rules to supported agents (GitHub Copilot, Claude Code, OpenAI Codex CLI, Cursor, Windsurf, Cline, Aider)
- Extensible architecture: add new agent adapters easily
Installation
Install globally:
npm install -g @intellectronica/rulerOr use npx:
npx @intellectronica/ruler applyUsage
Create a .ruler/ directory at your project root and add Markdown files defining your rules:
.ruler/
├── coding_guidelines.md
└── style_guide.mdRun the apply command:
ruler apply [--project-root <path>] [--agents <agent1,agent2,...>] [--config <path>] [--gitignore] [--no-gitignore]Run the init command to scaffold a basic .ruler/ setup:
ruler init [--project-root <path>]Use --agents to specify a comma-separated list of agent names (case-insensitive substrings) to limit which agents the rules are applied to.
The command will read all .md files under .ruler/, concatenate their contents, and generate/update configuration files for the following agents:
| Agent | File(s) Created/Updated |
|---|---|
| GitHub Copilot | .github/copilot-instructions.md |
| Claude Code | CLAUDE.md |
| OpenAI Codex CLI | AGENTS.md |
| Cursor | .cursor/rules/ruler_cursor_instructions.md |
| Windsurf | .windsurf/rules/ruler_windsurf_instructions.md |
| Cline | .clinerules |
| Aider | ruler_aider_instructions.md and updates .aider.conf.yml |
Configuration
Ruler uses a TOML configuration file located at .ruler/ruler.toml by default. You can override its location with the --config <path> option in the apply command.
Configuration structure
# Run only these agents by default (omit to use all agents)
# default_agents = ["GitHub Copilot", "Claude Code", "Aider"]
[agents.Copilot]
enabled = true
output_path = ".github/copilot-instructions.md"
[agents.Claude]
enabled = true
# output_path = "CLAUDE.md"
[agents.Aider]
enabled = false
# output_path_instructions = "ruler_aider_instructions.md"
# output_path_config = ".aider.conf.yml"default_agents: array of agent names (case-insensitive substrings) to run by default.[agents.<AgentName>]: per-agent settings:enabled(boolean): enable or disable this agent.output_path(string): custom path for agents that produce a single file.output_path_instructions/output_path_config: custom paths for Aider's instruction and config files.
Precedence
- CLI
--agentsoption (substring filters) - Config file
default_agentsand[agents]overrides - Built-in defaults (all agents enabled, standard output paths)
MCP servers
Ruler can propagate a project-level .ruler/mcp.json file to native MCP configurations of supported agents, merging (or overwriting) each agent’s existing MCP server settings.
.ruler/mcp.json
Place your MCP servers config in a file at .ruler/mcp.json:
{
"mcpServers": {
"example": {
"url": "https://mcp.example.com"
}
}
}CLI flags
| Flag | Effect |
|---|---|
--with-mcp |
Enable writing MCP configs for all agents (default) |
--no-mcp |
Disable writing MCP configs |
--mcp-overwrite |
Overwrite native MCP configs instead of merging |
Configuration (ruler.toml)
Configure default behavior in your ruler.toml:
[mcp]
enabled = true
merge_strategy = "merge" # or "overwrite"
[agents.Cursor.mcp]
enabled = false
merge_strategy = "overwrite".gitignore Integration
Ruler automatically adds generated agent configuration files to your project's .gitignore file to prevent them from being committed to version control. This ensures that the AI agent configuration files remain local to each developer's environment.
Behavior
When ruler apply runs, it will:
- Create or update a
.gitignorefile in your project root - Add all generated file paths to a managed block marked with
# START Ruler Generated Filesand# END Ruler Generated Files - Preserve any existing
.gitignorecontent outside the managed block - Sort paths alphabetically within the Ruler block
- Use relative POSIX-style paths (forward slashes)
CLI flags
| Flag | Effect |
|---|---|
--gitignore |
Enable automatic .gitignore updates (default) |
--no-gitignore |
Disable automatic .gitignore updates |
Configuration (ruler.toml)
Configure the default behavior in your ruler.toml:
[gitignore]
enabled = true # or false to disable by defaultPrecedence
The configuration precedence for .gitignore updates is:
- CLI flags (
--gitignoreor--no-gitignore) - Configuration file
[gitignore].enabledsetting - Default behavior (enabled)
Example
After running ruler apply, your .gitignore might look like:
node_modules/
*.log
# START Ruler Generated Files
.aider.conf.yml
.clinerules
.cursor/rules/ruler_cursor_instructions.md
.github/copilot-instructions.md
.windsurf/rules/ruler_windsurf_instructions.md
AGENTS.md
CLAUDE.md
ruler_aider_instructions.md
# END Ruler Generated Files
dist/Development
Clone the repository and install dependencies:
git clone https://github.com/intellectronica/ruler.git
cd ruler
npm install
npm run buildRun linting and formatting checks:
npm run lint
npm run formatRun tests:
npm testEnd-to-end tests (run build before tests):
npm run build && npm testContributing
Contributions are welcome! Please open issues or pull requests on GitHub.
License
MIT
© Eleanor Berger