ai-agent-rules 0.4.0__tar.gz
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.
- ai_agent_rules-0.4.0/LICENSE +22 -0
- ai_agent_rules-0.4.0/PKG-INFO +324 -0
- ai_agent_rules-0.4.0/README.md +290 -0
- ai_agent_rules-0.4.0/pyproject.toml +106 -0
- ai_agent_rules-0.4.0/setup.cfg +4 -0
- ai_agent_rules-0.4.0/src/ai_agent_rules.egg-info/PKG-INFO +324 -0
- ai_agent_rules-0.4.0/src/ai_agent_rules.egg-info/SOURCES.txt +23 -0
- ai_agent_rules-0.4.0/src/ai_agent_rules.egg-info/dependency_links.txt +1 -0
- ai_agent_rules-0.4.0/src/ai_agent_rules.egg-info/entry_points.txt +2 -0
- ai_agent_rules-0.4.0/src/ai_agent_rules.egg-info/requires.txt +9 -0
- ai_agent_rules-0.4.0/src/ai_agent_rules.egg-info/top_level.txt +1 -0
- ai_agent_rules-0.4.0/src/ai_rules/agents/base.py +68 -0
- ai_agent_rules-0.4.0/src/ai_rules/agents/claude.py +119 -0
- ai_agent_rules-0.4.0/src/ai_rules/agents/goose.py +42 -0
- ai_agent_rules-0.4.0/src/ai_rules/agents/shared.py +33 -0
- ai_agent_rules-0.4.0/src/ai_rules/bootstrap/__init__.py +52 -0
- ai_agent_rules-0.4.0/src/ai_rules/bootstrap/config.py +207 -0
- ai_agent_rules-0.4.0/src/ai_rules/bootstrap/installer.py +100 -0
- ai_agent_rules-0.4.0/src/ai_rules/bootstrap/updater.py +104 -0
- ai_agent_rules-0.4.0/src/ai_rules/bootstrap/version.py +52 -0
- ai_agent_rules-0.4.0/src/ai_rules/cli.py +1668 -0
- ai_agent_rules-0.4.0/src/ai_rules/config.py +541 -0
- ai_agent_rules-0.4.0/src/ai_rules/display.py +40 -0
- ai_agent_rules-0.4.0/src/ai_rules/mcp.py +358 -0
- ai_agent_rules-0.4.0/src/ai_rules/symlinks.py +207 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
|
|
2
|
+
MIT License
|
|
3
|
+
|
|
4
|
+
Copyright (c) 2025 Will Pfleger
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ai-agent-rules
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Manage user-level AI agent configurations
|
|
5
|
+
Author-email: Will Pfleger <pfleger.will@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/willpfleger/ai-rules
|
|
8
|
+
Project-URL: Repository, https://github.com/willpfleger/ai-rules
|
|
9
|
+
Project-URL: Issues, https://github.com/willpfleger/ai-rules/issues
|
|
10
|
+
Keywords: ai,cli,configuration,claude,goose,llm,agent
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: Utilities
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: click>=8.1
|
|
25
|
+
Requires-Dist: hatch>=1.15.1
|
|
26
|
+
Requires-Dist: packaging>=21.0
|
|
27
|
+
Requires-Dist: pytest>=8.4.2
|
|
28
|
+
Requires-Dist: pytest-cov>=7.0.0
|
|
29
|
+
Requires-Dist: pytest-xdist>=3.8.0
|
|
30
|
+
Requires-Dist: pyyaml>=6.0
|
|
31
|
+
Requires-Dist: rich>=13.0
|
|
32
|
+
Requires-Dist: ruff>=0.14.3
|
|
33
|
+
Dynamic: license-file
|
|
34
|
+
|
|
35
|
+
# AI Rules
|
|
36
|
+
|
|
37
|
+
Manage AI agent configurations through symlinks. Keep all your configs in one git-tracked location.
|
|
38
|
+
|
|
39
|
+
[](https://github.com/wpfleger96/ai-rules/graphs/contributors)
|
|
40
|
+
[](https://github.com/wpfleger96/ai-rules/blob/main/LICENSE)
|
|
41
|
+
|
|
42
|
+
## Overview
|
|
43
|
+
|
|
44
|
+
Consolidates config files for AI coding agents (Claude Code, Goose) into a single source of truth via symlinks:
|
|
45
|
+
|
|
46
|
+
- Git-tracked configs synced across machines
|
|
47
|
+
- Edit once, apply everywhere
|
|
48
|
+
- Exclude specific files (e.g., company-managed)
|
|
49
|
+
- Per-agent customizations
|
|
50
|
+
|
|
51
|
+
**Supported:** Claude Code (settings, agents, commands), Goose (hints, config), Shared (AGENTS.md)
|
|
52
|
+
|
|
53
|
+
## Installation
|
|
54
|
+
|
|
55
|
+
**Requirements:** Python 3.10+, [uv](https://github.com/astral-sh/uv)
|
|
56
|
+
|
|
57
|
+
### From PyPI (Recommended)
|
|
58
|
+
|
|
59
|
+
One-command setup from PyPI:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
uvx ai-agent-rules setup
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
This will:
|
|
66
|
+
1. Install AI agent configuration symlinks
|
|
67
|
+
2. Make `ai-rules` available system-wide
|
|
68
|
+
|
|
69
|
+
After setup, you can run `ai-rules` from any directory.
|
|
70
|
+
|
|
71
|
+
### Local Development
|
|
72
|
+
|
|
73
|
+
For contributing or local development:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
git clone https://github.com/wpfleger96/ai-rules.git
|
|
77
|
+
cd ai-rules
|
|
78
|
+
uv tool install -e .
|
|
79
|
+
ai-rules install
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Updating
|
|
83
|
+
|
|
84
|
+
Check for and install updates:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
ai-rules upgrade # Check and install updates
|
|
88
|
+
ai-rules upgrade --check # Only check for updates
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Auto-update checks run weekly by default. Configure in `~/.ai-rules/update_config.yaml`:
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
enabled: true
|
|
95
|
+
frequency: weekly # daily, weekly, never
|
|
96
|
+
notify_only: false
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Usage
|
|
100
|
+
|
|
101
|
+
### User-Level Configuration
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
ai-rules setup # One-time setup: install symlinks + make available system-wide
|
|
105
|
+
ai-rules upgrade # Upgrade to latest version
|
|
106
|
+
ai-rules upgrade --check # Check for updates without installing
|
|
107
|
+
|
|
108
|
+
ai-rules install # Install all agent configs
|
|
109
|
+
ai-rules install --agents claude # Install specific agents
|
|
110
|
+
ai-rules install --dry-run # Preview changes
|
|
111
|
+
ai-rules install --force # Skip confirmations
|
|
112
|
+
ai-rules install --rebuild-cache # Rebuild merged settings cache
|
|
113
|
+
|
|
114
|
+
ai-rules status # Check symlink status (✓✗⚠○)
|
|
115
|
+
ai-rules diff # Show config differences
|
|
116
|
+
ai-rules validate # Verify source files exist
|
|
117
|
+
ai-rules update # Re-sync after adding files
|
|
118
|
+
ai-rules uninstall # Remove all symlinks
|
|
119
|
+
ai-rules list-agents # Show available agents
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### Configuration Management
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
# Interactive wizard for first-time setup
|
|
126
|
+
ai-rules config init # Start configuration wizard
|
|
127
|
+
|
|
128
|
+
# View configuration
|
|
129
|
+
ai-rules config show # Show raw config files
|
|
130
|
+
ai-rules config show --merged # Show merged settings with overrides
|
|
131
|
+
ai-rules config show --agent claude # Show config for specific agent
|
|
132
|
+
ai-rules config edit # Edit user config in $EDITOR
|
|
133
|
+
|
|
134
|
+
# Manage exclusions
|
|
135
|
+
ai-rules exclude add "~/.claude/*.json" # Add exclusion pattern (supports globs)
|
|
136
|
+
ai-rules exclude remove "~/.claude/*.json" # Remove exclusion pattern
|
|
137
|
+
ai-rules exclude list # List all exclusions
|
|
138
|
+
|
|
139
|
+
# Manage settings overrides (for machine-specific settings)
|
|
140
|
+
ai-rules override set claude.model "claude-sonnet-4-5-20250929" # Set simple override
|
|
141
|
+
ai-rules override set claude.hooks.SubagentStop[0].hooks[0].command "script.py" # Array notation
|
|
142
|
+
ai-rules override unset claude.model # Remove override
|
|
143
|
+
ai-rules override list # List all overrides
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Configuration
|
|
147
|
+
|
|
148
|
+
### Quick Start with Config Wizard
|
|
149
|
+
|
|
150
|
+
Run the interactive configuration wizard for guided setup:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
ai-rules config init
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This will walk you through:
|
|
157
|
+
1. Selecting common exclusions
|
|
158
|
+
2. Adding custom exclusion patterns (with glob support)
|
|
159
|
+
3. Setting up machine-specific settings overrides
|
|
160
|
+
|
|
161
|
+
### User-Level Config
|
|
162
|
+
|
|
163
|
+
Create `~/.ai-rules-config.yaml` for user-level settings:
|
|
164
|
+
|
|
165
|
+
```yaml
|
|
166
|
+
version: 1
|
|
167
|
+
|
|
168
|
+
# Global exclusions (apply to all contexts)
|
|
169
|
+
# Supports glob patterns: *.json, **/*.yaml, etc.
|
|
170
|
+
exclude_symlinks:
|
|
171
|
+
- "~/.config/goose/config.yaml"
|
|
172
|
+
- "~/.claude/*.log" # Glob: exclude all log files
|
|
173
|
+
- "~/.claude/agents/debug-*.md" # Glob: exclude debug agents
|
|
174
|
+
|
|
175
|
+
# Machine-specific settings overrides
|
|
176
|
+
# Keeps repo settings.json synced via git, but allows local overrides
|
|
177
|
+
settings_overrides:
|
|
178
|
+
claude:
|
|
179
|
+
model: "claude-sonnet-4-5-20250929" # Override model on personal laptop
|
|
180
|
+
# Other settings inherited from repo config/claude/settings.json
|
|
181
|
+
goose:
|
|
182
|
+
provider: "anthropic"
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Config File Locations:**
|
|
186
|
+
- `~/.ai-rules-config.yaml` - User-specific config (exclusions and overrides)
|
|
187
|
+
- `<repo>/.ai-rules-config.yaml` - Repo defaults (global exclusions only)
|
|
188
|
+
|
|
189
|
+
**Config Precedence:**
|
|
190
|
+
- User config exclusions + Repo config exclusions = Combined (additive)
|
|
191
|
+
- Settings overrides only loaded from user config (machine-specific, not in git)
|
|
192
|
+
|
|
193
|
+
### Settings Overrides - Syncing Configs Across Machines
|
|
194
|
+
|
|
195
|
+
**Problem:** You want to sync your `settings.json` via git, but need different settings on different machines (e.g., different model access on work vs personal laptop).
|
|
196
|
+
|
|
197
|
+
**Solution:** Use `settings_overrides` in your user config:
|
|
198
|
+
|
|
199
|
+
```yaml
|
|
200
|
+
# ~/.ai-rules-config.yaml on personal laptop
|
|
201
|
+
settings_overrides:
|
|
202
|
+
claude:
|
|
203
|
+
model: "claude-sonnet-4-5-20250929" # No Opus access
|
|
204
|
+
|
|
205
|
+
# ~/.ai-rules-config.yaml on work laptop
|
|
206
|
+
settings_overrides:
|
|
207
|
+
claude:
|
|
208
|
+
model: "claude-opus-4-20250514" # Has Opus access
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Both machines sync the same `config/claude/settings.json` via git, but each has different local overrides. The system merges them at install time:
|
|
212
|
+
|
|
213
|
+
1. **Base settings** from `config/claude/settings.json` (git-tracked)
|
|
214
|
+
2. **Merged with** overrides from `~/.ai-rules-config.yaml` (local only)
|
|
215
|
+
3. **Cached** in `~/.ai-rules/cache/claude/settings.json`
|
|
216
|
+
4. **Symlinked** to `~/.claude/settings.json`
|
|
217
|
+
|
|
218
|
+
After changing overrides, run:
|
|
219
|
+
```bash
|
|
220
|
+
ai-rules install --rebuild-cache
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### Array Notation for Nested Settings
|
|
224
|
+
|
|
225
|
+
Override commands support array index notation for complex nested structures:
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
# Override nested array elements (e.g., hooks)
|
|
229
|
+
ai-rules override set claude.hooks.SubagentStop[0].hooks[0].command "uv run ~/my-hook.py"
|
|
230
|
+
|
|
231
|
+
# Override environment variables
|
|
232
|
+
ai-rules override set claude.env.MY_VAR "value"
|
|
233
|
+
|
|
234
|
+
# The system validates paths and provides helpful suggestions
|
|
235
|
+
ai-rules override set claude.modle "sonnet"
|
|
236
|
+
# Error: Key 'modle' not found at 'modle'
|
|
237
|
+
# Available options: model, env, hooks, statusLine, ...
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
Path validation ensures you only set valid overrides that exist in the base settings, preventing typos and configuration errors.
|
|
241
|
+
|
|
242
|
+
## Structure
|
|
243
|
+
|
|
244
|
+
```
|
|
245
|
+
config/
|
|
246
|
+
├── AGENTS.md # User-level rules → ~/AGENTS.md, ~/.CLAUDE.md, ~/.config/goose/.goosehints
|
|
247
|
+
├── claude/
|
|
248
|
+
│ ├── settings.json # → ~/.claude/settings.json
|
|
249
|
+
│ ├── agents/*.md # → ~/.claude/agents/*.md (dynamic)
|
|
250
|
+
│ └── commands/*.md # → ~/.claude/commands/*.md (dynamic)
|
|
251
|
+
└── goose/
|
|
252
|
+
└── config.yaml # → ~/.config/goose/config.yaml
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
## Extending
|
|
256
|
+
|
|
257
|
+
**Add Claude agent/command:**
|
|
258
|
+
1. Create `config/claude/agents/my-agent.md` or `config/claude/commands/my-cmd.md`
|
|
259
|
+
2. Run `ai-rules update`
|
|
260
|
+
|
|
261
|
+
**Add new AI tool:**
|
|
262
|
+
1. Add configs to `config/<tool>/`
|
|
263
|
+
2. Implement `ai_rules/agents/<tool>.py`
|
|
264
|
+
3. Register in `ai_rules/cli.py::get_agents()`
|
|
265
|
+
|
|
266
|
+
## Safety
|
|
267
|
+
|
|
268
|
+
- First-run warnings
|
|
269
|
+
- Timestamped backups (`*.ai-rules-backup.YYYYMMDD-HHMMSS`)
|
|
270
|
+
- Interactive prompts and dry-run mode
|
|
271
|
+
- Only manages symlinks (never deletes real files)
|
|
272
|
+
- Contextual error messages with tips
|
|
273
|
+
|
|
274
|
+
## Development
|
|
275
|
+
|
|
276
|
+
### Running Tests
|
|
277
|
+
The test suite includes both unit tests and integration tests.
|
|
278
|
+
|
|
279
|
+
The pytest-cov args are optional, use them to include a test coverage report in the output. To run all tests:
|
|
280
|
+
|
|
281
|
+
```bash
|
|
282
|
+
uv run pytest [--cov=src --cov-report=term-missing]
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
To only run unit tests:
|
|
286
|
+
```bash
|
|
287
|
+
uv run pytest -m unit
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
To only run integration tests:
|
|
291
|
+
```bash
|
|
292
|
+
uv run pytest -m integration
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Troubleshooting
|
|
296
|
+
|
|
297
|
+
**Wrong target:** `ai-rules status` then `ai-rules install --force`
|
|
298
|
+
|
|
299
|
+
**Restore backup:**
|
|
300
|
+
```bash
|
|
301
|
+
ls -la ~/.CLAUDE.md.ai-rules-backup.*
|
|
302
|
+
mv ~/.CLAUDE.md.ai-rules-backup.20250104-143022 ~/.CLAUDE.md
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Disable symlink:** Use the exclude command or add to config manually:
|
|
306
|
+
```bash
|
|
307
|
+
ai-rules exclude add "~/.claude/settings.json"
|
|
308
|
+
# Or edit manually: ai-rules config edit
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
**Override not applying:** Rebuild the merged settings cache:
|
|
312
|
+
```bash
|
|
313
|
+
ai-rules install --rebuild-cache
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
**View merged settings:** Check what's actually being applied:
|
|
317
|
+
```bash
|
|
318
|
+
ai-rules config show --merged
|
|
319
|
+
ai-rules config show --merged --agent claude
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
## License
|
|
323
|
+
|
|
324
|
+
MIT
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# AI Rules
|
|
2
|
+
|
|
3
|
+
Manage AI agent configurations through symlinks. Keep all your configs in one git-tracked location.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/wpfleger96/ai-rules/graphs/contributors)
|
|
6
|
+
[](https://github.com/wpfleger96/ai-rules/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Consolidates config files for AI coding agents (Claude Code, Goose) into a single source of truth via symlinks:
|
|
11
|
+
|
|
12
|
+
- Git-tracked configs synced across machines
|
|
13
|
+
- Edit once, apply everywhere
|
|
14
|
+
- Exclude specific files (e.g., company-managed)
|
|
15
|
+
- Per-agent customizations
|
|
16
|
+
|
|
17
|
+
**Supported:** Claude Code (settings, agents, commands), Goose (hints, config), Shared (AGENTS.md)
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
**Requirements:** Python 3.10+, [uv](https://github.com/astral-sh/uv)
|
|
22
|
+
|
|
23
|
+
### From PyPI (Recommended)
|
|
24
|
+
|
|
25
|
+
One-command setup from PyPI:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
uvx ai-agent-rules setup
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
This will:
|
|
32
|
+
1. Install AI agent configuration symlinks
|
|
33
|
+
2. Make `ai-rules` available system-wide
|
|
34
|
+
|
|
35
|
+
After setup, you can run `ai-rules` from any directory.
|
|
36
|
+
|
|
37
|
+
### Local Development
|
|
38
|
+
|
|
39
|
+
For contributing or local development:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
git clone https://github.com/wpfleger96/ai-rules.git
|
|
43
|
+
cd ai-rules
|
|
44
|
+
uv tool install -e .
|
|
45
|
+
ai-rules install
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Updating
|
|
49
|
+
|
|
50
|
+
Check for and install updates:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
ai-rules upgrade # Check and install updates
|
|
54
|
+
ai-rules upgrade --check # Only check for updates
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Auto-update checks run weekly by default. Configure in `~/.ai-rules/update_config.yaml`:
|
|
58
|
+
|
|
59
|
+
```yaml
|
|
60
|
+
enabled: true
|
|
61
|
+
frequency: weekly # daily, weekly, never
|
|
62
|
+
notify_only: false
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
### User-Level Configuration
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
ai-rules setup # One-time setup: install symlinks + make available system-wide
|
|
71
|
+
ai-rules upgrade # Upgrade to latest version
|
|
72
|
+
ai-rules upgrade --check # Check for updates without installing
|
|
73
|
+
|
|
74
|
+
ai-rules install # Install all agent configs
|
|
75
|
+
ai-rules install --agents claude # Install specific agents
|
|
76
|
+
ai-rules install --dry-run # Preview changes
|
|
77
|
+
ai-rules install --force # Skip confirmations
|
|
78
|
+
ai-rules install --rebuild-cache # Rebuild merged settings cache
|
|
79
|
+
|
|
80
|
+
ai-rules status # Check symlink status (✓✗⚠○)
|
|
81
|
+
ai-rules diff # Show config differences
|
|
82
|
+
ai-rules validate # Verify source files exist
|
|
83
|
+
ai-rules update # Re-sync after adding files
|
|
84
|
+
ai-rules uninstall # Remove all symlinks
|
|
85
|
+
ai-rules list-agents # Show available agents
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Configuration Management
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# Interactive wizard for first-time setup
|
|
92
|
+
ai-rules config init # Start configuration wizard
|
|
93
|
+
|
|
94
|
+
# View configuration
|
|
95
|
+
ai-rules config show # Show raw config files
|
|
96
|
+
ai-rules config show --merged # Show merged settings with overrides
|
|
97
|
+
ai-rules config show --agent claude # Show config for specific agent
|
|
98
|
+
ai-rules config edit # Edit user config in $EDITOR
|
|
99
|
+
|
|
100
|
+
# Manage exclusions
|
|
101
|
+
ai-rules exclude add "~/.claude/*.json" # Add exclusion pattern (supports globs)
|
|
102
|
+
ai-rules exclude remove "~/.claude/*.json" # Remove exclusion pattern
|
|
103
|
+
ai-rules exclude list # List all exclusions
|
|
104
|
+
|
|
105
|
+
# Manage settings overrides (for machine-specific settings)
|
|
106
|
+
ai-rules override set claude.model "claude-sonnet-4-5-20250929" # Set simple override
|
|
107
|
+
ai-rules override set claude.hooks.SubagentStop[0].hooks[0].command "script.py" # Array notation
|
|
108
|
+
ai-rules override unset claude.model # Remove override
|
|
109
|
+
ai-rules override list # List all overrides
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Configuration
|
|
113
|
+
|
|
114
|
+
### Quick Start with Config Wizard
|
|
115
|
+
|
|
116
|
+
Run the interactive configuration wizard for guided setup:
|
|
117
|
+
|
|
118
|
+
```bash
|
|
119
|
+
ai-rules config init
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
This will walk you through:
|
|
123
|
+
1. Selecting common exclusions
|
|
124
|
+
2. Adding custom exclusion patterns (with glob support)
|
|
125
|
+
3. Setting up machine-specific settings overrides
|
|
126
|
+
|
|
127
|
+
### User-Level Config
|
|
128
|
+
|
|
129
|
+
Create `~/.ai-rules-config.yaml` for user-level settings:
|
|
130
|
+
|
|
131
|
+
```yaml
|
|
132
|
+
version: 1
|
|
133
|
+
|
|
134
|
+
# Global exclusions (apply to all contexts)
|
|
135
|
+
# Supports glob patterns: *.json, **/*.yaml, etc.
|
|
136
|
+
exclude_symlinks:
|
|
137
|
+
- "~/.config/goose/config.yaml"
|
|
138
|
+
- "~/.claude/*.log" # Glob: exclude all log files
|
|
139
|
+
- "~/.claude/agents/debug-*.md" # Glob: exclude debug agents
|
|
140
|
+
|
|
141
|
+
# Machine-specific settings overrides
|
|
142
|
+
# Keeps repo settings.json synced via git, but allows local overrides
|
|
143
|
+
settings_overrides:
|
|
144
|
+
claude:
|
|
145
|
+
model: "claude-sonnet-4-5-20250929" # Override model on personal laptop
|
|
146
|
+
# Other settings inherited from repo config/claude/settings.json
|
|
147
|
+
goose:
|
|
148
|
+
provider: "anthropic"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
**Config File Locations:**
|
|
152
|
+
- `~/.ai-rules-config.yaml` - User-specific config (exclusions and overrides)
|
|
153
|
+
- `<repo>/.ai-rules-config.yaml` - Repo defaults (global exclusions only)
|
|
154
|
+
|
|
155
|
+
**Config Precedence:**
|
|
156
|
+
- User config exclusions + Repo config exclusions = Combined (additive)
|
|
157
|
+
- Settings overrides only loaded from user config (machine-specific, not in git)
|
|
158
|
+
|
|
159
|
+
### Settings Overrides - Syncing Configs Across Machines
|
|
160
|
+
|
|
161
|
+
**Problem:** You want to sync your `settings.json` via git, but need different settings on different machines (e.g., different model access on work vs personal laptop).
|
|
162
|
+
|
|
163
|
+
**Solution:** Use `settings_overrides` in your user config:
|
|
164
|
+
|
|
165
|
+
```yaml
|
|
166
|
+
# ~/.ai-rules-config.yaml on personal laptop
|
|
167
|
+
settings_overrides:
|
|
168
|
+
claude:
|
|
169
|
+
model: "claude-sonnet-4-5-20250929" # No Opus access
|
|
170
|
+
|
|
171
|
+
# ~/.ai-rules-config.yaml on work laptop
|
|
172
|
+
settings_overrides:
|
|
173
|
+
claude:
|
|
174
|
+
model: "claude-opus-4-20250514" # Has Opus access
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Both machines sync the same `config/claude/settings.json` via git, but each has different local overrides. The system merges them at install time:
|
|
178
|
+
|
|
179
|
+
1. **Base settings** from `config/claude/settings.json` (git-tracked)
|
|
180
|
+
2. **Merged with** overrides from `~/.ai-rules-config.yaml` (local only)
|
|
181
|
+
3. **Cached** in `~/.ai-rules/cache/claude/settings.json`
|
|
182
|
+
4. **Symlinked** to `~/.claude/settings.json`
|
|
183
|
+
|
|
184
|
+
After changing overrides, run:
|
|
185
|
+
```bash
|
|
186
|
+
ai-rules install --rebuild-cache
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
#### Array Notation for Nested Settings
|
|
190
|
+
|
|
191
|
+
Override commands support array index notation for complex nested structures:
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
# Override nested array elements (e.g., hooks)
|
|
195
|
+
ai-rules override set claude.hooks.SubagentStop[0].hooks[0].command "uv run ~/my-hook.py"
|
|
196
|
+
|
|
197
|
+
# Override environment variables
|
|
198
|
+
ai-rules override set claude.env.MY_VAR "value"
|
|
199
|
+
|
|
200
|
+
# The system validates paths and provides helpful suggestions
|
|
201
|
+
ai-rules override set claude.modle "sonnet"
|
|
202
|
+
# Error: Key 'modle' not found at 'modle'
|
|
203
|
+
# Available options: model, env, hooks, statusLine, ...
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Path validation ensures you only set valid overrides that exist in the base settings, preventing typos and configuration errors.
|
|
207
|
+
|
|
208
|
+
## Structure
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
config/
|
|
212
|
+
├── AGENTS.md # User-level rules → ~/AGENTS.md, ~/.CLAUDE.md, ~/.config/goose/.goosehints
|
|
213
|
+
├── claude/
|
|
214
|
+
│ ├── settings.json # → ~/.claude/settings.json
|
|
215
|
+
│ ├── agents/*.md # → ~/.claude/agents/*.md (dynamic)
|
|
216
|
+
│ └── commands/*.md # → ~/.claude/commands/*.md (dynamic)
|
|
217
|
+
└── goose/
|
|
218
|
+
└── config.yaml # → ~/.config/goose/config.yaml
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## Extending
|
|
222
|
+
|
|
223
|
+
**Add Claude agent/command:**
|
|
224
|
+
1. Create `config/claude/agents/my-agent.md` or `config/claude/commands/my-cmd.md`
|
|
225
|
+
2. Run `ai-rules update`
|
|
226
|
+
|
|
227
|
+
**Add new AI tool:**
|
|
228
|
+
1. Add configs to `config/<tool>/`
|
|
229
|
+
2. Implement `ai_rules/agents/<tool>.py`
|
|
230
|
+
3. Register in `ai_rules/cli.py::get_agents()`
|
|
231
|
+
|
|
232
|
+
## Safety
|
|
233
|
+
|
|
234
|
+
- First-run warnings
|
|
235
|
+
- Timestamped backups (`*.ai-rules-backup.YYYYMMDD-HHMMSS`)
|
|
236
|
+
- Interactive prompts and dry-run mode
|
|
237
|
+
- Only manages symlinks (never deletes real files)
|
|
238
|
+
- Contextual error messages with tips
|
|
239
|
+
|
|
240
|
+
## Development
|
|
241
|
+
|
|
242
|
+
### Running Tests
|
|
243
|
+
The test suite includes both unit tests and integration tests.
|
|
244
|
+
|
|
245
|
+
The pytest-cov args are optional, use them to include a test coverage report in the output. To run all tests:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
uv run pytest [--cov=src --cov-report=term-missing]
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
To only run unit tests:
|
|
252
|
+
```bash
|
|
253
|
+
uv run pytest -m unit
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
To only run integration tests:
|
|
257
|
+
```bash
|
|
258
|
+
uv run pytest -m integration
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Troubleshooting
|
|
262
|
+
|
|
263
|
+
**Wrong target:** `ai-rules status` then `ai-rules install --force`
|
|
264
|
+
|
|
265
|
+
**Restore backup:**
|
|
266
|
+
```bash
|
|
267
|
+
ls -la ~/.CLAUDE.md.ai-rules-backup.*
|
|
268
|
+
mv ~/.CLAUDE.md.ai-rules-backup.20250104-143022 ~/.CLAUDE.md
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
**Disable symlink:** Use the exclude command or add to config manually:
|
|
272
|
+
```bash
|
|
273
|
+
ai-rules exclude add "~/.claude/settings.json"
|
|
274
|
+
# Or edit manually: ai-rules config edit
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Override not applying:** Rebuild the merged settings cache:
|
|
278
|
+
```bash
|
|
279
|
+
ai-rules install --rebuild-cache
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
**View merged settings:** Check what's actually being applied:
|
|
283
|
+
```bash
|
|
284
|
+
ai-rules config show --merged
|
|
285
|
+
ai-rules config show --merged --agent claude
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
MIT
|