AFAdocs
CLI

Configuration

Configure AFA via .afa.yaml -- models, gates, analysis, safety, and billing.

Configuration

AFA is configured via a .afa.yaml file in your project root. All settings have sensible defaults -- you only need a config file to customize behavior.

Minimal config

version: "1.0"

model:
  provider: anthropic

That's it. Everything else uses defaults.

Full reference

Model

model:
  provider: anthropic          # anthropic | openai | google | local
  model: claude-sonnet-4-6     # Provider-specific model ID
  fallback: openai/gpt-5.4    # Single fallback model
  fallback_chain:              # Full cross-provider fallback chain
    - openai/gpt-5.4
    - gemini/gemini-3-flash-preview

Gates

Gate parameters are grouped into three governance tracks. Violations cause a ConfigError at load time.

Frozen (cannot be changed)

ParameterValueDescription
complexity_floor0.5Hard floor -- non-overridable

Stable (tunable within narrow bands)

ParameterDefaultMinMaxDescription
delta_risk_threshold2.01.53.0Minimum risk improvement ratio
delta_profit_threshold2.01.53.0Minimum profit improvement ratio
bayesian_confidence0.950.900.99Posterior probability threshold
novelty_threshold0.80.60.9Minimum novelty score
quality_minimum0.70.60.9Minimum aggregate quality
utility_threshold1.5-1.05.0Minimum LCB(U)
kpi_r2_threshold0.60.50.8Minimum R-squared for KPI model
phi_s100.050.0200.0Static complexity cost ($/month/kLOC)
phi_d2000.01000.05000.0Dynamic complexity cost ($/month/service)
z_alpha1.6451.281.96Confidence level z-score

Canary (wider experimental bands)

ParameterDefaultMinMaxDescription
entropy_floor0.250.200.50Minimum Shannon entropy of diff
gamma0.30.10.5Low-confidence value discount
novelty_k5.04.06.0Logistic slope
novelty_n03.52.04.0Logistic center
dead_code_threshold0.80.60.95Anti-gaming: reachable code score
edit_locality_threshold0.30.10.5Anti-gaming: edit locality score
gen_code_threshold0.50.30.8Anti-gaming: natural code score

Example:

gates:
  utility_threshold: 2.0
  entropy_floor: 0.30
  novelty_k: 5.5

Analysis

analysis:
  languages:
    - python
    - typescript
    - go
    - java
    - rust
  exclude:
    - "tests/**"
    - "vendor/**"
    - "node_modules/**"
  max_function_size: 500         # Max lines per function
  protected_paths:               # Additional paths AFA will never modify
    - "migrations/"
    - "generated/"
  finding_policy:                # Finding action policy
    ast_definite_action: auto_block
    hybrid_corroborated_action: auto_block
    llm_only_critical_action: human_review
    llm_only_high_action: human_review
    llm_only_medium_action: advisory
    style_action: advisory

Protected paths merge with AFA's hardcoded defaults (gates/, tests/, config.py, etc.). You can add paths but never remove the built-in ones.

Enhancement

enhancement:
  max_candidates: 3         # Candidates per function (1-10)
  auto_commit: false         # Auto-commit passing enhancements
  branch_prefix: "afa/"      # Git branch prefix
  pr_labels:                 # Labels for auto-created PRs
    - afa-enhancement
    - automated
  max_retries: 3             # Redesign attempts per function (1-10)

Safety

safety:
  kill_switch_check_interval: 1    # Check kill switch every N functions
  gate_subprocess_timeout: 30      # Seconds for out-of-band gate eval (0 = in-process)
  test_isolation: true             # Verify test integrity in worktrees

Cost budgets

cost:
  hourly_budget: 5.0      # USD
  daily_budget: 50.0       # USD
  monthly_budget: 500.0    # USD

Server

server:
  host: "127.0.0.1"       # Bind address (0.0.0.0 for containers)
  port: 8080
  api_token: ""            # Bearer token (empty = open access)
  audit_path: ".afa/audit.db"

Billing

billing:
  stripe_secret_key_env: STRIPE_SECRET_KEY
  stripe_webhook_secret_env: STRIPE_WEBHOOK_SECRET
  metering_db_path: ".afa/metering.db"
  unkey_root_key_env: UNKEY_ROOT_KEY
  unkey_api_id: ""
  unkey_key_prefix: "uk_afa"

Integrations (optional)

integrations:
  aegis:
    enabled: false
    endpoint: "https://aegis.example.com"
    api_key_env: AEGIS_API_KEY
    timeout_seconds: 30
    fallback_to_builtin: true
  pcw:
    enabled: false
    providers:
      - anthropic
      - openai
    agreement_threshold: 0.66
    fallback_to_scoring: true

CLI config command

Set individual values without editing the file:

afa config gates.entropy_floor 0.30
afa config model.provider gemini
afa config enhancement.max_retries 5

On this page