Skip to main content

Policy File (.rafter.yml)

The .rafter.yml file defines project-level security policies that override your global ~/.rafter/config.json settings. Place it in your project root and Rafter picks it up automatically.

How It Works

When any rafter agent command runs, the CLI walks from your current directory up to the git root looking for .rafter.yml or .rafter.yaml (also .rafter/config.yml / .rafter/config.yaml, read for compatibility with the hosted scanner’s config filename — if more than one exists, .rafter.yml/.rafter.yaml wins). If found, its values merge into the loaded config with policy file winning on conflicts — except for the fields in the precedence table below that are a floor the project can only tighten (command_policy.blocked_patterns/require_approval/allowed_patterns; see Command Execution), and audit.log_path, which a project file cannot set at all (see below). command_policy.blocked_patterns and command_policy.require_approval are unioned with the global config’s lists — a project can add restriction but can’t remove a global entry. scan.custom_patterns and scan.exclude_paths are additive the same way. Hardcoded defaults (the built-in exclusion list and the 28 secret patterns) always apply regardless of what the policy file sets. See the precedence table below for every field. The file is parsed and validated on every run: an unrecognized top-level key, an invalid enum value, or a malformed entry is dropped with a warning on stderr — it never aborts the command. If the file can’t be read or parsed at all (bad YAML, wrong permissions), the whole file is ignored with a warning naming the file and the error, and the command proceeds with default settings. Either way, nothing in the file can silently suppress a secret scan if it fails to load. The hosted scanner (rafter run, the GitHub app, the dashboard) reads the same file from the scanned commit — .rafter.yml first, then .rafter.yaml, .rafter/config.yml, .rafter/config.yaml — and honors scan.exclude_paths and ignore:. The other sections on this page (risk_level, command_policy, scan.custom_patterns, audit) affect only the local CLI. Write keys in snake_case, as on this page. The CLI reads only snake_case keys from .rafter.yml and skips a camelCase spelling such as excludePaths without a warning. The hosted scanner accepts both spellings; if a file carries both spellings of one key, it uses the snake_case one.

Full Schema

All sections are optional. Only specify what you need to override. Within an ignore: rule, paths is always required; reason is what lets a hosted scan suppress a must-fix or secret-scanner finding — see Suppressing Findings.
audit.log_path is not valid in a project .rafter.yml. It’s read only from the global config, ~/.rafter/config.json (agent.audit.logPath) — a project value is parsed but then ignored with a stderr warning, so every project logs to the same machine-wide location regardless of what its policy file says.

Custom Scan Patterns

Add organization-specific secret patterns that the 28 built-in patterns don’t cover:
Each pattern requires:
  • name: Human-readable identifier shown in scan output
  • regex: JavaScript-compatible regular expression
  • severity: critical, high, medium, or low
Custom patterns are added alongside the default patterns, not replacing them.

Exclude Paths

Skip directories during secret scanning:
These are directory names matched against path segments. The default exclusions (node_modules, .git, dist, build, .next, .trigger, coverage, .vscode, .idea, vendor, .venv, venv, __pycache__, .tox, .mypy_cache, .pytest_cache, .ruff_cache, .terraform, bower_components, results) always apply to the built-in patterns engine, on top of .gitignore when the scan target is in a git work tree. Your exclude_paths add to that list — see Secret Scanning for the full exclusion behavior. On hosted scans, exclude_paths drops ordinary findings in those paths but cannot hide a protected finding — one Rafter classifies as must-fix, one from a secret scanner, or an unclassified critical/high — because a path exclusion carries no reason. Such findings stay in the report. To suppress one of those, write an ignore: rule with a reason.

Command Policy Overrides

Add project-specific restrictions on top of whatever the machine owner has configured globally:
Both lists are unioned with the global config, not replaced — this project adds terraform apply to the commands that need approval without touching anything the owner already listed (rm -rf, sudo rm, git push --force, …). command_policy.mode can only be set here to something at least as strict as the global mode (approve-dangerous > deny-list > allow-all) — a looser value is dropped with a warning. Since the shipped default is already the strictest (approve-dangerous), setting mode from a project is rarely useful unless the machine owner has deliberately chosen a looser global mode and this project wants to opt back up. This is useful for monorepos or shared projects where one team needs extra approval gates beyond the machine-wide baseline — it is not a way to loosen what the machine owner configured; see Precedence Rules below.

Precedence Rules

A .rafter.yml lives in the repository, so it isn’t necessarily under the control of whoever is running Rafter against that checkout. So for everything that gates command execution, the machine owner’s global config (~/.rafter/config.json) is a floor that a project policy can only tighten, never loosen — unless the owner has explicitly set agent.commandPolicy.allowProjectOverride: true in that global config. That flag switches mode, blocked_patterns, require_approval, and allowed_patterns from floor/union semantics to a plain replace, letting the project set any of them to anything, including something looser than the global default. The flag is opt-in and lives only in the global config — a project .rafter.yml cannot set it for itself. Everything else merges with the project file winning on conflicts: A project policy with an out-of-bounds value doesn’t fail the command — it’s dropped with a warning and the stricter/global value is used instead.

Best Practices

Recommendations

  1. Commit .rafter.yml to version control so the whole team gets the same policies
  2. Use command_policy.require_approval/blocked_patterns to add project-specific gates — they add to the machine owner’s list rather than replacing it
  3. Add custom patterns for any organization-specific secret formats
  4. Use exclude_paths for vendored code or generated files
  5. Suppress confirmed false positives with ignore: and a reason, rather than loosening a pattern — see Suppressing Findings

Next Steps

Secret Scanning

Learn about scan options and output

Command Execution

Configure policy enforcement

Suppressing Findings

Hide a confirmed false positive with a reason

Audit Log

Where policy decisions get logged