Why this rule
Agent context files are read on every task. A raw credential inAGENTS.md is visible to every model session, every log that captures context windows, and every tool invocation that passes the context forward. Rotation after exposure is the only safe recovery — the secret cannot be “un-seen.”
What triggers it
Charter scans git-tracked agent-visible files for high-confidence credential patterns:| Pattern | Example prefix | Min length |
|---|---|---|
| OpenAI API token | sk- | 20 characters |
| GitHub personal access token | ghp_ | 30 characters |
| AWS access key ID | AKIA | 16 characters |
| Slack bot token | xoxb- | 20 characters |
| PEM private key | -----BEGIN ... PRIVATE KEY----- | — |
AGENTS.md, CLAUDE.md, .cursor/rules, .windsurfrules, .github/copilot-instructions.md, opencode.md, codex.md, DESIGN.md, SKILL.md.
Neutralized (never fire): Environment variable references (${VAR}, $VAR) and the placeholder string your-api-key-here are explicitly excluded. Only literal credential values trigger the finding. Detected values are redacted in Charter output (first 4 characters followed by …).
Out of scope by design: Uncommitted local files are never scanned. Only git-tracked files are in scope.
Examples
- Failing
- Passing
AGENTS.md
How to fix
Rotate the credential externally
Revoke and regenerate the secret in the provider’s dashboard. The commit that introduced the literal value exposed it — assume it is compromised regardless of repo visibility.
Remove the literal value from the file
Delete the raw credential from the context file. Do not just move it to a comment or mask part of it.
Replace with an environment variable reference
Use
${OPENAI_API_KEY} or $OPENAI_API_KEY in place of the literal value. Most agent runtimes and CI systems resolve env refs at execution time.Commit the fix
Commit the updated file. Charter will re-scan on next run and clear the finding once no literal credential is detected.
Score impact
Related rules
- AE-SEC-002 — same patterns applied to MCP config files
- AE-CTX-001 — context file must exist and be within budget