Context
There is no way to re-record snapshots. The documented procedure is to delete the
snapshot file and re-run, since assert_match_snapshot writes the file when it is
missing (src/assert_snapshot.sh:24-27). Both agent-facing docs say so
explicitly:
docs/ai-agents.md:119 — "There is no --update-snapshots flag"
docs/public/bashunit-skill.md:175 — same
The path to delete is derived, not stated in the test source
(bashunit::snapshot::resolve_file, src/assert_snapshot.sh:91-116): the test
file's basename and the test function name are each passed through
normalize_variable_name, then joined as
./<dir>/snapshots/<file>.<function>.snapshot. For example:
snapshots/snap_test_sh.test_new_snapshot_is_silently_recorded.snapshot
So re-recording means reproducing that normalization by hand, per test.
Proposal
Add --snapshot-update (plus BASHUNIT_SNAPSHOT_UPDATE for .env, following the
existing flag/env pairing in src/env.sh) that makes assert_match_snapshot and
assert_match_snapshot_ignore_colors overwrite the snapshot with the actual value
and count it as a recorded snapshot rather than a pass.
Details worth settling:
- it must compose with a filter so a single test can be re-recorded, not the whole
suite — --snapshot-update together with the existing --filter
- interaction with placeholders (
::ignore::, BASHUNIT_SNAPSHOT_PLACEHOLDER):
overwriting a snapshot destroys its placeholders. Either refuse to overwrite
a snapshot containing the placeholder, or warn loudly. This needs a decision
before implementation.
- run summary must make the rewrite visible (reuse the existing
Some snapshots created block, wording adjusted)
Why this matters for agentic coding
Deliberate output changes are routine — an agent adjusts a message and a dozen
acceptance snapshots need re-recording. Today the agent must derive each path
through a normalization function it has to read the source to understand, then
rm files it cannot verify it chose correctly. Deletion is also the one operation
with no undo: .claude/skills/gh-issues/SKILL.md and the skill docs both already
warn that a deleted snapshot never fails, so a wrong rm silently converts a real
assertion into a rubber stamp. A flag makes the intended operation the easy one
and takes rm off the agent's path entirely.
Acceptance criteria
Context
There is no way to re-record snapshots. The documented procedure is to delete the
snapshot file and re-run, since
assert_match_snapshotwrites the file when it ismissing (
src/assert_snapshot.sh:24-27). Both agent-facing docs say soexplicitly:
docs/ai-agents.md:119— "There is no--update-snapshotsflag"docs/public/bashunit-skill.md:175— sameThe path to delete is derived, not stated in the test source
(
bashunit::snapshot::resolve_file,src/assert_snapshot.sh:91-116): the testfile's basename and the test function name are each passed through
normalize_variable_name, then joined as./<dir>/snapshots/<file>.<function>.snapshot. For example:So re-recording means reproducing that normalization by hand, per test.
Proposal
Add
--snapshot-update(plusBASHUNIT_SNAPSHOT_UPDATEfor.env, following theexisting flag/env pairing in
src/env.sh) that makesassert_match_snapshotandassert_match_snapshot_ignore_colorsoverwrite the snapshot with the actual valueand count it as a recorded snapshot rather than a pass.
Details worth settling:
suite —
--snapshot-updatetogether with the existing--filter::ignore::,BASHUNIT_SNAPSHOT_PLACEHOLDER):overwriting a snapshot destroys its placeholders. Either refuse to overwrite
a snapshot containing the placeholder, or warn loudly. This needs a decision
before implementation.
Some snapshots createdblock, wording adjusted)Why this matters for agentic coding
Deliberate output changes are routine — an agent adjusts a message and a dozen
acceptance snapshots need re-recording. Today the agent must derive each path
through a normalization function it has to read the source to understand, then
rmfiles it cannot verify it chose correctly. Deletion is also the one operationwith no undo:
.claude/skills/gh-issues/SKILL.mdand the skill docs both alreadywarn that a deleted snapshot never fails, so a wrong
rmsilently converts a realassertion into a rubber stamp. A flag makes the intended operation the easy one
and takes
rmoff the agent's path entirely.Acceptance criteria
--snapshot-updaterewrites existing snapshots from the actual valueBASHUNIT_SNAPSHOT_UPDATEequivalent, documented indocs/configuration.md--filterfor single-test re-recordingdocs/snapshots.md,docs/command-line.md,docs/configuration.md, and the "there is no such flag" notes indocs/ai-agents.md+docs/public/bashunit-skill.mdtests/acceptance/make sa+make lintgreen