Skip to content

Protect secrets

Generated output redacts potential secrets by default and keeps sensitive files, such as .env, private keys, and credential stores, path-only. Detection covers common token formats, private-key blocks, credential assignments, bearer values, and credentials in URLs, but unfamiliar or constructed values may be missed.

Select a mode

--secrets accepts redact, block, or off:

Shell
contextcraft . --secrets redact -o context.md
contextcraft . --secrets block -o context.md
contextcraft . --secrets off -o context.md

Redact mode replaces matched values with [REDACTED], while block mode rejects generation when findings exist. Off mode explicitly disables protection.

Exempt a path

Use --secret-allow for a narrow path exemption:

Shell
contextcraft . --secret-allow '.env.example' -o context.md

An exemption bypasses both sensitive-file suppression and content scanning for matching paths. Example files are not exempt automatically, and explicit file inputs still receive protection unless exempted.

JSON
{
  "secrets": {
    "mode": "redact",
    "allow_paths": [".env.example"]
  }
}

Understand the boundary

Protection runs before ranking, rendering, and exact budgeting of the generated view. Known patterns in paths are protected too, and outline ranges are remapped to avoid exposing part of a matched secret through an excerpt.

Raw analysis retains original source, and lower-level rendering APIs operate on their supplied data. Redaction does not modify repository files or erase process memory. Findings contain locations and rule IDs rather than matched values.

Review artifacts before sharing them. Report suspected bypasses privately through the security policy.