Rule Discovery and Filtering
Rulebound discovers rules by recursively scanning the rules directory for .md files. You can then filter which rules apply using metadata and CLI options.
Rule Discovery
When you run any command that loads rules, Rulebound:
- Finds the rules directory (
.rulebound/rules/by default) - Recursively collects all
.mdfiles - Parses YAML front matter from each file
- Builds a rule list with IDs derived from file paths
The rules directory is found by checking these locations in order:
.rulebound/rules/rules/examples/rules/
You can override this with the --dir flag or rulesDir in config.json.
Filtering Rules
Use the find-rules command to filter rules:
# Filter by category
rulebound find-rules --category security
# Filter by tags
rulebound find-rules --tags "auth,api"
# Filter by tech stack
rulebound find-rules --stack typescript
# Filter by title search
rulebound find-rules --title "secrets"
# Filter by task description (semantic matching)
rulebound find-rules --task "add authentication endpoint"
Context-Aware Matching
When you run validate, diff, or ci, Rulebound does smart context matching:
- Stack matching -- Rules with
stackthat overlap with your project config get +3 score per match - Scope matching -- Rules with
scopethat overlap get +2 score per match - Team matching -- Rules with
teammatching your config get +1 - Global rules -- Rules without stack/scope/team always apply
- Task matching -- Words from the task description are matched against rule titles, tags, and categories
Rules are sorted by their match score so the most relevant rules are prioritized.
Directory Organization
Organize rules into subdirectories by category:
.rulebound/rules/
security/
no-secrets.md
input-validation.md
style/
naming-conventions.md
testing/
coverage-requirements.md
architecture/
api-patterns.md
The subdirectory name is used as the default category if the front matter does not specify one.
Ignoring Files
Only files with the .md extension are loaded as rules. Other file types (README, notes, drafts) are ignored unless they end in .md.
To exclude a rule without deleting it, move it outside the rules directory or rename it to a non-
.mdextension.