skiller 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +989 -0
- package/dist/agents/AbstractAgent.js +92 -0
- package/dist/agents/AgentsMdAgent.js +85 -0
- package/dist/agents/AiderAgent.js +108 -0
- package/dist/agents/AmazonQCliAgent.js +103 -0
- package/dist/agents/AmpAgent.js +13 -0
- package/dist/agents/AugmentCodeAgent.js +70 -0
- package/dist/agents/ClaudeAgent.js +95 -0
- package/dist/agents/ClineAgent.js +53 -0
- package/dist/agents/CodexCliAgent.js +143 -0
- package/dist/agents/CopilotAgent.js +43 -0
- package/dist/agents/CrushAgent.js +128 -0
- package/dist/agents/CursorAgent.js +93 -0
- package/dist/agents/FirebaseAgent.js +61 -0
- package/dist/agents/FirebenderAgent.js +205 -0
- package/dist/agents/GeminiCliAgent.js +99 -0
- package/dist/agents/GooseAgent.js +58 -0
- package/dist/agents/IAgent.js +2 -0
- package/dist/agents/JulesAgent.js +14 -0
- package/dist/agents/JunieAgent.js +53 -0
- package/dist/agents/KiloCodeAgent.js +63 -0
- package/dist/agents/KiroAgent.js +50 -0
- package/dist/agents/OpenCodeAgent.js +99 -0
- package/dist/agents/OpenHandsAgent.js +56 -0
- package/dist/agents/QwenCodeAgent.js +82 -0
- package/dist/agents/RooCodeAgent.js +139 -0
- package/dist/agents/TraeAgent.js +54 -0
- package/dist/agents/WarpAgent.js +61 -0
- package/dist/agents/WindsurfAgent.js +27 -0
- package/dist/agents/ZedAgent.js +132 -0
- package/dist/agents/agent-utils.js +37 -0
- package/dist/agents/index.js +77 -0
- package/dist/cli/commands.js +136 -0
- package/dist/cli/handlers.js +221 -0
- package/dist/cli/index.js +5 -0
- package/dist/constants.js +58 -0
- package/dist/core/ConfigLoader.js +274 -0
- package/dist/core/FileSystemUtils.js +421 -0
- package/dist/core/FrontmatterParser.js +142 -0
- package/dist/core/GitignoreUtils.js +171 -0
- package/dist/core/RuleProcessor.js +60 -0
- package/dist/core/SkillsProcessor.js +528 -0
- package/dist/core/SkillsUtils.js +230 -0
- package/dist/core/UnifiedConfigLoader.js +432 -0
- package/dist/core/UnifiedConfigTypes.js +2 -0
- package/dist/core/agent-selection.js +52 -0
- package/dist/core/apply-engine.js +668 -0
- package/dist/core/config-utils.js +30 -0
- package/dist/core/hash.js +24 -0
- package/dist/core/revert-engine.js +413 -0
- package/dist/lib.js +196 -0
- package/dist/mcp/capabilities.js +65 -0
- package/dist/mcp/merge.js +39 -0
- package/dist/mcp/propagateOpenCodeMcp.js +116 -0
- package/dist/mcp/propagateOpenHandsMcp.js +169 -0
- package/dist/mcp/validate.js +17 -0
- package/dist/paths/mcp.js +120 -0
- package/dist/revert.js +186 -0
- package/dist/types.js +2 -0
- package/dist/vscode/settings.js +117 -0
- package/package.json +77 -0
package/README.md
ADDED
|
@@ -0,0 +1,989 @@
|
|
|
1
|
+
# `@udecode/ruler` fork
|
|
2
|
+
|
|
3
|
+
**Fork features:**
|
|
4
|
+
|
|
5
|
+
## 1. CLAUDE.md @filename References
|
|
6
|
+
|
|
7
|
+
- Uses `@filename` syntax instead of merging content
|
|
8
|
+
- Claude Code auto-includes referenced files
|
|
9
|
+
- Reduces CLAUDE.md size and keeps sources separate
|
|
10
|
+
- Other agents still get merged content
|
|
11
|
+
|
|
12
|
+
## 2. MDC File Support
|
|
13
|
+
|
|
14
|
+
- Supports both `.md` and `.mdc` files (Nuxt Content, Vue)
|
|
15
|
+
- All patterns auto-expand: `"components"` → `"components/**/*.{md,mdc}"`
|
|
16
|
+
|
|
17
|
+
## 3. Rules Filtering
|
|
18
|
+
|
|
19
|
+
- `include`/`exclude` glob patterns in `[rules]`
|
|
20
|
+
- Directory names auto-expand to `directory/**/*.{md,mdc}`
|
|
21
|
+
- Organize by team/feature, exclude drafts/internal docs
|
|
22
|
+
|
|
23
|
+
## 4. Claude Root Folder
|
|
24
|
+
|
|
25
|
+
- `ruler init --claude` creates `.claude/` instead of `.ruler/`
|
|
26
|
+
- Skills already in `.claude/skills` (no copying)
|
|
27
|
+
- Single directory for all Claude Code config
|
|
28
|
+
|
|
29
|
+
## 5. Cursor-style Rules
|
|
30
|
+
|
|
31
|
+
- `merge_strategy = "cursor"` parses `.mdc` frontmatter
|
|
32
|
+
- Only includes rules with `alwaysApply: true`
|
|
33
|
+
- Strips frontmatter, keeps body only
|
|
34
|
+
|
|
35
|
+
## 6. Backup Control
|
|
36
|
+
|
|
37
|
+
- `[backup].enabled = false` disables `.bak` files
|
|
38
|
+
|
|
39
|
+
## 7. Auto-Generate Skills from Rules
|
|
40
|
+
|
|
41
|
+
- `[skills].generate_from_rules = true` creates skills from .mdc files
|
|
42
|
+
- Only generates from files with `alwaysApply: false` (or undefined)
|
|
43
|
+
- Files with `alwaysApply: true` are merged into AGENTS.md instead
|
|
44
|
+
- Automatically removes skills when `alwaysApply` changes to `true`
|
|
45
|
+
- Skills use @filename references to original .mdc (for Claude Code)
|
|
46
|
+
- MCP agents (excluding Cursor) get full content in .skillz (frontmatter stripped)
|
|
47
|
+
- Cursor uses .cursor/rules directly (no skillz MCP needed)
|
|
48
|
+
- Globs appended to description: "Applies to files matching: ..."
|
|
49
|
+
- **Folder support**: `rules/docx/docx.mdc` + `rules/docx/script.sh` → `skills/docx/SKILL.md` + `skills/docx/script.sh`
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
# Ruler: Centralise Your AI Coding Assistant Instructions
|
|
54
|
+
|
|
55
|
+
> **Beta Research Preview**
|
|
56
|
+
>
|
|
57
|
+
> - Please test this version carefully in your environment
|
|
58
|
+
> - Report issues at https://github.com/udecode/ruler/issues
|
|
59
|
+
|
|
60
|
+
## Why Ruler?
|
|
61
|
+
|
|
62
|
+
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:
|
|
63
|
+
|
|
64
|
+
- **Inconsistent guidance** across AI tools
|
|
65
|
+
- **Duplicated effort** maintaining multiple config files
|
|
66
|
+
- **Context drift** as project requirements evolve
|
|
67
|
+
- **Onboarding friction** for new AI tools
|
|
68
|
+
- **Complex project structures** requiring context-specific instructions for different components
|
|
69
|
+
|
|
70
|
+
Ruler solves this by providing a **single source of truth** for all your AI agent instructions, automatically distributing them to the right configuration files. With support for **nested rule loading**, Ruler can handle complex project structures with context-specific instructions for different components.
|
|
71
|
+
|
|
72
|
+
## Core Features
|
|
73
|
+
|
|
74
|
+
- **Centralised Rule Management**: Store all AI instructions in a dedicated `.ruler/` directory using Markdown files
|
|
75
|
+
- **Nested Rule Loading**: Support complex project structures with multiple `.ruler/` directories for context-specific instructions
|
|
76
|
+
- **Automatic Distribution**: Ruler applies these rules to configuration files of supported AI agents
|
|
77
|
+
- **Targeted Agent Configuration**: Fine-tune which agents are affected and their specific output paths via `ruler.toml`
|
|
78
|
+
- **MCP Server Propagation**: Manage and distribute Model Context Protocol (MCP) server settings
|
|
79
|
+
- **`.gitignore` Automation**: Keeps generated agent config files out of version control automatically
|
|
80
|
+
- **Simple CLI**: Easy-to-use commands for initialising and applying configurations
|
|
81
|
+
|
|
82
|
+
## Supported AI Agents
|
|
83
|
+
|
|
84
|
+
| Agent | Rules File(s) | MCP Configuration / Notes |
|
|
85
|
+
| ---------------- | ------------------------------------------------ | ------------------------------------------------ |
|
|
86
|
+
| AGENTS.md | `AGENTS.md` | (pseudo-agent ensuring root `AGENTS.md` exists) |
|
|
87
|
+
| GitHub Copilot | `AGENTS.md` | `.vscode/mcp.json` |
|
|
88
|
+
| Claude Code | `CLAUDE.md` (@filename references) | `.mcp.json` |
|
|
89
|
+
| OpenAI Codex CLI | `AGENTS.md` | `.codex/config.toml` (MCP via Skillz) |
|
|
90
|
+
| Jules | `AGENTS.md` | - |
|
|
91
|
+
| Cursor | `AGENTS.md` | `.cursor/mcp.json` |
|
|
92
|
+
| Windsurf | `AGENTS.md` | `.windsurf/mcp_config.json` |
|
|
93
|
+
| Cline | `.clinerules` | - |
|
|
94
|
+
| Crush | `CRUSH.md` | `.crush.json` |
|
|
95
|
+
| Amp | `AGENTS.md` | - |
|
|
96
|
+
| Amazon Q CLI | `.amazonq/rules/ruler_q_rules.md` | `.amazonq/mcp.json` |
|
|
97
|
+
| Aider | `AGENTS.md`, `.aider.conf.yml` | `.mcp.json` |
|
|
98
|
+
| Firebase Studio | `.idx/airules.md` | `.idx/mcp.json` |
|
|
99
|
+
| Open Hands | `.openhands/microagents/repo.md` | `config.toml` |
|
|
100
|
+
| Gemini CLI | `AGENTS.md` | `.gemini/settings.json` |
|
|
101
|
+
| Junie | `.junie/guidelines.md` | - |
|
|
102
|
+
| AugmentCode | `.augment/rules/ruler_augment_instructions.md` | - |
|
|
103
|
+
| Kilo Code | `.kilocode/rules/ruler_kilocode_instructions.md` | `.kilocode/mcp.json` |
|
|
104
|
+
| OpenCode | `AGENTS.md` | `opencode.json` |
|
|
105
|
+
| Goose | `.goosehints` | - |
|
|
106
|
+
| Qwen Code | `AGENTS.md` | `.qwen/settings.json` |
|
|
107
|
+
| RooCode | `AGENTS.md` | `.roo/mcp.json` |
|
|
108
|
+
| Zed | `AGENTS.md` | `.zed/settings.json` (project root, never $HOME) |
|
|
109
|
+
| Trae AI | `.trae/rules/project_rules.md` | - |
|
|
110
|
+
| Warp | `WARP.md` | - |
|
|
111
|
+
| Kiro | `.kiro/steering/ruler_kiro_instructions.md` | - |
|
|
112
|
+
| Firebender | `firebender.json` | `firebender.json` (rules and MCP in same file) |
|
|
113
|
+
|
|
114
|
+
## Getting Started
|
|
115
|
+
|
|
116
|
+
### Installation
|
|
117
|
+
|
|
118
|
+
**Global Installation (Recommended for CLI use):**
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
npm install -g @udecode/ruler
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Using `npx` (for one-off commands):**
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npx @udecode/ruler apply
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Project Initialisation
|
|
131
|
+
|
|
132
|
+
1. Navigate to your project's root directory
|
|
133
|
+
2. Run `ruler init`
|
|
134
|
+
3. This creates:
|
|
135
|
+
|
|
136
|
+
- `.ruler/` directory
|
|
137
|
+
- `.ruler/AGENTS.md`: The primary starter Markdown file for your rules
|
|
138
|
+
- `.ruler/ruler.toml`: The main configuration file for Ruler
|
|
139
|
+
|
|
140
|
+
Additionally, you can create a global configuration to use when no local `.ruler/` directory is found:
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
ruler init --global
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
The global configuration will be created to `$XDG_CONFIG_HOME/ruler` (default: `~/.config/ruler`).
|
|
147
|
+
|
|
148
|
+
## Core Concepts
|
|
149
|
+
|
|
150
|
+
### The `.ruler/` Directory
|
|
151
|
+
|
|
152
|
+
This is your central hub for all AI agent instructions:
|
|
153
|
+
|
|
154
|
+
- **Primary File Order & Precedence**:
|
|
155
|
+
1. A repository root `AGENTS.md` (outside `.ruler/`) if present (highest precedence, prepended)
|
|
156
|
+
2. `.ruler/AGENTS.md` (new default starter file)
|
|
157
|
+
3. Remaining discovered `.md` files under `.ruler/` (and subdirectories) in sorted order
|
|
158
|
+
- **Rule Files (`*.md`)**: Discovered recursively from `.ruler/` or `$XDG_CONFIG_HOME/ruler` and concatenated in the order above
|
|
159
|
+
- **Concatenation Marker**: Each file's content is prepended with `--- Source: <relative_path_to_md_file> ---` for traceability
|
|
160
|
+
- **`ruler.toml`**: Master configuration for Ruler's behavior, agent selection, and output paths
|
|
161
|
+
- **`mcp.json`**: Shared MCP server settings
|
|
162
|
+
|
|
163
|
+
This ordering lets you keep a short, high-impact root `AGENTS.md` (e.g. executive project summary) while housing detailed guidance inside `.ruler/`.
|
|
164
|
+
|
|
165
|
+
### Nested Rule Loading
|
|
166
|
+
|
|
167
|
+
Ruler now supports **nested rule loading** with the `--nested` flag, enabling context-specific instructions for different parts of your project:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
project/
|
|
171
|
+
├── .ruler/ # Global project rules
|
|
172
|
+
│ ├── AGENTS.md
|
|
173
|
+
│ └── coding_style.md
|
|
174
|
+
├── src/
|
|
175
|
+
│ └── .ruler/ # Component-specific rules
|
|
176
|
+
│ └── api_guidelines.md
|
|
177
|
+
├── tests/
|
|
178
|
+
│ └── .ruler/ # Test-specific rules
|
|
179
|
+
│ └── testing_conventions.md
|
|
180
|
+
└── docs/
|
|
181
|
+
└── .ruler/ # Documentation rules
|
|
182
|
+
└── writing_style.md
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**How it works:**
|
|
186
|
+
|
|
187
|
+
- Discover all `.ruler/` directories in the project hierarchy
|
|
188
|
+
- Load and concatenate rules from each directory in order
|
|
189
|
+
- Decide whether nested mode is enabled using the following precedence:
|
|
190
|
+
1. `ruler apply --nested` (or `--no-nested`) takes top priority
|
|
191
|
+
2. `nested = true` in `ruler.toml`
|
|
192
|
+
3. Default to disabled when neither option is provided
|
|
193
|
+
- When a run is nested, downstream configs are forced to keep `nested = true`. If a child config attempts to disable it, Ruler keeps nested processing active and emits a warning in the logs.
|
|
194
|
+
- Nested processing carries forward each directory's own MCP bundle and configuration settings so that generated files remain scoped to their source directories while being normalized back to the project root.
|
|
195
|
+
|
|
196
|
+
> [!CAUTION]
|
|
197
|
+
> Nested mode is experimental and may change in future releases. The CLI logs this warning the first time a nested run is detected so you know the behavior may evolve.
|
|
198
|
+
|
|
199
|
+
**Perfect for:**
|
|
200
|
+
|
|
201
|
+
- Monorepos with multiple services
|
|
202
|
+
- Projects with distinct components (frontend/backend)
|
|
203
|
+
- Teams needing different instructions for different areas
|
|
204
|
+
- Complex codebases with varying standards
|
|
205
|
+
|
|
206
|
+
### Best Practices for Rule Files
|
|
207
|
+
|
|
208
|
+
**Granularity**: Break down complex instructions into focused `.md` files:
|
|
209
|
+
|
|
210
|
+
- `coding_style.md`
|
|
211
|
+
- `api_conventions.md`
|
|
212
|
+
- `project_architecture.md`
|
|
213
|
+
- `security_guidelines.md`
|
|
214
|
+
|
|
215
|
+
**Example rule file (`.ruler/python_guidelines.md`):**
|
|
216
|
+
|
|
217
|
+
```markdown
|
|
218
|
+
# Python Project Guidelines
|
|
219
|
+
|
|
220
|
+
## General Style
|
|
221
|
+
|
|
222
|
+
- Follow PEP 8 for all Python code
|
|
223
|
+
- Use type hints for all function signatures and complex variables
|
|
224
|
+
- Keep functions short and focused on a single task
|
|
225
|
+
|
|
226
|
+
## Error Handling
|
|
227
|
+
|
|
228
|
+
- Use specific exception types rather than generic `Exception`
|
|
229
|
+
- Log errors effectively with context
|
|
230
|
+
|
|
231
|
+
## Security
|
|
232
|
+
|
|
233
|
+
- Always validate and sanitize user input
|
|
234
|
+
- Be mindful of potential injection vulnerabilities
|
|
235
|
+
```
|
|
236
|
+
|
|
237
|
+
## Usage: The `apply` Command
|
|
238
|
+
|
|
239
|
+
### Primary Command
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
ruler apply [options]
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The `apply` command looks for `.ruler/` in the current directory tree, reading the first match. If no such directory is found, it will look for a global configuration in `$XDG_CONFIG_HOME/ruler`.
|
|
246
|
+
|
|
247
|
+
### Options
|
|
248
|
+
|
|
249
|
+
| Option | Description |
|
|
250
|
+
| ------------------------------ | ---------------------------------------------------------------------- |
|
|
251
|
+
| `--project-root <path>` | Project root path (default: current directory). |
|
|
252
|
+
| `--agents <agent1,agent2,...>` | Comma-separated agent names to target (see supported list below). |
|
|
253
|
+
| `--config <path>` | Custom `ruler.toml` path. |
|
|
254
|
+
| `--mcp` / `--with-mcp` | Enable applying MCP server configurations (default: true). |
|
|
255
|
+
| `--no-mcp` | Disable applying MCP server configurations. |
|
|
256
|
+
| `--mcp-overwrite` | Overwrite native MCP config instead of merging. |
|
|
257
|
+
| `--gitignore` | Enable automatic .gitignore updates (default: true). |
|
|
258
|
+
| `--no-gitignore` | Disable automatic .gitignore updates. |
|
|
259
|
+
| `--nested` | Enable nested rule loading (default: inherit from config or disabled). |
|
|
260
|
+
| `--no-nested` | Disable nested rule loading even if `nested = true` in config. |
|
|
261
|
+
| `--backup` / `--no-backup` | Enable/disable creation of `.bak` backup files (default: enabled). |
|
|
262
|
+
| `--dry-run` | Preview changes without writing files. |
|
|
263
|
+
| `--local-only` | Skip `$XDG_CONFIG_HOME` when looking for configuration. |
|
|
264
|
+
| `--verbose` / `-v` | Display detailed output during execution. |
|
|
265
|
+
|
|
266
|
+
### Common Examples
|
|
267
|
+
|
|
268
|
+
**Apply rules to all configured agents:**
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
ruler apply
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**Apply rules only to GitHub Copilot and Claude:**
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
ruler apply --agents copilot,claude
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Apply rules only to Firebase Studio:**
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
ruler apply --agents firebase
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
**Apply rules only to Warp:**
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
ruler apply --agents warp
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Apply rules only to Trae AI:**
|
|
293
|
+
|
|
294
|
+
```bash
|
|
295
|
+
ruler apply --agents trae
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**Apply rules only to RooCode:**
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
ruler apply --agents roo
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Use a specific configuration file:**
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
ruler apply --config ./team-configs/ruler.frontend.toml
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Apply rules with verbose output:**
|
|
311
|
+
|
|
312
|
+
```bash
|
|
313
|
+
ruler apply --verbose
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**Apply rules but skip MCP and .gitignore updates:**
|
|
317
|
+
|
|
318
|
+
```bash
|
|
319
|
+
ruler apply --no-mcp --no-gitignore
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## Usage: The `revert` Command
|
|
323
|
+
|
|
324
|
+
The `revert` command safely undoes all changes made by `ruler apply`, restoring your project to its pre-ruler state. It intelligently restores files from backups (`.bak` files) when available, or removes generated files that didn't exist before.
|
|
325
|
+
|
|
326
|
+
### Why Revert is Needed
|
|
327
|
+
|
|
328
|
+
When experimenting with different rule configurations or switching between projects, you may want to:
|
|
329
|
+
|
|
330
|
+
- **Clean slate**: Remove all ruler-generated files to start fresh
|
|
331
|
+
- **Restore originals**: Revert modified files back to their original state
|
|
332
|
+
- **Selective cleanup**: Remove configurations for specific agents only
|
|
333
|
+
- **Safe experimentation**: Try ruler without fear of permanent changes
|
|
334
|
+
|
|
335
|
+
### Primary Command
|
|
336
|
+
|
|
337
|
+
```bash
|
|
338
|
+
ruler revert [options]
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Options
|
|
342
|
+
|
|
343
|
+
| Option | Description |
|
|
344
|
+
| ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
345
|
+
| `--project-root <path>` | Path to your project's root (default: current directory) |
|
|
346
|
+
| `--agents <agent1,agent2,...>` | Comma-separated list of agent names to revert (agentsmd, aider, amazonqcli, amp, augmentcode, claude, cline, codex, copilot, crush, cursor, firebase, firebender, gemini-cli, goose, jules, junie, kilocode, kiro, opencode, openhands, qwen, roo, trae, warp, windsurf, zed) |
|
|
347
|
+
| `--config <path>` | Path to a custom `ruler.toml` configuration file |
|
|
348
|
+
| `--keep-backups` | Keep backup files (.bak) after restoration (default: false) |
|
|
349
|
+
| `--dry-run` | Preview changes without actually reverting files |
|
|
350
|
+
| `--verbose` / `-v` | Display detailed output during execution |
|
|
351
|
+
| `--local-only` | Only search for local .ruler directories, ignore global config |
|
|
352
|
+
|
|
353
|
+
### Common Examples
|
|
354
|
+
|
|
355
|
+
**Revert all ruler changes:**
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
ruler revert
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
**Preview what would be reverted (dry-run):**
|
|
362
|
+
|
|
363
|
+
```bash
|
|
364
|
+
ruler revert --dry-run
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Revert only specific agents:**
|
|
368
|
+
|
|
369
|
+
```bash
|
|
370
|
+
ruler revert --agents claude,copilot
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
**Revert with detailed output:**
|
|
374
|
+
|
|
375
|
+
```bash
|
|
376
|
+
ruler revert --verbose
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
**Keep backup files after reverting:**
|
|
380
|
+
|
|
381
|
+
```bash
|
|
382
|
+
ruler revert --keep-backups
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
## Configuration (`ruler.toml`) in Detail
|
|
386
|
+
|
|
387
|
+
### Location
|
|
388
|
+
|
|
389
|
+
Defaults to `.ruler/ruler.toml` in the project root. Override with `--config` CLI option.
|
|
390
|
+
|
|
391
|
+
### Complete Example
|
|
392
|
+
|
|
393
|
+
```toml
|
|
394
|
+
# Default agents to run when --agents is not specified
|
|
395
|
+
# Uses case-insensitive substring matching
|
|
396
|
+
default_agents = ["copilot", "claude", "aider"]
|
|
397
|
+
|
|
398
|
+
# --- Global MCP Server Configuration ---
|
|
399
|
+
[mcp]
|
|
400
|
+
# Enable/disable MCP propagation globally (default: true)
|
|
401
|
+
enabled = true
|
|
402
|
+
# Global merge strategy: 'merge' or 'overwrite' (default: 'merge')
|
|
403
|
+
merge_strategy = "merge"
|
|
404
|
+
|
|
405
|
+
# --- MCP Server Definitions ---
|
|
406
|
+
[mcp_servers.filesystem]
|
|
407
|
+
command = "npx"
|
|
408
|
+
args = ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
|
|
409
|
+
|
|
410
|
+
[mcp_servers.git]
|
|
411
|
+
command = "npx"
|
|
412
|
+
args = ["-y", "@modelcontextprotocol/server-git", "--repository", "."]
|
|
413
|
+
|
|
414
|
+
[mcp_servers.remote_api]
|
|
415
|
+
url = "https://api.example.com"
|
|
416
|
+
|
|
417
|
+
[mcp_servers.remote_api.headers]
|
|
418
|
+
Authorization = "Bearer your-token"
|
|
419
|
+
|
|
420
|
+
# --- Global .gitignore Configuration ---
|
|
421
|
+
[gitignore]
|
|
422
|
+
# Enable/disable automatic .gitignore updates (default: true)
|
|
423
|
+
enabled = true
|
|
424
|
+
|
|
425
|
+
# --- Backup Configuration ---
|
|
426
|
+
[backup]
|
|
427
|
+
# Enable/disable creation of .bak backup files (default: true)
|
|
428
|
+
enabled = false
|
|
429
|
+
|
|
430
|
+
# --- Agent-Specific Configurations ---
|
|
431
|
+
[agents.copilot]
|
|
432
|
+
enabled = true
|
|
433
|
+
|
|
434
|
+
[agents.claude]
|
|
435
|
+
enabled = true
|
|
436
|
+
output_path = "CLAUDE.md"
|
|
437
|
+
|
|
438
|
+
[agents.aider]
|
|
439
|
+
enabled = true
|
|
440
|
+
output_path_instructions = "AGENTS.md"
|
|
441
|
+
output_path_config = ".aider.conf.yml"
|
|
442
|
+
|
|
443
|
+
# OpenAI Codex CLI agent and MCP config
|
|
444
|
+
[agents.codex]
|
|
445
|
+
enabled = true
|
|
446
|
+
output_path = "AGENTS.md"
|
|
447
|
+
output_path_config = ".codex/config.toml"
|
|
448
|
+
|
|
449
|
+
# Agent-specific MCP configuration for Codex CLI
|
|
450
|
+
[agents.codex.mcp]
|
|
451
|
+
enabled = true
|
|
452
|
+
merge_strategy = "merge"
|
|
453
|
+
|
|
454
|
+
[agents.firebase]
|
|
455
|
+
enabled = true
|
|
456
|
+
output_path = ".idx/airules.md"
|
|
457
|
+
|
|
458
|
+
[agents.gemini-cli]
|
|
459
|
+
enabled = true
|
|
460
|
+
|
|
461
|
+
[agents.jules]
|
|
462
|
+
enabled = true
|
|
463
|
+
|
|
464
|
+
[agents.junie]
|
|
465
|
+
enabled = true
|
|
466
|
+
output_path = ".junie/guidelines.md"
|
|
467
|
+
|
|
468
|
+
# Agent-specific MCP configuration
|
|
469
|
+
[agents.cursor.mcp]
|
|
470
|
+
enabled = true
|
|
471
|
+
merge_strategy = "merge"
|
|
472
|
+
|
|
473
|
+
# Disable specific agents
|
|
474
|
+
[agents.windsurf]
|
|
475
|
+
enabled = false
|
|
476
|
+
|
|
477
|
+
[agents.kilocode]
|
|
478
|
+
enabled = true
|
|
479
|
+
output_path = ".kilocode/rules/ruler_kilocode_instructions.md"
|
|
480
|
+
|
|
481
|
+
[agents.warp]
|
|
482
|
+
enabled = true
|
|
483
|
+
output_path = "WARP.md"
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
### Configuration Precedence
|
|
487
|
+
|
|
488
|
+
1. **CLI flags** (e.g., `--agents`, `--no-mcp`, `--mcp-overwrite`, `--no-gitignore`)
|
|
489
|
+
2. **Settings in `ruler.toml`** (`default_agents`, specific agent settings, global sections)
|
|
490
|
+
3. **Ruler's built-in defaults** (all agents enabled, standard output paths, MCP enabled with 'merge')
|
|
491
|
+
|
|
492
|
+
## MCP (Model Context Protocol) Server Configuration
|
|
493
|
+
|
|
494
|
+
MCP provides broader context to AI models through server configurations. Ruler can manage and distribute these settings across compatible agents.
|
|
495
|
+
|
|
496
|
+
### TOML Configuration (Recommended)
|
|
497
|
+
|
|
498
|
+
You can now define MCP servers directly in `ruler.toml` using the `[mcp_servers.<name>]` syntax:
|
|
499
|
+
|
|
500
|
+
```toml
|
|
501
|
+
# Global MCP behavior
|
|
502
|
+
[mcp]
|
|
503
|
+
enabled = true
|
|
504
|
+
merge_strategy = "merge" # or "overwrite"
|
|
505
|
+
|
|
506
|
+
# Local (stdio) server
|
|
507
|
+
[mcp_servers.filesystem]
|
|
508
|
+
command = "npx"
|
|
509
|
+
args = ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/project"]
|
|
510
|
+
|
|
511
|
+
[mcp_servers.filesystem.env]
|
|
512
|
+
API_KEY = "your-api-key"
|
|
513
|
+
|
|
514
|
+
# Remote server
|
|
515
|
+
[mcp_servers.search]
|
|
516
|
+
url = "https://mcp.example.com"
|
|
517
|
+
|
|
518
|
+
[mcp_servers.search.headers]
|
|
519
|
+
Authorization = "Bearer your-token"
|
|
520
|
+
"X-API-Version" = "v1"
|
|
521
|
+
```
|
|
522
|
+
|
|
523
|
+
### Configuration Precedence
|
|
524
|
+
|
|
525
|
+
When both TOML and JSON configurations are present:
|
|
526
|
+
|
|
527
|
+
1. **TOML servers take precedence** over JSON servers with the same name
|
|
528
|
+
2. **Servers are merged** from both sources (unless using overwrite strategy)
|
|
529
|
+
3. **Deprecation warning** is shown encouraging migration to TOML (warning shown once per run)
|
|
530
|
+
|
|
531
|
+
### Server Types
|
|
532
|
+
|
|
533
|
+
**Local/stdio servers** require a `command` field:
|
|
534
|
+
|
|
535
|
+
```toml
|
|
536
|
+
[mcp_servers.local_server]
|
|
537
|
+
command = "node"
|
|
538
|
+
args = ["server.js"]
|
|
539
|
+
|
|
540
|
+
[mcp_servers.local_server.env]
|
|
541
|
+
DEBUG = "1"
|
|
542
|
+
```
|
|
543
|
+
|
|
544
|
+
**Remote servers** require a `url` field (headers optional; bearer Authorization token auto-extracted for OpenHands when possible):
|
|
545
|
+
|
|
546
|
+
```toml
|
|
547
|
+
[mcp_servers.remote_server]
|
|
548
|
+
url = "https://api.example.com"
|
|
549
|
+
|
|
550
|
+
[mcp_servers.remote_server.headers]
|
|
551
|
+
Authorization = "Bearer token"
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
Ruler uses this configuration with the `merge` (default) or `overwrite` strategy, controlled by `ruler.toml` or CLI flags.
|
|
555
|
+
|
|
556
|
+
**Home Directory Safety:** Ruler never writes MCP configuration files outside your project root. Any historical references to user home directories (e.g. `~/.codeium/windsurf/mcp_config.json` or `~/.zed/settings.json`) have been removed; only project-local paths are targeted.
|
|
557
|
+
|
|
558
|
+
**Note for OpenAI Codex CLI:** To apply the local Codex CLI MCP configuration, set the `CODEX_HOME` environment variable to your project’s `.codex` directory:
|
|
559
|
+
|
|
560
|
+
```bash
|
|
561
|
+
export CODEX_HOME="$(pwd)/.codex"
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## Skills Support (Experimental)
|
|
565
|
+
|
|
566
|
+
**⚠️ Experimental Feature**: Skills support is currently experimental and requires `uv` (the Python package manager) to be installed on your system for MCP-based agent integration.
|
|
567
|
+
|
|
568
|
+
Ruler can manage and propagate Claude Code-compatible skills to supported AI agents. Skills are stored in `.ruler/skills/` and are automatically distributed to compatible agents when you run `ruler apply`.
|
|
569
|
+
|
|
570
|
+
### How It Works
|
|
571
|
+
|
|
572
|
+
Skills are specialized knowledge packages that extend AI agent capabilities with domain-specific expertise, workflows, or tool integrations. Ruler discovers skills in your `.ruler/skills/` directory and propagates them to compatible agents:
|
|
573
|
+
|
|
574
|
+
- **Claude Code**: Skills copied to `.claude/skills/` with @filename references preserved
|
|
575
|
+
- **Cursor**: Uses `.cursor/rules/` directly (copied when `merge_strategy = "cursor"`), no skillz MCP needed
|
|
576
|
+
- **Other MCP agents**: Skills copied to `.skillz/` with @filename references expanded to full content (frontmatter stripped), Skillz MCP server auto-configured via `uvx`
|
|
577
|
+
|
|
578
|
+
### Skills Directory Structure
|
|
579
|
+
|
|
580
|
+
Skills can be organized flat or nested:
|
|
581
|
+
|
|
582
|
+
```
|
|
583
|
+
.ruler/skills/
|
|
584
|
+
├── my-skill/
|
|
585
|
+
│ ├── SKILL.md # Required: skill instructions/knowledge
|
|
586
|
+
│ ├── helper.py # Optional: additional resources (scripts)
|
|
587
|
+
│ └── reference.md # Optional: additional resources (docs)
|
|
588
|
+
└── another-skill/
|
|
589
|
+
└── SKILL.md
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
Each skill must contain:
|
|
593
|
+
|
|
594
|
+
- `SKILL.md` - Primary skill file with instructions or knowledge base
|
|
595
|
+
|
|
596
|
+
Skills can optionally include additional resources like:
|
|
597
|
+
|
|
598
|
+
- Markdown files with supplementary documentation
|
|
599
|
+
- Python, JavaScript, or other scripts
|
|
600
|
+
- Configuration files or data
|
|
601
|
+
|
|
602
|
+
### Auto-Generated Skills from Rules (with `generate_from_rules = true`)
|
|
603
|
+
|
|
604
|
+
When using `[skills].generate_from_rules = true`, skills are automatically created from `.mdc` files in your rules directory. This feature supports folder-based organization:
|
|
605
|
+
|
|
606
|
+
**Folder Support**: If your `.mdc` file is in a folder with the same name, all additional files in that folder are automatically copied to the generated skill:
|
|
607
|
+
|
|
608
|
+
```
|
|
609
|
+
.claude/rules/docx/
|
|
610
|
+
├── docx.mdc # Main rule (with frontmatter)
|
|
611
|
+
├── script.sh # Helper script
|
|
612
|
+
└── templates/ # Subdirectory
|
|
613
|
+
└── default.docx # Template file
|
|
614
|
+
|
|
615
|
+
→ Generated:
|
|
616
|
+
|
|
617
|
+
.claude/skills/docx/
|
|
618
|
+
├── SKILL.md # Generated from docx.mdc
|
|
619
|
+
├── script.sh # Copied automatically
|
|
620
|
+
└── templates/ # Copied automatically
|
|
621
|
+
└── default.docx # Copied automatically
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
**Requirements for folder copying**:
|
|
625
|
+
- The `.mdc` file must be in a folder with the same basename (e.g., `docx/docx.mdc`)
|
|
626
|
+
- The `.mdc` file must have frontmatter with `alwaysApply: false` (or undefined)
|
|
627
|
+
- All files and subdirectories in that folder (except the `.mdc` file itself) are copied
|
|
628
|
+
|
|
629
|
+
**Example `.mdc` file with frontmatter**:
|
|
630
|
+
```markdown
|
|
631
|
+
---
|
|
632
|
+
description: DOCX file processing utilities
|
|
633
|
+
globs: ["**/*.docx"]
|
|
634
|
+
alwaysApply: false
|
|
635
|
+
---
|
|
636
|
+
|
|
637
|
+
# DOCX Processing
|
|
638
|
+
|
|
639
|
+
Use script.sh to process DOCX files. Templates are in templates/ directory.
|
|
640
|
+
```
|
|
641
|
+
|
|
642
|
+
### Configuration
|
|
643
|
+
|
|
644
|
+
Skills support is **enabled by default** but can be controlled via:
|
|
645
|
+
|
|
646
|
+
**CLI flags:**
|
|
647
|
+
|
|
648
|
+
```bash
|
|
649
|
+
# Enable skills (default)
|
|
650
|
+
ruler apply --skills
|
|
651
|
+
|
|
652
|
+
# Disable skills
|
|
653
|
+
ruler apply --no-skills
|
|
654
|
+
```
|
|
655
|
+
|
|
656
|
+
**Configuration in `ruler.toml`:**
|
|
657
|
+
|
|
658
|
+
```toml
|
|
659
|
+
[skills]
|
|
660
|
+
enabled = true # or false to disable
|
|
661
|
+
```
|
|
662
|
+
|
|
663
|
+
### Skillz MCP Server
|
|
664
|
+
|
|
665
|
+
For agents that support MCP but don't have native skills support (excluding Claude Code and Cursor), Ruler automatically:
|
|
666
|
+
|
|
667
|
+
1. Copies skills to `.skillz/` directory with @filename references expanded to full content
|
|
668
|
+
2. Strips frontmatter from referenced .mdc files to avoid duplication
|
|
669
|
+
3. Configures a Skillz MCP server in the agent's configuration
|
|
670
|
+
4. Uses `uvx` to launch the server with the absolute path to `.skillz`
|
|
671
|
+
|
|
672
|
+
**Note**: Cursor is excluded from Skillz MCP because it uses `.cursor/rules/` directory natively.
|
|
673
|
+
|
|
674
|
+
Example auto-generated MCP server configuration:
|
|
675
|
+
|
|
676
|
+
```toml
|
|
677
|
+
[mcp_servers.skillz]
|
|
678
|
+
command = "uvx"
|
|
679
|
+
args = ["skillz@latest", "/absolute/path/to/project/.skillz"]
|
|
680
|
+
```
|
|
681
|
+
|
|
682
|
+
### `.gitignore` Integration
|
|
683
|
+
|
|
684
|
+
When skills support is enabled and gitignore integration is active, Ruler automatically adds:
|
|
685
|
+
|
|
686
|
+
- `.claude/skills/` (when generated from `.claude/rules/` or copied from `.ruler/skills/`)
|
|
687
|
+
- `.skillz/` (for MCP-based agents excluding Cursor)
|
|
688
|
+
- `.cursor/rules/` (when using `merge_strategy = "cursor"`)
|
|
689
|
+
|
|
690
|
+
to your `.gitignore` file within the managed Ruler block.
|
|
691
|
+
|
|
692
|
+
**Note**: If you manually create `.claude/skills/` without `.claude/rules/`, it won't be gitignored (assumed to be versioned).
|
|
693
|
+
|
|
694
|
+
### Requirements
|
|
695
|
+
|
|
696
|
+
- **For Claude Code**: No additional requirements
|
|
697
|
+
- **For MCP agents**: `uv` must be installed and available in your PATH
|
|
698
|
+
```bash
|
|
699
|
+
# Install uv if needed
|
|
700
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
### Validation
|
|
704
|
+
|
|
705
|
+
Ruler validates discovered skills and issues warnings for:
|
|
706
|
+
|
|
707
|
+
- Missing required file (`SKILL.md`)
|
|
708
|
+
- Invalid directory structures (directories without `SKILL.md` and no sub-skills)
|
|
709
|
+
|
|
710
|
+
Warnings don't prevent propagation but help identify potential issues.
|
|
711
|
+
|
|
712
|
+
### Dry-Run Mode
|
|
713
|
+
|
|
714
|
+
Test skills propagation without making changes:
|
|
715
|
+
|
|
716
|
+
```bash
|
|
717
|
+
ruler apply --dry-run
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
This shows which skills would be copied and which MCP servers would be configured.
|
|
721
|
+
|
|
722
|
+
### Example Workflow
|
|
723
|
+
|
|
724
|
+
```bash
|
|
725
|
+
# 1. Add a skill to your project
|
|
726
|
+
mkdir -p .ruler/skills/my-skill
|
|
727
|
+
cat > .ruler/skills/my-skill/SKILL.md << 'EOF'
|
|
728
|
+
# My Custom Skill
|
|
729
|
+
|
|
730
|
+
This skill provides specialized knowledge for...
|
|
731
|
+
|
|
732
|
+
## Usage
|
|
733
|
+
|
|
734
|
+
When working on this project, always follow these guidelines:
|
|
735
|
+
- Use TypeScript for all new code
|
|
736
|
+
- Write tests for all features
|
|
737
|
+
- Follow the existing code style
|
|
738
|
+
EOF
|
|
739
|
+
|
|
740
|
+
# 2. Apply to all agents (skills enabled by default)
|
|
741
|
+
ruler apply
|
|
742
|
+
|
|
743
|
+
# 3. Skills are now available to compatible agents:
|
|
744
|
+
# - Claude Code: .claude/skills/my-skill/
|
|
745
|
+
# - Other MCP agents: .skillz/my-skill/ + Skillz MCP server configured
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
## `.gitignore` Integration
|
|
749
|
+
|
|
750
|
+
Ruler automatically manages your `.gitignore` file to keep generated agent configuration files out of version control.
|
|
751
|
+
|
|
752
|
+
### How it Works
|
|
753
|
+
|
|
754
|
+
- Creates or updates `.gitignore` in your project root
|
|
755
|
+
- Adds paths to a managed block marked with `# START Ruler Generated Files` and `# END Ruler Generated Files`
|
|
756
|
+
- Preserves existing content outside this block
|
|
757
|
+
- Sorts paths alphabetically and uses relative POSIX-style paths
|
|
758
|
+
|
|
759
|
+
### Example `.gitignore` Section (sample - actual list depends on enabled agents)
|
|
760
|
+
|
|
761
|
+
```gitignore
|
|
762
|
+
# Your existing rules
|
|
763
|
+
node_modules/
|
|
764
|
+
*.log
|
|
765
|
+
|
|
766
|
+
# START Ruler Generated Files
|
|
767
|
+
.aider.conf.yml
|
|
768
|
+
.clinerules
|
|
769
|
+
AGENTS.md
|
|
770
|
+
CLAUDE.md
|
|
771
|
+
# END Ruler Generated Files
|
|
772
|
+
|
|
773
|
+
dist/
|
|
774
|
+
```
|
|
775
|
+
|
|
776
|
+
### Control Options
|
|
777
|
+
|
|
778
|
+
- **CLI flags**: `--gitignore` or `--no-gitignore`
|
|
779
|
+
- **Configuration**: `[gitignore].enabled` in `ruler.toml`
|
|
780
|
+
- **Default**: enabled
|
|
781
|
+
|
|
782
|
+
## Practical Usage Scenarios
|
|
783
|
+
|
|
784
|
+
### Scenario 1: Getting Started Quickly
|
|
785
|
+
|
|
786
|
+
```bash
|
|
787
|
+
# Initialize Ruler in your project
|
|
788
|
+
cd your-project
|
|
789
|
+
ruler init
|
|
790
|
+
|
|
791
|
+
# Edit the generated files
|
|
792
|
+
# - Add your coding guidelines to .ruler/AGENTS.md (or keep adding additional .md files)
|
|
793
|
+
# - Customize .ruler/ruler.toml if needed
|
|
794
|
+
|
|
795
|
+
# Apply rules to all AI agents
|
|
796
|
+
ruler apply
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
### Scenario 2: Complex Projects with Nested Rules
|
|
800
|
+
|
|
801
|
+
For large projects with multiple components or services, enable nested rule loading so each directory keeps its own rules and MCP bundle:
|
|
802
|
+
|
|
803
|
+
```bash
|
|
804
|
+
# Set up nested .ruler directories
|
|
805
|
+
mkdir -p src/.ruler tests/.ruler docs/.ruler
|
|
806
|
+
|
|
807
|
+
# Add component-specific instructions
|
|
808
|
+
echo "# API Design Guidelines" > src/.ruler/api_rules.md
|
|
809
|
+
echo "# Testing Best Practices" > tests/.ruler/test_rules.md
|
|
810
|
+
echo "# Documentation Standards" > docs/.ruler/docs_rules.md
|
|
811
|
+
```
|
|
812
|
+
|
|
813
|
+
```toml
|
|
814
|
+
# .ruler/ruler.toml
|
|
815
|
+
nested = true
|
|
816
|
+
```
|
|
817
|
+
|
|
818
|
+
```bash
|
|
819
|
+
# The CLI inherits nested mode from ruler.toml
|
|
820
|
+
ruler apply --verbose
|
|
821
|
+
|
|
822
|
+
# Override from the CLI at any time
|
|
823
|
+
ruler apply --no-nested
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
This creates context-specific instructions for different parts of your project while maintaining global rules in the root `.ruler/` directory. Nested runs automatically keep every nested config enabled even if a child tries to disable it.
|
|
827
|
+
|
|
828
|
+
> [!NOTE]
|
|
829
|
+
> The CLI prints "Nested mode is experimental and may change in future releases." the first time nested processing runs. Expect refinements in future versions.
|
|
830
|
+
|
|
831
|
+
### Scenario 3: Team Standardization
|
|
832
|
+
|
|
833
|
+
1. Create `.ruler/coding_standards.md`, `.ruler/api_usage.md`
|
|
834
|
+
2. Commit the `.ruler` directory to your repository
|
|
835
|
+
3. Team members pull changes and run `ruler apply` to update their local AI agent configurations
|
|
836
|
+
|
|
837
|
+
### Scenario 4: Project-Specific Context for AI
|
|
838
|
+
|
|
839
|
+
1. Detail your project's architecture in `.ruler/project_overview.md`
|
|
840
|
+
2. Describe primary data structures in `.ruler/data_models.md`
|
|
841
|
+
3. Run `ruler apply` to help AI tools provide more relevant suggestions
|
|
842
|
+
|
|
843
|
+
### Integration with NPM Scripts
|
|
844
|
+
|
|
845
|
+
```json
|
|
846
|
+
{
|
|
847
|
+
"scripts": {
|
|
848
|
+
"ruler:apply": "ruler apply",
|
|
849
|
+
"dev": "npm run ruler:apply && your_dev_command",
|
|
850
|
+
"precommit": "npm run ruler:apply"
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
```
|
|
854
|
+
|
|
855
|
+
### Integration with GitHub Actions
|
|
856
|
+
|
|
857
|
+
```yaml
|
|
858
|
+
# .github/workflows/ruler-check.yml
|
|
859
|
+
name: Check Ruler Configuration
|
|
860
|
+
on:
|
|
861
|
+
pull_request:
|
|
862
|
+
paths: ['.ruler/**']
|
|
863
|
+
|
|
864
|
+
jobs:
|
|
865
|
+
check-ruler:
|
|
866
|
+
runs-on: ubuntu-latest
|
|
867
|
+
steps:
|
|
868
|
+
- uses: actions/checkout@v4
|
|
869
|
+
- uses: actions/setup-node@v4
|
|
870
|
+
with:
|
|
871
|
+
node-version: '18'
|
|
872
|
+
cache: 'npm'
|
|
873
|
+
|
|
874
|
+
- name: Install Ruler
|
|
875
|
+
run: npm install -g @udecode/ruler
|
|
876
|
+
|
|
877
|
+
- name: Apply Ruler configuration
|
|
878
|
+
run: ruler apply --no-gitignore
|
|
879
|
+
|
|
880
|
+
- name: Check for uncommitted changes
|
|
881
|
+
run: |
|
|
882
|
+
if [[ -n $(git status --porcelain) ]]; then
|
|
883
|
+
echo "::error::Ruler configuration is out of sync!"
|
|
884
|
+
echo "Please run 'ruler apply' locally and commit the changes."
|
|
885
|
+
exit 1
|
|
886
|
+
fi
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
## Troubleshooting
|
|
890
|
+
|
|
891
|
+
### Common Issues
|
|
892
|
+
|
|
893
|
+
**"Cannot find module" errors:**
|
|
894
|
+
|
|
895
|
+
- Ensure Ruler is installed globally: `npm install -g @udecode/ruler`
|
|
896
|
+
- Or use `npx @udecode/ruler`
|
|
897
|
+
|
|
898
|
+
**Permission denied errors:**
|
|
899
|
+
|
|
900
|
+
- On Unix systems, you may need `sudo` for global installation
|
|
901
|
+
|
|
902
|
+
**Agent files not updating:**
|
|
903
|
+
|
|
904
|
+
- Check if the agent is enabled in `ruler.toml`
|
|
905
|
+
- Verify agent isn't excluded by `--agents` flag
|
|
906
|
+
- Use `--verbose` to see detailed execution logs
|
|
907
|
+
|
|
908
|
+
**Configuration validation errors:**
|
|
909
|
+
|
|
910
|
+
- Ruler now validates `ruler.toml` format and will show specific error details
|
|
911
|
+
- Check that all configuration values match the expected types and formats
|
|
912
|
+
|
|
913
|
+
### Debug Mode
|
|
914
|
+
|
|
915
|
+
Use `--verbose` flag to see detailed execution logs:
|
|
916
|
+
|
|
917
|
+
```bash
|
|
918
|
+
ruler apply --verbose
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
This shows:
|
|
922
|
+
|
|
923
|
+
- Configuration loading details
|
|
924
|
+
- Agent selection logic
|
|
925
|
+
- File processing information
|
|
926
|
+
- MCP configuration steps
|
|
927
|
+
|
|
928
|
+
## FAQ
|
|
929
|
+
|
|
930
|
+
**Q: Can I use different rules for different agents?**
|
|
931
|
+
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".
|
|
932
|
+
|
|
933
|
+
**Q: How do I set up different instructions for different parts of my project?**
|
|
934
|
+
A: Enable nested mode either by setting `nested = true` in `ruler.toml` or by passing `ruler apply --nested`. The CLI inherits the config setting by default, but `--no-nested` always wins if you need to opt out for a run. Nested mode keeps loading rules (and MCP settings) from every `.ruler/` directory in the hierarchy, forces child configs to remain nested, and logs "Nested mode is experimental and may change in future releases." if any nested processing occurs.
|
|
935
|
+
|
|
936
|
+
**Q: How do I temporarily disable Ruler for an agent?**
|
|
937
|
+
A: Set `enabled = false` in `ruler.toml` under `[agents.agentname]`, or use `--agents` flag to specify only the agents you want.
|
|
938
|
+
|
|
939
|
+
**Q: What happens to my existing agent configuration files?**
|
|
940
|
+
A: Ruler creates backups with `.bak` extension before overwriting any existing files.
|
|
941
|
+
|
|
942
|
+
**Q: Can I run Ruler in CI/CD pipelines?**
|
|
943
|
+
A: Yes! Use `ruler apply --no-gitignore` in CI to avoid modifying `.gitignore`. See the GitHub Actions example above.
|
|
944
|
+
|
|
945
|
+
**Q: How does OpenHands MCP propagation classify servers?**
|
|
946
|
+
A: Local stdio servers become `stdio_servers`. Remote URLs containing `/sse` are classified as `sse_servers`; others become `shttp_servers`. Bearer tokens in an `Authorization` header are extracted into `api_key` where possible.
|
|
947
|
+
|
|
948
|
+
**Q: Where is Zed configuration written now?**
|
|
949
|
+
A: Ruler writes a `settings.json` in the project root (not the user home dir) and transforms MCP server definitions to Zed's `context_servers` format including `source: "custom"`.
|
|
950
|
+
|
|
951
|
+
**Q: What changed about MCP initialization?**
|
|
952
|
+
A: `ruler init` now only adds example MCP server sections to `ruler.toml` instead of creating `.ruler/mcp.json`. The JSON file is still consumed if present, but TOML servers win on name conflicts.
|
|
953
|
+
|
|
954
|
+
**Q: Is Kiro supported?**
|
|
955
|
+
A: Yes. Kiro receives concatenated rules at `.kiro/steering/ruler_kiro_instructions.md`.
|
|
956
|
+
|
|
957
|
+
## Development
|
|
958
|
+
|
|
959
|
+
### Setup
|
|
960
|
+
|
|
961
|
+
```bash
|
|
962
|
+
git clone https://github.com/udecode/ruler.git
|
|
963
|
+
cd ruler
|
|
964
|
+
npm install
|
|
965
|
+
npm run build
|
|
966
|
+
```
|
|
967
|
+
|
|
968
|
+
### Testing
|
|
969
|
+
|
|
970
|
+
```bash
|
|
971
|
+
# Run all tests
|
|
972
|
+
npm test
|
|
973
|
+
|
|
974
|
+
# Run tests with coverage
|
|
975
|
+
npm run test:coverage
|
|
976
|
+
|
|
977
|
+
# Run tests in watch mode
|
|
978
|
+
npm run test:watch
|
|
979
|
+
```
|
|
980
|
+
|
|
981
|
+
### Code Quality
|
|
982
|
+
|
|
983
|
+
```bash
|
|
984
|
+
# Run linting
|
|
985
|
+
npm run lint
|
|
986
|
+
|
|
987
|
+
# Run formatting
|
|
988
|
+
npm run format
|
|
989
|
+
```
|