---
name: safe-diagnostics
description: Use when collecting diagnostics without leaking secrets.
---

# Safe diagnostics

When inspecting configuration, scripts, or support bundles, verify what is actually collected and preserve secret confidentiality.

1. Inspect a diagnostic script and its sourced files before running it; check for writes, network access, credential collection, and forced success exit codes. If effects exceed the user's stated scope, explain and do not run it without appropriate authorization.
2. Treat environment variables as potentially secret, including multiline values. Never use line-oriented `printenv | cut -d= -f1` to extract names: continuation lines can expose values. Use a language's environment mapping, e.g. `python3 -c 'import os; print("\n".join(sorted(os.environ)))'`.
3. Encoding does not redact secrets; a diff against a redacted copy can expose the original. Compare locally without returning values and report only names and match status when authorized.
4. For a product support dump, inspect help and implementation to identify raw config and secret handling. Capture output privately and return only verified safe fields or statuses; do not print secret values or write them to files intended for sharing. State clearly when output is filtered.
5. Report the actual exit code, and do not treat an unconditional `exit 0` as proof that checks passed. In shell pipelines, the status of `head` can mask failure of the diagnostic command; collect individual process statuses or use `pipefail`, and distinguish truncated output from complete output.
6. If the user requests both complete diagnostic output and no secret values, inspect the commands and their output handling before persisting or sharing results. Prefer a private in-memory capture and verified redaction where possible; disclose any filtering or truncation and never claim regex or environment-value scanning guarantees detection of all secrets. If a secret-free complete output cannot be established, explain the limitation rather than promising both.
6. When creating a backup, check whether the requested destination already exists before running a potentially overwriting command. Afterward verify the exact requested artifact exists and has the expected format; exit code 0 or a success message may describe a different snapshot or destination. Report the actual result without attaching archives that could contain secrets.
