coding.sh purge
Remove a leaked secret from the store: events, search, blobs, spool, eval runs. Every option of coding.sh purge, from its own --help.
coding.sh purge [options]
Remove a leaked secret from the store: events, search, blobs, spool, eval runs
Options
--literal <FILE|-> File with the values to remove, one per line (- reads stdin); never pass them as arguments
--rule <REGEX> Also remove every match of this regular expression (repeatable); describe the secret's shape, not the secret
--dry-run Count the copies without changing anything
Examples
coding.sh purge --literal leaked.txt --dry-run
pbpaste | coding.sh purge --literal -
coding.sh purge --rule 'sk-ant-api03-[A-Za-z0-9_-]{80,}' --dry-run
Notes
Every copy becomes [redacted:purged]: event payloads (the full-text index is updated), session titles and stats, labels, eval docs and settings. Blobs holding a value are rewritten under their new hash and every reference follows. Spool, judge-cache and eval run files (~/.coding.sh/runs) keep their length (the value becomes asterisks) so ingest offsets stay valid. A run's .git directory and files over 64 MB are left alone.
--rule takes a JavaScript regular expression. Each distinct match of 8 or more characters is purged like a --literal value; shorter matches are left alone, and a rule that matches over 10,000 distinct values is refused.
Then the search index is merged, and the index and the blob pack (blobs/pack.db) are VACUUMed, so the old bytes leave the files. If another process is reading one of them (the viewer, serve, a sqlite3 shell), its old bytes stay until that process closes: purge says which file and exits 1, and the same purge run again finishes the job. Values shorter than 8 characters are refused. Only the SQLite store is supported.
A copy of the index kept next to it by an upgrade (index.db.v<N>.bak) or by upgrade-store --restore (index.db.v<N>.undone) holds the value too. Purge deletes these copies instead of rewriting them, so upgrade-store --restore can no longer put one back; --dry-run names them. If one can't be deleted, purge names it and exits 1.
Rotate the secret as well: copies in the agent's own transcripts, shell history or git are not touched.