Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration

ruley supports hierarchical configuration from multiple sources. This page documents the configuration file format and precedence rules.

Configuration Precedence

Configuration is resolved in this order (highest to lowest precedence):

  1. CLI flags – Explicitly provided command-line arguments
  2. Environment variablesRULEY_* prefix (handled by clap’s env attribute)
  3. Config files – Loaded and merged in discovery order (see below)
  4. Built-in defaults – Hardcoded in the CLI parser

When a CLI flag is explicitly provided, it always wins. When it’s not provided (using the default), the config file value is used instead.

Config File Discovery

Config files are discovered and merged in this order (later overrides earlier):

  1. ~/.config/ruley/config.toml – User-level global config
  2. ruley.toml in the git repository root – Project-level config
  3. ./ruley.toml in the current directory – Working directory config
  4. Explicit --config <path> – If provided, overrides all above

All discovered files are merged. Duplicate keys in later files override earlier ones.

Configuration File Format

Configuration files use TOML format. All sections are optional.

Complete Example

[general]
provider = "anthropic"
model = "claude-sonnet-4-5-20250929"
format = ["cursor", "claude"]
compress = true
chunk_size = 100000
no_confirm = false
rule_type = "auto"

[output]
formats = ["cursor", "claude"]
on_conflict = "prompt"

[output.paths]
cursor = ".cursor/rules/project-rules.mdc"
claude = "CLAUDE.md"

[include]
patterns = ["**/*.rs", "**/*.toml"]

[exclude]
patterns = ["**/target/**", "**/node_modules/**"]

[chunking]
chunk_size = 100000
overlap = 10000

[providers.anthropic]
model = "claude-sonnet-4-5-20250929"
max_tokens = 8192

[providers.openai]
model = "gpt-4o"
max_tokens = 4096

[providers.ollama]
host = "http://localhost:11434"
model = "llama3.1:70b"

[providers.openrouter]
model = "anthropic/claude-3.5-sonnet"
max_tokens = 8192

[validation]
enabled = true
retry_on_failure = false
max_retries = 3

[validation.semantic]
check_file_paths = true
check_contradictions = true
check_consistency = true
check_reality = true

[finalization]
enabled = true
deconflict = true
normalize_formatting = true
inject_metadata = true

[general] Section

Core settings for the pipeline.

KeyTypeDefaultDescription
providerstring"anthropic"LLM provider name
modelstring(provider default)Model to use
formatstring[]["cursor"]Output formats
compressboolfalseEnable tree-sitter compression
chunk_sizeint100000Max tokens per LLM chunk
no_confirmboolfalseSkip cost confirmation
rule_typestring"auto"Cursor rule type

[output] Section

Output format and path configuration.

KeyTypeDefaultDescription
formatsstring[][]Alternative to general.format
on_conflictstring"prompt"Conflict resolution strategy
paths.<format>string(format default)Custom output path per format

[include] / [exclude] Sections

File filtering using glob patterns.

KeyTypeDefaultDescription
patternsstring[][]Glob patterns for file matching

[chunking] Section

Controls how large codebases are split for LLM processing.

KeyTypeDefaultDescription
chunk_sizeint100000Max tokens per chunk
overlapintchunk_size / 10Token overlap between chunks

[providers] Section

Provider-specific configuration. Each provider has its own subsection.

[providers.anthropic] / [providers.openai] / [providers.openrouter]:

KeyTypeDescription
modelstringModel name override
max_tokensintMax output tokens

[providers.ollama]:

KeyTypeDescription
hoststringOllama server URL
modelstringModel name

[validation] Section

Controls validation of generated rules.

KeyTypeDefaultDescription
enabledbooltrueEnable validation
retry_on_failureboolfalseAuto-retry with LLM fix
max_retriesint3Max auto-fix attempts

[validation.semantic] – Semantic validation checks:

KeyTypeDefaultDescription
check_file_pathsbooltrueVerify referenced file paths exist
check_contradictionsbooltrueDetect contradictory rules
check_consistencybooltrueCross-format consistency check
check_realitybooltrueVerify language/framework references

[finalization] Section

Controls post-processing of generated rules.

KeyTypeDefaultDescription
enabledbooltrueEnable finalization
deconflictbooltrueLLM-based deconfliction with existing rules
normalize_formattingbooltrueNormalize line endings and whitespace
inject_metadatabooltrueAdd timestamp/version/provider headers