| name | ruler |
| description | Unified AI agent configuration propagation across 18+ coding assistants. |
| version | 1.0.0 |
ruler
Unified AI agent configuration propagation across 18+ coding assistants.
Repository: https://github.com/intellectronica/ruler
Documentation: https://deepwiki.com/intellectronica/ruler
Overview
Ruler centralizes AI agent instructions in .ruler/ and distributes them to all configured agents via ruler apply. Supports Model Context Protocol (MCP) propagation with merge/overwrite strategies.
.ruler/
├── *.md # Rules (concatenated alphabetically)
├── ruler.toml # Agent config + MCP settings
└── mcp.json # Shared MCP servers
Installation
npm install -g ruler
npx ruler init
Commands
ruler init
Creates .ruler/ directory with default files:
ruler init
ruler init --global
Creates:
instructions.md - Central AI instructions
ruler.toml - Configuration file
mcp.json - MCP server definitions
ruler apply
Propagates rules to all configured agents:
ruler apply
ruler apply --agents claude,codex
ruler apply --no-mcp
ruler apply --mcp-overwrite
ruler apply --no-gitignore
ruler revert
Restores files from backups:
ruler revert
ruler revert --keep-backups
Supported Agents (18)
| Agent | Identifier | Instructions Output | MCP Config |
|---|
| GitHub Copilot | copilot | .github/copilot-instructions.md | .vscode/mcp.json |
| Claude Code | claude | CLAUDE.md | .mcp.json |
| OpenAI Codex CLI | codex | AGENTS.md | .codex/config.toml |
| Jules | jules | AGENTS.md | - |
| Cursor | cursor | .cursor/rules/ruler_cursor_instructions.mdc | .cursor/mcp.json |
| Windsurf | windsurf | .windsurf/rules/ruler_windsurf_instructions.md | ~/.codeium/windsurf/mcp_config.json |
| Cline | cline | .clinerules | - |
| Amp | amp | AGENT.md | - |
| Aider | aider | ruler_aider_instructions.md + .aider.conf.yml | .mcp.json |
| Firebase Studio | firebase | .idx/airules.md | - |
| Open Hands | openhands | .openhands/microagents/repo.md | .openhands/config.toml |
| Gemini CLI | gemini-cli | GEMINI.md |
Configuration: ruler.toml
Complete configuration reference:
default_agents = ["copilot", "claude", "codex", "cursor", "amp"]
[mcp]
enabled = true
merge_strategy = "merge"
[gitignore]
enabled = true
[agents.copilot]
enabled = true
output_path = ".github/copilot-instructions.md"
[agents.claude]
enabled =
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
Configuration: mcp.json
Define shared MCP servers:
{
"mcpServers": {
"gay": {
"type": "stdio",
"command": "julia",
"args": ["--project=@gay", "-e", "using Gay; Gay.serve_mcp()"],
"env": {
"GAY_SEED": "1069"
}
},
"firecrawl": {
"type": "stdio",
"command": "npx",
"args": ["-y", "firecrawl-mcp"],
"env": {
"FIRECRAWL_API_KEY":
Architecture
IAgent Interface
All agents implement:
interface IAgent {
getIdentifier(): string;
getName(): string;
getDefaultOutputPath(): string | Record<string, string>;
getMcpServerKey?(): string;
applyRulerConfig(
concatenatedRules: string,
projectRoot: string,
rulerMcpJson: object,
agentConfig?: AgentConfig
): Promise<void>;
}
MCP Server Keys by Agent
| Agent | MCP Server Key |
|---|
| Copilot | servers |
| Claude | mcpServers |
| OpenCode | mcp |
| Others | mcpServers |
Orchestration Flow (src/lib.ts)
1. Load ruler.toml configuration
2. Find .ruler/ directory (local or global)
3. Concatenate all *.md files alphabetically
4. Load and validate mcp.json
5. For each selected agent:
a. Determine output paths (with overrides)
b. Backup existing files (.bak)
c. Call agent.applyRulerConfig()
d. If MCP enabled:
- Read native MCP config
- Merge with ruler mcp.json
- Write merged config
6. Update .gitignore with generated paths
MCP Merge Strategies
Merge (default)
Combines servers from both configs, incoming takes precedence:
{ "mcpServers": { "a": {...}, "b": {...} } }
{ "mcpServers": { "b": {...}, "c": {...} } }
{ "mcpServers": { "a": {...}, "b": {...from ruler}, "c": {...} } }
Overwrite
Replaces native config entirely:
{ "mcpServers": { "b": {...}, "c": {...} } }
Backup Strategy
- Before overwriting, create
file.bak
- On revert: restore from
.bak, then delete .bak
- With
--keep-backups: restore but keep .bak files
- Generated files (no backup) are simply deleted on revert
Special Agent Handling
OpenHands
- MCP config in
.openhands/config.toml
- Uses
stdio_servers key (TOML format)
AugmentCode
- MCP embedded in
.vscode/settings.json
- Custom propagation function
OpenCode
- MCP in
opencode.json
- Uses
mcp key instead of mcpServers
Cursor
- Adds YAML front-matter to rules
.mdc extension for instructions
Aider
- Two output files: instructions + config
- Config is
.aider.conf.yml
Configuration Precedence
CLI flags (highest)
↓
ruler.toml settings
↓
Built-in defaults (lowest)
Examples:
--no-gitignore overrides [gitignore] enabled = true
--agents claude overrides default_agents
- Agent-specific
[agents.X.mcp] overrides global [mcp]
Example Workflow
ruler init
cat > .ruler/01-style.md << 'EOF'
- Use TypeScript
- Prefer functional programming
- Maximum line length: 100
EOF
cat > .ruler/02-security.md << 'EOF'
- Never log secrets
- Use parameterized queries
- Validate all inputs
EOF
cat > .ruler/mcp.json << 'EOF'
{
"mcpServers": {
"gay": {
"command": "julia",
"args": ["--project=@gay", "-e", "using Gay; Gay.serve_mcp()"]
}
}
}
EOF
cat > .ruler/ruler.toml << 'EOF'
default_agents = ["claude", "codex", "amp"]
[mcp]
enabled = true
merge_strategy = "merge"
[agents.claude]
enabled = true
[agents.codex]
enabled = true
[agents.amp]
enabled = true
EOF
ruler apply
cat CLAUDE.md
cat AGENTS.md
cat AGENT.md
vim .ruler/01-style.md
ruler apply
ruler revert
Integration with Music-Topos
The .ruler/ directory in music-topos extends the standard ruler with:
GF(3) Bisimulation
[bisimulation]
enabled = true
polarity_rotation = true
[bisimulation.agents]
claude = "PLUS"
codex = "ERGODIC"
cursor = "MINUS"
propagate.clj (Babashka)
(def AGENTS
{:codex {:trit 0 :skills-path ".codex/skills"}
:claude {:trit -1 :skills-path ".claude/skills"}
:amp {:trit 0 :skills-path ".ruler/skills"}
:cursor {:trit -1 :skills-path ".cursor/skills"}
:copilot {:trit 1 :skills-path ".vscode/skills"}
:aider {:trit 1 :skills-path ".skillz"}})
;; Propagate with GF(3) conservation check
(propagate-all!)
References
Scientific Skill Interleaving
This skill connects to the K-Dense-AI/claude-scientific-skills ecosystem:
Graph Theory
- networkx [○] via bicomodule
Bibliography References
general: 734 citations in bib.duckdb
SDF Interleaving
This skill connects to Software Design for Flexibility (Hanson & Sussman, 2021):
Primary Chapter: 10. Adventure Game Example
Concepts: autonomous agent, game, synthesis
GF(3) Balanced Triad
ruler (+) + SDF.Ch10 (+) + [balancer] (+) = 0
Skill Trit: 1 (PLUS - generation)
Secondary Chapters
- Ch8: Degeneracy
- Ch1: Flexibility through Abstraction
- Ch2: Domain-Specific Languages
- Ch7: Propagators
Connection Pattern
Adventure games synthesize techniques. This skill integrates multiple patterns.
Cat# Integration
This skill maps to Cat# = Comod(P) as a bicomodule in the equipment structure:
Trit: 0 (ERGODIC)
Home: Prof
Poly Op: ⊗
Kan Role: Adj
Color: #26D826
GF(3) Naturality
The skill participates in triads satisfying:
(-1) + (0) + (+1) ≡ 0 (mod 3)
This ensures compositional coherence in the Cat# equipment structure.