Files
command-center/agent/managed-skills/defuse-shell-rc-secrets/SKILL.md
T
Frank a34322aeb0 refactor(skills): consolidate managed skill library 94 -> 25
The managed-skill library was regenerated: 94 narrow per-incident skills
replaced by 25 broader ones (radiance-*, llamacpp-*, homepage-*, fleet/
endpoint ops). Git renders this as mass delete + mass add because whole
directories changed name; old content stays in history at 12c5e88.

Surface check: the 25 on disk are exactly the skills the harness advertises
this session.
2026-10-09 13:17:48 -07:00

1.9 KiB

name, description
name description
defuse-shell-rc-secrets Find literal API keys/tokens in shell rc files and replace them with 600-perm secret files + loader lines, syncing the canonical tool token file.

Defuse shell-rc secrets

Symptom: export KEY=... literal in .zshrc/.bashrc — world-readable in every process env, one git add -A from a dotfiles repo.

Procedure (repeat per host)

  1. Sweep: grep -n "export.*KEY\|export.*TOKEN" ~/.zshrc ~/.zprofile ~/.profile ~/.bashrc 2>/dev/null (run per host; when batching hosts in one ssh compound command, label which output came from which host — misattribution wastes turns).
  2. Extract WITHOUT echoing: mkdir -p ~/.config/secrets && chmod 700 it, then sed -n 's/^export NAME="\(.*\)"$/\1/p' ~/.zshrc > ~/.config/secrets/<name> (quote variant and unquoted variant are different sed patterns — verify byte counts with wc -c, a 0-byte file means the pattern missed).
  3. chmod 600 every secret file; sync any canonical tool file the ecosystem expects (e.g. ~/.cache/huggingface/token).
  4. Replace the rc literal (hashline PUT N.=N: range — never echo the secret in the op): [ -f ~/.config/secrets/<name> ] && export NAME="$(cat ~/.config/secrets/<name>)".
  5. Verify: zsh -n ~/.zshrc (or bash -n); keep a dated .bak of the rc on remote hosts; shred any /tmp transfer copies immediately (shred -u).

Laws

  • A token pasted into chat lands in transcripts and model context — treat chat as a leak channel; give the user the read -rs snippet instead.
  • scp of a secret FILE (encrypted channel, no argv) is fine; the token is never a command-line argument.
  • After replacing a legacy HF token, probe scope non-destructively: HfApi().whoami() (legacy read tokens show type: access_token without canWrite; the decisive probe is create_repo(exist_ok=True) on the real target repo).
  • Verify extraction byte-count before deleting/trusting; a successful-looking sed can write an empty file.