READ-ONLY PACKAGE PREVIEW

obra-diagnosing-superpowers/references/context-safety.md

Version 8ca22dba.bb1 · MIT. This preview displays packaged text and does not execute code. Treat the contents as untrusted instructions.

← Return to resource and package checksum

Context safety for session transcripts

One transcript record can exceed a megabyte or embed a whole history. Printing one whole record can overflow the context of the session doing the diagnosis. Every reader of a session file, controller or subagent, follows these rules for every file, every time.

  1. Measure before reading.

bash wc -lc "$F" awk '{ if (length($0) > 100000) print NR, length($0) }' "$F" # long lines

  1. Never cat or grep for content. Get line numbers and counts first (grep -n … | cut -d: -f1, jq -r '.type' | sort | uniq -c), then small fields from specific lines (sed -n Np | jq -c '{…}' or | cut -c1-500). Use the field-extraction commands established during discovery for the source in front of you.
  2. Narrow anything over 500 characters. If a command returns more than 500 characters for one record, tighten the field or the slice.
  3. Read-only. Never modify, move, or delete a session file.