CLI Reference¶
All AI-Rulez CLI commands and flags.
Command Overview¶
Core Commands¶
| Command | Description |
|---|---|
ai-rulez init |
Initialize V4 directory-based configuration |
ai-rulez generate |
Generate presets for specific profile |
ai-rulez validate |
Validate configuration |
ai-rulez migrate |
Migrate configuration versions (migrate v4 command) |
ai-rulez version |
Show version |
ai-rulez mcp |
Start MCP server |
ai-rulez builtins list |
List available built-in domains |
ai-rulez builtins show <name> |
Show bundled content for a built-in domain |
CRUD Commands (Configuration Management)¶
| Command | Description |
|---|---|
ai-rulez domain add/remove/list |
Manage domains |
ai-rulez add rule/context/skill |
Create content files |
ai-rulez remove rule/context/skill |
Delete content files |
ai-rulez list rules/context/skills |
List content files |
ai-rulez include add/remove/list |
Manage external includes |
ai-rulez skill install/remove/list |
Manage installed skills |
ai-rulez profile add/remove/list |
Manage profiles |
ai-rulez profile set-default |
Set default profile |
CRUD Commands¶
AI-Rulez provides CRUD commands to programmatically modify your V4 .ai-rulez/ configuration. These commands allow you to create domains, add rules/context/skills, manage includes, and organize profiles.
Domain Management¶
ai-rulez domain add <name> [flags]¶
Create a new domain with subdirectories for rules, context, and skills.
Syntax:
Arguments:
<name>(required): Domain name. Alphanumeric and underscores, 1-50 characters.
Flags:
--description <text>/-s(optional): Description of the domain
Examples:
Create a backend domain:
Create a domain with description:
ai-rulez domain remove <name> [flags]¶
Delete a domain and all its contents.
Syntax:
Arguments:
<name>(required): Domain name to delete
Flags:
--force/-f(optional): Skip confirmation prompt
Examples:
Remove a domain (with confirmation):
Remove without confirmation:
ai-rulez domain list [flags]¶
List all domains in the .ai-rulez/ directory.
Syntax:
Flags:
--json/-j(optional): Output as JSON
Examples:
List domains:
List as JSON:
Content Management¶
Rules, context, and skills can be added to the root (always included) or to specific domains (profile-dependent).
ai-rulez add rule <name> [flags]¶
Create a new rule file with optional YAML frontmatter.
Syntax:
Arguments:
<name>(required): Rule filename without.mdextension
Flags:
--domain <name>/-d(optional): Domain name. If not specified, creates in root rules directory--priority <level>/-p(optional): Priority: critical, high, medium, low. Default: medium--targets <list>/-t(optional): Comma-separated list of target providers (claude, cursor, etc.)--content <text>/-c(optional): Rule content. Uses a template if omitted.
Examples:
Create a root rule:
Create a domain-specific rule:
Create with specific targets:
ai-rulez add context <name> [flags]¶
Create a new context file (documentation/reference material).
Syntax:
Arguments:
<name>(required): Context filename without.mdextension
Flags:
--domain <name>/-d(optional): Domain name. If not specified, creates in root context directory--priority <level>/-p(optional): Priority: critical, high, medium, low. Default: medium--content <text>/-c(optional): Context content. Uses a template if omitted.
Examples:
Create root context:
Create domain context:
ai-rulez add skill <name> [flags]¶
Create a new skill file (AI prompt/expert definition).
Syntax:
Arguments:
<name>(required): Skill filename without.mdextension
Flags:
--domain <name>/-d(optional): Domain name. If not specified, creates in root skills directory--description <text>/-s(optional): Skill description--content <text>/-c(optional): Skill content. Uses a template if omitted.
Examples:
Create a root skill:
Create a domain-specific skill:
ai-rulez remove rule <name> [flags]¶
Delete a rule file.
Syntax:
Arguments:
<name>(required): Rule filename without.mdextension
Flags:
--domain <name>/-d(optional): Domain name--force/-f(optional): Skip confirmation
Examples:
Remove a root rule:
Remove a domain rule:
ai-rulez remove context <name> [flags]¶
Delete a context file.
Syntax:
Arguments:
<name>(required): Context filename without.mdextension
Flags:
--domain <name>/-d(optional): Domain name--force/-f(optional): Skip confirmation
Examples:
ai-rulez remove context architecture
ai-rulez remove context backend-design --domain backend --force
ai-rulez remove skill <name> [flags]¶
Delete a skill file.
Syntax:
Arguments:
<name>(required): Skill filename without.mdextension
Flags:
--domain <name>/-d(optional): Domain name--force/-f(optional): Skip confirmation
Examples:
ai-rulez remove skill code-reviewer
ai-rulez remove skill performance-optimizer --domain backend --force
ai-rulez list rules [flags]¶
List all rule files.
Syntax:
Flags:
--domain <name>/-d(optional): List rules in specific domain only--json/-j(optional): Output as JSON
Examples:
List all rules:
List domain rules:
ai-rulez list context [flags]¶
List all context files.
Syntax:
Flags:
--domain <name>/-d(optional): List context in specific domain only--json/-j(optional): Output as JSON
Examples:
ai-rulez list skills [flags]¶
List all skill files.
Syntax:
Flags:
--domain <name>/-d(optional): List skills in specific domain only--json/-j(optional): Output as JSON
Examples:
Installed Skill Management¶
Install named skills from external repositories. See Installed Skills for full details.
ai-rulez skill install <name> --source <url> [flags]¶
Install a named skill from a git repository or local path.
Arguments:
<name>(required): Skill name (unique identifier)
Flags:
--source <url>/-s(required): Git URL or local path--path <dir>/-p(optional): Path within repo to skill directory (defaults toskills/<name>)--ref <ref>/-r(optional): Git reference (branch, tag, commit)
Examples:
ai-rulez skill install kreuzberg --source https://github.com/kreuzberg-dev/kreuzberg
ai-rulez skill install my-lib --source https://github.com/org/repo --path custom/path --ref v2.0
ai-rulez skill install local-skill --source ../my-other-repo
ai-rulez skill remove <name> [flags]¶
Remove an installed skill from the configuration.
Arguments:
<name>(required): Skill name to remove
Flags:
--force/-f(optional): Skip confirmation prompt
Examples:
ai-rulez skill list [flags]¶
List all installed skills.
Flags:
--json/-j(optional): Output as JSON
Examples:
Include Management¶
Manage external rule sources (git repositories or local packages).
ai-rulez include add <name> <source> [flags]¶
Add a new include source to the configuration.
Syntax:
Arguments:
<name>(required): Unique identifier for this include<source>(required): Git URL (e.g.,https://github.com/org/repo) or local path (e.g.,./packages/shared)
Flags:
--path <dir>/-p(optional): Path within git repository where.ai-rulez/content is located--ref <branch>/-r(optional): Git reference (branch, tag, commit). Default: main--include <types>/-i(optional): Comma-separated content types: rules,context,skills,mcp--merge-strategy <strategy>/-m(optional): Merge strategy: default, override, append--install-to <path>/-t(optional): Installation target path in.ai-rulez/
Examples:
Add a git-based include:
Add with custom path and ref:
Add local include:
ai-rulez include remove <name> [flags]¶
Remove an include source.
Syntax:
Arguments:
<name>(required): Include name to remove
Flags:
--force/-f(optional): Skip confirmation
Examples:
ai-rulez include list [flags]¶
List all include sources.
Syntax:
Flags:
--json/-j(optional): Output as JSON
Examples:
Profile Management¶
Organize domains into named profiles for targeted generation.
ai-rulez profile add <name> <domains...> [flags]¶
Create a new profile.
Syntax:
Arguments:
<name>(required): Profile name<domains...>(required): Space-separated list of domain names to include
Flags:
--set-default/-s(optional): Set this as the default profile
Examples:
Create a backend profile:
Create and set as default:
ai-rulez profile remove <name> [flags]¶
Delete a profile.
Syntax:
Arguments:
<name>(required): Profile name to remove
Flags:
--force/-f(optional): Skip confirmation
Examples:
ai-rulez profile set-default <name> [flags]¶
Set a profile as the default for generation.
Syntax:
Arguments:
<name>(required): Profile name to set as default
Examples:
ai-rulez profile list [flags]¶
List all profiles.
Syntax:
Flags:
--json/-j(optional): Output as JSON
Examples:
Builtins Command¶
ai-rulez builtins list [flags]¶
List all built-in domains embedded in the ai-rulez binary.
Flags:
--json/-j(optional): Output as JSON
ai-rulez builtins show <name> [flags]¶
Show the full rules, context, skills, agents, and commands for a built-in domain.
Arguments:
<name>(required): Built-in domain name, such assecurity,go, ortypescript
Flags:
--json/-j(optional): Output as JSON
Initialization Command¶
ai-rulez init [project-name]¶
Initialize a new V4 directory-based configuration.
Syntax:
Arguments:
[project-name](optional): The project name. If not provided, prompted interactively.
V4-specific Flags:
| Flag | Type | Default | Description |
|---|---|---|---|
--format / -f |
string | toml |
Configuration format: toml, yaml, or json |
--domains / -d |
string | (none) | Comma-separated list of domain names to create |
--skip-content / -s |
boolean | false | Skip creating example content files |
--from / -F |
string | (none) | Import from existing tool files, such as auto or .claude,.cursor |
--setup-hooks / -H |
boolean | false | Configure Git hooks after initialization |
--yes / -y |
boolean | false | Automatically answer yes to prompts |
General Flags:
| Flag | Type | Description |
|---|---|---|
--verbose |
boolean | Enable verbose output |
--debug |
boolean | Enable debug output |
Examples:
Basic V4 initialization (TOML format):
V4 with YAML format:
V4 with multiple domains:
V4 with example content skipped:
Generate Command¶
ai-rulez generate [config-path]¶
Generate AI assistant rule files from configuration.
Syntax:
Arguments:
[config-path](optional): Path to configuration file or directory. If not provided, auto-detected.
Generation Flags:
| Flag | Type | Default | Description |
|---|---|---|---|
--profile / -p |
string | (from config) | Profile to generate |
General Flags:
| Flag | Type | Default | Description |
|---|---|---|---|
--dry-run / -d |
boolean | false | Show what would be generated without writing files |
--gitignore / -i |
boolean | (from config) | Update .gitignore with generated output patterns |
--recursive / -r |
boolean | false | Find and process configs recursively |
--no-fetch / -f |
boolean | false | Skip fetching remote includes and use cached content |
--config-dir / -n |
string | .ai-rulez |
Configuration directory name for non-default layouts |
--env / -e |
string | MCP env override in KEY=VALUE form; repeatable |
|
--env-file / -E |
string | .env |
Dotenv file for MCP env placeholders; repeatable |
--no-configure-cli-mcp / -M |
boolean | false | Skip configuring CLI-based MCP tools such as Claude and Gemini |
--skip-cli-mcp / -S |
boolean | false | Alias for --no-configure-cli-mcp |
--token / -T |
string | (from env) | Git access token for private repositories (or use AI_RULEZ_GIT_TOKEN env var) |
--update-gitignore still works as a hidden deprecated alias for --gitignore for backward compatibility.
Examples:
Generate with default profile:
Generate specific profile:
Dry-run to preview generation:
Generate and update .gitignore:
Generate MCP configs with secret env values:
Generate recursively in monorepo:
Generate from a non-default configuration directory:
Generate with private repository authentication:
# Using environment variable (recommended)
export AI_RULEZ_GIT_TOKEN="ghp_your_github_token_here"
ai-rulez generate
# Using CLI flag
ai-rulez generate --token "ghp_your_github_token_here"
Profile Selection¶
When using profile-based configuration:
- No
--profileflag: Uses default profile from config --profile backend: Generates content for thebackendprofile- Invalid profile: Shows error and lists available profiles
Example with profile hierarchy:
# .ai-rulez/config.toml
default = "full"
[profiles]
full = ["backend", "frontend", "qa"]
backend = ["backend"]
frontend = ["frontend"]
# Uses "full" profile (default)
ai-rulez generate
# Uses "backend" profile only
ai-rulez generate --profile backend
# Uses "frontend" profile only
ai-rulez generate --profile frontend
Validation Command¶
ai-rulez validate [config-path]¶
Validate configuration without generating files.
Syntax:
Arguments:
[config-path](optional): Path to configuration file. If not provided, auto-detected.
Flags:
| Flag | Type | Description |
|---|---|---|
--config-dir |
string | Configuration directory name for non-default layouts |
--verbose |
boolean | Enable verbose output |
--debug |
boolean | Enable debug output |
Examples:
Validate current configuration:
Validate specific config file:
With verbose output:
What Gets Validated¶
versionis"3.0"or"4.0"nameis present and non-empty- All preset names are valid
- Referenced domains exist in filesystem
- Profile definitions reference valid domains
- File paths are accessible
Migrate Command¶
ai-rulez migrate v4¶
Migrate configuration from V3 (YAML) to V4 (TOML format).
Syntax:
Arguments:
v4,4, or4.0(required): Target configuration version.
The migrate command has no command-local flags.
Examples:
Migrate current directory:
What It Does:
- Finds
.ai-rulez/in the current directory - Returns without changes if
.ai-rulez/config.tomlalready exists - Loads the existing configuration, including legacy MCP files if present
- Writes
.ai-rulez/config.tomlwithversion = "4.0" - Removes old
.ai-rulez/config.yaml,.ai-rulez/config.json,.ai-rulez/mcp.yaml,.ai-rulez/mcp.toml, and.ai-rulez/mcp.jsonfiles
After Migration:
.ai-rulez/config.toml— new V4 configuration (TOML)- All other files remain unchanged
Then regenerate outputs:
Version Command¶
ai-rulez version¶
Show the current version and build information.
MCP Server¶
ai-rulez mcp¶
Starts the Model Context Protocol (MCP) server to allow AI assistants to programmatically interact with your configuration.
See the MCP Server Documentation for more details.
Global Flags¶
These flags work with all commands:
| Flag | Type | Description |
|---|---|---|
--config / -C |
string | Config file path (auto-discovered if not specified) |
--token / -T |
string | Git access token for private repositories (or use AI_RULEZ_GIT_TOKEN env var) |
--verbose / -V |
boolean | Enable verbose output |
--debug / -D |
boolean | Enable debug output |
--quiet / -q |
boolean | Suppress progress bars and non-essential output |
--help / -h |
boolean | Show help for a command |
Most command-local flags also have shorthands. Common mappings are --domain -d, --force -f,
--json -j, --priority -p, --targets -t, --content -c, --description -s, --path -p,
and --ref -r.
Examples:
Generate with debug output:
Quiet mode (minimal output):
Show help for init:
Configuration Detection¶
Commands that load a project directory use the following config order:
- Explicit path: Via
--configflag or command argument - Directory config:
.ai-rulez/config.toml,.ai-rulez/config.yaml, or.ai-rulez/config.json - Error: No configuration found
Legacy flat V2 config files such as ai-rulez.yaml are migration inputs. Use ai-rulez migrate v4
before running V4 generation workflows.
Example detection flow:
cd /path/to/project
# Detects .ai-rulez/ if it exists
ai-rulez generate
# Use explicit path
ai-rulez generate .ai-rulez/config.toml
# Specify config via flag
ai-rulez generate --config ./ai-policy/config.toml
Exit Codes¶
The CLI uses standard exit codes:
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error (config not found, validation failed, etc.) |
| 2 | Command syntax error (invalid flags, arguments) |
Output Examples¶
Initialize Output¶
✅ Created .ai-rulez/ directory structure
Directory structure:
.ai-rulez/
├── config.toml
├── rules/ # Base rules (always included)
├── context/ # Base context (always included)
├── skills/ # Base skills (always included)
├── agents/ # Base agents (always included)
└── domains/ # Domain-specific content
Example content created:
- rules/code-quality.md
- context/architecture.md
- skills/code-reviewer/SKILL.md
- skills/ai-rulez/SKILL.md
Domain directories created:
- domains/backend/
- domains/frontend/
- domains/qa/
Next steps:
1. Edit .ai-rulez/config.toml to customize presets and profiles
2. Add your rules, context, and skills to the appropriate directories
3. Run 'ai-rulez generate' to create tool-specific outputs
Generate Output¶
Validation Output¶
INFO Configuration is valid path=/path/to/project/.ai-rulez
INFO
Configuration summary:
INFO - Rules: count=5
INFO - Context files: count=10
INFO - Skills: count=8
INFO - Domains: count=9
INFO - Domain rules: count=35
INFO - Domain context: count=2
INFO - Presets: count=12
Validation Error¶
❌ Configuration validation failed
errors:
- Profile "backend" references undefined domain "backend"
- Preset "claude" not found
Run 'ai-rulez validate --verbose' for details
Common CRUD Workflows¶
Creating a Domain with Rules¶
# Create a domain
ai-rulez domain add backend --description "Backend services"
# Add rules to the domain
ai-rulez add rule database-standards --domain backend --priority high
ai-rulez add rule api-design --domain backend --priority high
# Add context
ai-rulez add context architecture --domain backend
# Validate and generate
ai-rulez validate
ai-rulez generate
Setting Up Team-Based Profiles¶
# Create domains for each team
ai-rulez domain add backend
ai-rulez domain add frontend
ai-rulez domain add qa
# Create team-specific profiles
ai-rulez profile add full backend frontend qa --set-default
ai-rulez profile add backend backend qa
ai-rulez profile add frontend frontend qa
# Generate for a specific profile
ai-rulez generate --profile backend
Adding External Rules from Git¶
# Add corporate rules include
ai-rulez include add corporate-rules https://github.com/myorg/shared-rules --ref main
# Verify include was added
ai-rulez include list
# Validate with included content
ai-rulez validate
# Regenerate with included content
ai-rulez generate
Managing Content Across Domains¶
# Add shared rule to root (always included)
ai-rulez add rule code-style --priority high
# Add domain-specific rule
ai-rulez add rule database-standards --domain backend --priority high
ai-rulez add rule accessibility --domain frontend --priority high
# List all rules
ai-rulez list rules
# List domain-specific rules
ai-rulez list rules --domain backend
ai-rulez list rules --domain frontend
# Remove a rule
ai-rulez remove rule old-guideline --force
Common Workflows¶
Set Up a New Project¶
# Initialize with domains
ai-rulez init "my-project" --domains "backend,frontend,qa"
# Review generated structure
ls -la .ai-rulez/
# Create/edit content files
# (edit .ai-rulez/rules/, .ai-rulez/context/, etc.)
# Validate configuration
ai-rulez validate
# Generate outputs
ai-rulez generate
Generate Multiple Profiles¶
# Generate full profile
ai-rulez generate --profile full
# Generate backend-only profile
ai-rulez generate --profile backend
# Generate frontend-only profile
ai-rulez generate --profile frontend
Update AI Configuration After Changes¶
# Edit your content
vim .ai-rulez/rules/my-rule.md
# Validate it's still correct
ai-rulez validate
# Regenerate outputs
ai-rulez generate
# Commit changes
git add .ai-rulez/ CLAUDE.md .cursor/ GEMINI.md
git commit -m "docs: update AI assistant guidelines"
CI/CD Integration¶
#!/bin/bash
# Simple CI/CD script
# Validate configuration
ai-rulez validate || exit 1
# Generate all outputs
ai-rulez generate || exit 1
# Check for uncommitted changes
if ! git diff --quiet CLAUDE.md .cursor/ GEMINI.md; then
echo "Generated files are out of sync"
echo "Run: ai-rulez generate"
exit 1
fi
Troubleshooting¶
Command not found¶
Configuration not found¶
# Check current directory
ls -la .ai-rulez/
ls -la .ai-rulez/config.toml
# Or specify explicitly
ai-rulez generate --config /path/to/.ai-rulez/config.toml
Invalid profile name¶
# List available profiles
ai-rulez validate --verbose
# Use a valid profile name
ai-rulez generate --profile backend
Generated files not updated¶
# Check if files were actually generated
ai-rulez generate --dry-run
# Force regeneration
rm CLAUDE.md .cursor/rules/*
ai-rulez generate
Help and Documentation¶
Get help for any command:
For more detailed documentation:
- Configuration Reference: Config options
- Quick Start: Getting started
- Domains & Profiles: Team organization