Configuration Reference

June 11, 2026 · View on GitHub

Gaze is configured via a .gaze.yaml file in the project root. All settings are optional — Gaze ships with sensible defaults and works without a config file.

File Location

Gaze searches for .gaze.yaml in the current working directory. You can override this with the --config flag on commands that support it (analyze, quality, docscan).

If no config file is found, Gaze uses the default configuration silently (no error).

Complete Example

# .gaze.yaml — Gaze configuration
classification:
  thresholds:
    contractual: 80    # Confidence >= 80 → contractual
    incidental: 50     # Confidence < 50 → incidental
                       # 50–79 → ambiguous
  doc_scan:
    exclude:
      - "vendor/**"
      - "node_modules/**"
      - ".git/**"
      - "testdata/**"
      - "CHANGELOG.md"
      - "CONTRIBUTING.md"
      - "CODE_OF_CONDUCT.md"
      - "LICENSE"
      - "LICENSE.md"
    include: []        # Empty = scan all non-excluded files
    timeout: "30s"

baseline:
  file: .gaze/baseline.json   # Path to baseline file
  epsilon: 0.5                 # Minimum score delta for regression/improvement
  new_function_threshold: 30   # CRAP score above which a new function is a violation

Configuration Keys

classification

Top-level section for all classification-related settings.


classification.thresholds

Confidence score boundaries that determine how side effects are labeled.

KeyTypeDefaultValid RangeDescription
contractualint801–99Minimum confidence for the contractual label. Side effects with confidence scores at or above this value are classified as contractual.
incidentalint501–99Upper bound for the incidental label. Side effects with confidence scores below this value are classified as incidental.

Constraint: contractual must be strictly greater than incidental. If this constraint is violated (either in the config file or via CLI flag overrides), Gaze exits with an error explaining which source caused the invalid configuration.

Label assignment logic:

  • Confidence >= contractualcontractual
  • Confidence < incidentalincidental
  • Otherwise → ambiguous

Tier-based boosts: Before threshold comparison, P0 effects (ReturnValue, ErrorReturn, SentinelError, ReceiverMutation, PointerArgMutation) receive a +25 confidence boost (base 75), and P1 effects receive a +10 boost (base 60). This means P0 effects trend toward contractual by default.


classification.doc_scan

Controls which documentation files are scanned for classification signals.

classification.doc_scan.exclude

KeyTypeDefaultDescription
exclude[]stringSee belowGlob patterns for files to exclude from document scanning

Default exclude patterns:

exclude:
  - "vendor/**"
  - "node_modules/**"
  - ".git/**"
  - "testdata/**"
  - "CHANGELOG.md"
  - "CONTRIBUTING.md"
  - "CODE_OF_CONDUCT.md"
  - "LICENSE"
  - "LICENSE.md"

These defaults prevent scanning dependency directories and boilerplate files that rarely contain classification-relevant information.

classification.doc_scan.include

KeyTypeDefaultDescription
include[]stringnull (scan all)Glob patterns for files to include. When set, only matching files are processed, overriding the default full-repo scan.

When include is set, only files matching at least one include pattern (and not matching any exclude pattern) are scanned. When include is empty or null, all non-excluded Markdown files are scanned.

classification.doc_scan.timeout

KeyTypeDefaultDescription
timeoutstring"30s"Maximum duration for document scanning. Uses Go duration format (e.g., "30s", "1m", "2m30s").

baseline

Top-level section for baseline comparison settings. Controls how gaze crap detects regressions by comparing current CRAP/GazeCRAP scores against a saved baseline.

All fields are optional — when omitted, sensible defaults are used.

KeyTypeDefaultValid RangeDescription
filestring.gaze/baseline.jsonAny valid file pathPath to the baseline JSON file. This is the auto-detection path — gaze crap loads this file automatically when it exists.
epsilonfloat640.5>= 0Minimum score delta to trigger a regression or improvement. Score changes within epsilon are classified as unchanged. The default (0.5) absorbs platform/toolchain noise without masking real regressions.
new_function_thresholdfloat6430> 0CRAP score above which a new function (not present in the baseline) is flagged as a violation. New functions below this threshold are reported as informational.

Validation rules:

  • epsilon must be >= 0. A negative epsilon produces an error.
  • new_function_threshold must be > 0. A zero or negative value produces an error.

Interaction with CLI flags: The --baseline flag overrides the file path. There are no CLI flags for epsilon or new_function_threshold — these are configured only via .gaze.yaml since they rarely change.


CLI Flag Overrides

Several CLI flags override config file values. The CLI flag always takes precedence when explicitly set.

CLI FlagConfig KeyCommands
--contractual-thresholdclassification.thresholds.contractualanalyze, quality
--incidental-thresholdclassification.thresholds.incidentalanalyze, quality
--config— (specifies file path)analyze, quality, docscan
--baselinebaseline.filecrap

Override semantics: A CLI flag value of -1 (the default) means "use the config file value." Any other value in the valid range (1–99) overrides the config. The threshold coherence constraint (contractual > incidental) is validated after merging CLI and config values.

Validation Rules

  1. Threshold range: Both contractual and incidental must be integers in [1, 99].
  2. Threshold ordering: contractual must be strictly greater than incidental.
  3. Timeout format: Must be a valid Go duration string (parsed by time.ParseDuration).
  4. Glob patterns: Must be valid glob patterns (parsed by Go's filepath.Match).
  5. YAML syntax: The file must be valid YAML. Parse errors produce a descriptive error message with the file path.
  6. Baseline epsilon: Must be >= 0.
  7. Baseline new_function_threshold: Must be > 0.

Error Messages

When configuration is invalid, Gaze produces actionable error messages that identify the source:

# Invalid threshold from config file
contractual threshold (40) must be greater than incidental threshold (50); check config file .gaze.yaml

# Invalid threshold from CLI flag
--contractual-threshold=30 is invalid: must be in [1, 99]

# Conflict between CLI flag and config
contractual threshold (50) must be greater than incidental threshold (50); check --contractual-threshold flag

# Invalid baseline config
baseline epsilon (-1) must be >= 0; check config file .gaze.yaml

# Invalid baseline threshold
baseline new_function_threshold (0) must be > 0; check config file .gaze.yaml

See Also

  • Classification — how thresholds affect classification labels
  • gaze analyze — uses config for classification
  • gaze crap — uses config for baseline comparison settings
  • gaze quality — uses config for classification and contract coverage
  • gaze docscan — uses config for document scanning settings
  • Glossary — definitions of contractual, incidental, and ambiguous