Skip to main content

Manage user-level AI agent configurations

Project description

AI Rules

Manage AI agent configurations through symlinks. Keep all your configs in one git-tracked location.

PyPI Downloads PyPI version Python Versions CI GitHub Contributors Lines of Code License

Overview

Consolidates config files for AI coding agents (Claude Code, Goose) into a single source of truth via symlinks:

  • Git-tracked configs synced across machines
  • Edit once, apply everywhere
  • Exclude specific files (e.g., company-managed)
  • Per-agent customizations

Supported: Claude Code (settings, agents, commands), Goose (hints, config), Shared (AGENTS.md)

Installation

Requirements: Python 3.10+, uv

From PyPI (Recommended)

One-command setup from PyPI:

uvx --from ai-agent-rules ai-rules setup

This will:

  1. Install AI agent configuration symlinks
  2. Make ai-rules available system-wide

After setup, you can run ai-rules from any directory.

Local Development

For contributing or local development:

git clone https://github.com/wpfleger96/ai-rules.git
cd ai-rules
uv tool install -e .
ai-rules install

Updating

Check for and install updates:

ai-rules upgrade              # Check and install updates
ai-rules upgrade --check      # Only check for updates

Auto-update checks run weekly by default. Configure in ~/.ai-rules/update_config.yaml:

enabled: true
frequency: weekly  # daily, weekly, never
notify_only: false

Usage

User-Level Configuration

ai-rules setup                      # One-time setup: install symlinks + make available system-wide
ai-rules upgrade                    # Upgrade to latest version
ai-rules upgrade --check            # Check for updates without installing

ai-rules install                    # Install all agent configs
ai-rules install --agents claude    # Install specific agents
ai-rules install --dry-run          # Preview changes
ai-rules install --force            # Skip confirmations
ai-rules install --rebuild-cache    # Rebuild merged settings cache

ai-rules status                     # Check symlink status (✓✗⚠○)
ai-rules diff                       # Show config differences
ai-rules validate                   # Verify source files exist
ai-rules update                     # Re-sync after adding files
ai-rules uninstall                  # Remove all symlinks
ai-rules list-agents                # Show available agents

Configuration Management

# Interactive wizard for first-time setup
ai-rules config init                # Start configuration wizard

# View configuration
ai-rules config show                # Show raw config files
ai-rules config show --merged       # Show merged settings with overrides
ai-rules config show --agent claude # Show config for specific agent
ai-rules config edit                # Edit user config in $EDITOR

# Manage exclusions
ai-rules exclude add "~/.claude/*.json"      # Add exclusion pattern (supports globs)
ai-rules exclude remove "~/.claude/*.json"   # Remove exclusion pattern
ai-rules exclude list                        # List all exclusions

# Manage settings overrides (for machine-specific settings)
ai-rules override set claude.model "claude-sonnet-4-5-20250929"  # Set simple override
ai-rules override set claude.hooks.SubagentStop[0].hooks[0].command "script.py"  # Array notation
ai-rules override unset claude.model         # Remove override
ai-rules override list                       # List all overrides

Configuration

Quick Start with Config Wizard

Run the interactive configuration wizard for guided setup:

ai-rules config init

This will walk you through:

  1. Selecting common exclusions
  2. Adding custom exclusion patterns (with glob support)
  3. Setting up machine-specific settings overrides

User-Level Config

Create ~/.ai-rules-config.yaml for user-level settings:

version: 1

# Global exclusions (apply to all contexts)
# Supports glob patterns: *.json, **/*.yaml, etc.
exclude_symlinks:
  - "~/.config/goose/config.yaml"
  - "~/.claude/*.log"              # Glob: exclude all log files
  - "~/.claude/agents/debug-*.md"  # Glob: exclude debug agents

# Machine-specific settings overrides
# Keeps repo settings.json synced via git, but allows local overrides
settings_overrides:
  claude:
    model: "claude-sonnet-4-5-20250929"  # Override model on personal laptop
    # Other settings inherited from base config/claude/settings.json
  goose:
    provider: "anthropic"

Config File Location:

  • ~/.ai-rules-config.yaml - User-specific config (exclusions and overrides)

Settings Overrides - Syncing Configs Across Machines

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).

Solution: Use settings_overrides in your user config:

# ~/.ai-rules-config.yaml on personal laptop
settings_overrides:
  claude:
    model: "claude-sonnet-4-5-20250929"  # No Opus access

# ~/.ai-rules-config.yaml on work laptop
settings_overrides:
  claude:
    model: "claude-opus-4-20250514"  # Has Opus access

Both machines sync the same config/claude/settings.json via git, but each has different local overrides. The system merges them at install time:

  1. Base settings from config/claude/settings.json (git-tracked)
  2. Merged with overrides from ~/.ai-rules-config.yaml (local only)
  3. Cached in ~/.ai-rules/cache/claude/settings.json
  4. Symlinked to ~/.claude/settings.json

After changing overrides, run:

ai-rules install --rebuild-cache

Array Notation for Nested Settings

Override commands support array index notation for complex nested structures:

# Override nested array elements (e.g., hooks)
ai-rules override set claude.hooks.SubagentStop[0].hooks[0].command "uv run ~/my-hook.py"

# Override environment variables
ai-rules override set claude.env.MY_VAR "value"

# The system validates paths and provides helpful suggestions
ai-rules override set claude.modle "sonnet"
# Error: Key 'modle' not found at 'modle'
# Available options: model, env, hooks, statusLine, ...

Path validation ensures you only set valid overrides that exist in the base settings, preventing typos and configuration errors.

Structure

config/
├── AGENTS.md              # User-level rules → ~/AGENTS.md, ~/.CLAUDE.md, ~/.config/goose/.goosehints
├── claude/
│   ├── settings.json      # → ~/.claude/settings.json
│   ├── agents/*.md        # → ~/.claude/agents/*.md (dynamic)
│   └── commands/*.md      # → ~/.claude/commands/*.md (dynamic)
└── goose/
    └── config.yaml        # → ~/.config/goose/config.yaml

Extending

Add Claude agent/command:

  1. Create config/claude/agents/my-agent.md or config/claude/commands/my-cmd.md
  2. Run ai-rules update

Add new AI tool:

  1. Add configs to config/<tool>/
  2. Implement ai_rules/agents/<tool>.py
  3. Register in ai_rules/cli.py::get_agents()

Safety

  • First-run warnings
  • Timestamped backups (*.ai-rules-backup.YYYYMMDD-HHMMSS)
  • Interactive prompts and dry-run mode
  • Only manages symlinks (never deletes real files)
  • Contextual error messages with tips

Development

Running Tests

The test suite includes both unit tests and integration tests.

The pytest-cov args are optional, use them to include a test coverage report in the output. To run all tests:

uv run pytest [--cov=src --cov-report=term-missing]

To only run unit tests:

uv run pytest -m unit

To only run integration tests:

uv run pytest -m integration

Troubleshooting

Wrong target: ai-rules status then ai-rules install --force

Restore backup:

ls -la ~/.CLAUDE.md.ai-rules-backup.*
mv ~/.CLAUDE.md.ai-rules-backup.20250104-143022 ~/.CLAUDE.md

Disable symlink: Use the exclude command or add to config manually:

ai-rules exclude add "~/.claude/settings.json"
# Or edit manually: ai-rules config edit

Override not applying: Rebuild the merged settings cache:

ai-rules install --rebuild-cache

View merged settings: Check what's actually being applied:

ai-rules config show --merged
ai-rules config show --merged --agent claude

License

MIT

Project details


Release history Release notifications | RSS feed

This version

0.5.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_agent_rules-0.5.2.tar.gz (75.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_agent_rules-0.5.2-py3-none-any.whl (89.1 kB view details)

Uploaded Python 3

File details

Details for the file ai_agent_rules-0.5.2.tar.gz.

File metadata

  • Download URL: ai_agent_rules-0.5.2.tar.gz
  • Upload date:
  • Size: 75.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ai_agent_rules-0.5.2.tar.gz
Algorithm Hash digest
SHA256 5abe8140362feb368538471e8c6f973799fc4126e0d816b1ec7aedc5bfe7da2f
MD5 c023e03ee676e89b065150af34cc9e99
BLAKE2b-256 0297ea7a6cd25cc313c07ce5c0328c09909748bddc6ce13d8652f85924b9c2ea

See more details on using hashes here.

File details

Details for the file ai_agent_rules-0.5.2-py3-none-any.whl.

File metadata

  • Download URL: ai_agent_rules-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 89.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for ai_agent_rules-0.5.2-py3-none-any.whl
Algorithm Hash digest
SHA256 21c5445fb5a5258b91c94020bf8eab9cc96e805b27a291b336dde562306e9b3e
MD5 accf7133a9668dc8ab34b8ae21b69bce
BLAKE2b-256 e79ffffa77e14c3c05d4ae6426222256540482b55f8c6ff0c94b233cb0ff27e5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page