Skill: Secret Safety & Redaction
Purpose
Ensure zero leakage of sensitive credentials, personally identifiable information, or local tokens when modifying the project, executing code, and generating logs.
When to Use
- Whenever writing a new API integration (e.g., Minimax, X API, Threads).
- Whenever writing logging mechanisms (
pinosetup) or intercepting HTTP errors. - Whenever creating test snapshots or fixture data.
Required Inputs
- Payload data, error objects, or environment config maps.
Expected Outputs
- A sanitized version of the input, where sensitive fields are replaced by
[REDACTED].
Constraints
- Strictly forbid the writing of real secrets into the repository under any circumstance.
- Never blindly log full HTTP Axios/Fetch error objects, since they frequently contain
Authorizationheaders.
Step-by-Step Execution
- Identify all fields categorized as secrets (e.g., ends with
_KEY,_SECRET,TOKEN). - Pass the unredacted object to
src/utils/secrets.ts#redact()before passing it intologger.info()orlogger.error(). - If creating example configs, exclusively write
your_value_hereas placeholders in.examplefiles. - Verify by attempting a dry-run log and observing the console output.
Failure Modes
- A third-party library dumps the entire context on a crash. (Mitigation: use
uncaughtExceptionandunhandledRejectionsafe wrappers). - A developer accidentally pastes a live token while using an interactive REPL.
Validation Checklist
- [ ] Is
.env.localinside.gitignore? - [ ] Are test fixtures mocked out completely with fake keys (e.g.,
sk-mock-...)? - [ ] Did you sanitize headers for any outgoing API diagnostic log?