Security & Safety / Least Privilege & Secrets
Keep secrets out of agent context, memory, logs and output
- MUST inject credentials at the tool or transport boundary (environment of the tool process, a secret manager, OAuth handled by the client) so the model never sees the secret value.
- MUST NOT put secrets in prompts, instruction files (
AGENTS.md,CLAUDE.md), skills, MCP configuration that is committed, agent memory, workflow stores, or handoff briefs. Reference them by name (${GITHUB_TOKEN}), never by value. - MUST deny agents read access to secret files and stores they do not need (
.env,~/.ssh, cloud credential files, password managers) with permission rules or the sandbox, not instructions. - MUST scan everything agents write for secrets before it leaves the machine: commits and pull requests (pre-commit and CI secret scanning), logs, memory entries, issue comments and generated documents.
- MUST redact secrets and personal data from tool output and logs before they enter context or are stored.
- MUST treat any secret that entered an agent’s context, transcript, memory or a log as exposed: rotate it, then remove it from where it was stored.
- SHOULD use short-lived, scoped tokens (BP-0032) so an exposed secret has limited use.
- SHOULD keep secrets in one managed store (cloud secret manager, vault, OS keychain) with audit logging, not in files spread across machines.
- SHOULD tell agents, in their instruction file, where credentials come from and that they must never print, echo or store them.
When to apply
Section titled “When to apply”Any agent that uses credentials, reads configuration, writes code, logs, memory or documents.
Examples
Section titled “Examples”Good: the deploy tool reads DEPLOY_TOKEN from its own environment; the agent calls deploy --env staging and sees only the result. .env is on the agent’s deny list. Pre-commit secret scanning blocks a token in a test fixture.
Bad: “Here is the API key: sk-…” pasted into chat; the agent stores it in long-term memory “for next time” and echoes it into a debug log.
Anti-patterns
Section titled “Anti-patterns”- Secrets in
CLAUDE.md“so the agent can test the API”. cat .envto “check the config”.- Debug logging of full HTTP requests with headers.
- Deleting a leaked key from the transcript but not rotating it.
Checklist
Section titled “Checklist”- Credentials injected at the tool boundary; model never sees values
- No secrets in prompts, instruction files, skills, memory or committed config
- Secret files denied to agents
- Secret scanning on commits, logs, memory and outputs; redaction in place
- Exposed secrets rotated