Use ai-rules CLI to manage and synchronize AI coding rules across multiple AI assistants (Cursor, Claude Code, GitHub Copilot, Opencode, etc.). Use when: (1) Setting up ai-rules in a new project, (2) Updating AI coding guidelines and best practices, (3) Generating platform-specific rule files from source, (4) Checking if generated files are in sync with source files, (5) Managing multi-agent rule consistency, or (6) Adding new rules or modifying existing ones. Requires ai-rules CLI installed. The ai-rules/ directory serves as the single source of truth for all AI coding guidelines.
Use ai-rules CLI to manage and synchronize AI coding rules across multiple AI assistants, maintaining a single source of truth for coding guidelines that works with Cursor, Claude Code, GitHub Copilot, Opencode, Gemini, and other AI coding agents.
curl -fsSL https://raw.githubusercontent.com/block/ai-rules/main/scripts/install.sh | bashai-rules/ directory should existCheck if ai-rules is installed:
ai-rules --version
Initialize ai-rules in a project:
ai-rules init
Generate platform-specific files:
ai-rules generate
Check sync status:
ai-rules status
Install ai-rules CLI:
curl -fsSL https://raw.githubusercontent.com/block/ai-rules/main/scripts/install.sh | bash
Initialize in project:
ai-rules init
This creates:
ai-rules/ directoryai-rules-config.yaml configuration fileConfigure agents:
Edit ai-rules/ai-rules-config.yaml:
agents: [claude, cursor, copilot, codex, opencode, gemini]
nested_depth: 0
gitignore: false
Generate initial files:
ai-rules generate
Edit source files in ai-rules/ directory:
ai-rules/my-new-rule.mdai-rules/react-router-7.mdai-rules/00-project-context.mdGenerate platform-specific files:
ai-rules generate
This automatically creates/updates:
CLAUDE.md - Rules for Claude CodeAGENTS.md - Rules for Opencode and other agents.cursor/rules/*.mdc - Rules for Cursor.github/copilot-instructions.md - Symlink for GitHub CopilotCheck all agents:
ai-rules status
Check specific agents:
ai-rules status --agents claude,cursor
Output interpretation:
in sync - Generated files match source filesout of sync - Source files modified, need regenerationUse in CI/CD:
ai-rules status || exit 1 # Fails if out of sync
Create new rule file in ai-rules/:
touch ai-rules/my-new-rule.md
Add rule content with optional frontmatter:
---
description: Context description for when to apply this rule
alwaysApply: true
fileMatching: "**/*.ts"
---
# My New Rule
Rule content here...
Generate platform files:
ai-rules generate
Verify sync:
ai-rules status
Edit source file in ai-rules/:
# Edit ai-rules/react-router-7.md
Regenerate platform files:
ai-rules generate
Commit both source and generated files:
git add ai-rules/ CLAUDE.md AGENTS.md .cursor/rules/
git commit -m "docs: update React Router v7 rules"
ai-rules init in repository rootai-rules-config.yaml for desired agentsai-rules generate to create platform filesRegular workflow:
ai-rules/ai-rules generate to syncai-rules status to verifyBefore major changes:
ai-rules statusai-rules generateai-rules status# Initialize ai-rules in current directory
ai-rules init
# Initialize with custom parameters (for custom recipes)
ai-rules init --params service=payments --params owner=checkout
# Force initialization without prompts
ai-rules init --force
# Generate rules for all configured agents
ai-rules generate
# Generate for specific agents only
ai-rules generate --agents claude,cursor
# Generate with nested directory scanning
ai-rules generate --nested-depth 2
# Add generated files to .gitignore
ai-rules generate --gitignore
# Check sync status for all agents
ai-rules status
# Check specific agents
ai-rules status --agents claude,cursor
# Check with nested scanning
ai-rules status --nested-depth 1
# Remove all generated files (keeps source files)
ai-rules clean
# Clean with nested scanning
ai-rules clean --nested-depth 2
# List all supported agents
ai-rules list-agents
ai-rules/ai-rules-config.yaml# List of agents to generate rules for
agents: [claude, cursor, copilot, codex, opencode, gemini]
# Agents to generate commands for (defaults to agents list)
command_agents: [claude, cursor]
# Maximum nested directory depth to scan for ai-rules/ folders
nested_depth: 0
# Whether to add generated files to .gitignore
gitignore: false
ai-rules-config.yaml)Claude Code Skills Mode:
use_claude_skills: true # Default: false
When enabled, rules with alwaysApply: false are generated as separate skills in .claude/skills/ instead of being included in CLAUDE.md.
---
description: Context description for when to apply this rule
alwaysApply: true
fileMatching: "**/*.ts"
---
# Rule Title
Rule content here...
Frontmatter fields:
description - Context description (optional)alwaysApply - true (always included) or false (optional/contextual) (default: true)fileMatching - Glob patterns for file matching (Cursor-specific)For simple setups, use a single AGENTS.md file without frontmatter:
AGENTS.mdai-rules/ai-rules/ directoryai-rules/ai-rules generate to syncai-rules statusreact-router-7.md, testing-best-practices.md00-project-context.mdai-rules status regularly to catch sync issuesai-rules generate after any source file changesai-rules status in CI/CD to ensure syncAdd to .git/hooks/pre-commit:
#!/bin/bash
ai-rules status || (echo "AI rules out of sync. Run 'ai-rules generate'" && exit 1)
# .github/workflows/ai-rules.yml
- name: Check AI Rules Sync
run: ai-rules status || exit 1
- name: Generate AI Rules
run: ai-rules generate
ai-rules/ai-rules generate locallySymptom: ai-rules status shows "out of sync"
Solution:
ai-rules generate
Symptom: command not found: ai-rules
Solution:
curl -fsSL https://raw.githubusercontent.com/block/ai-rules/main/scripts/install.sh | bash
Symptom: Changes in ai-rules-config.yaml not taking effect
Solution:
ai-rules/ directory)Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer