Context
A seat has twice blanked a GitHub body by piping a transform into gh … edit --body-file -:
- 2026-10-12,
neomjs/neo-stage#24 (13k chars of a folded decision): the sed failed on an unescaped / and printed nothing.
- 2026-10-17 21:43Z,
neomjs/neo-stage#170, a PR under review: the node transform failed with MODULE_NOT_FOUND, because its path came from a glob that matched another session's scratch directory. The body sat at 0 chars for 33 s and was restored from GraphQL userContentEdits.
The same seat (Vega) had recorded the lesson after the first occurrence, and discipline did not hold. The defect-note at 21:45Z promotes it as a second occurrence.
The Problem
A pipeline cannot keep the old value when its producer fails. --body-file - writes whatever arrives on stdin, and GitHub accepts an empty body for pr edit and issue edit. The producer doesn't matter (sed, node, jq). set -o pipefail alone doesn't help either: it only changes the exit code after the consumer has already written.
The Architectural Reality
.claude/settings.json runs two PreToolUse Bash guards: .claude/hooks/rgReplaceGuardHook.mjs (the rg -r footgun; it exports tokenizeShellCommand) and .claude/hooks/harnessIdGuardHook.mjs. Both fail open on a malformed payload.
- The spec precedent is
test/playwright/unit/hooks/rgReplaceGuardHook.spec.mjs.
The Fix
Add .claude/hooks/bodyFileGuardHook.mjs as a sibling that reuses tokenizeShellCommand, and register it in .claude/settings.json beside the rg guard.
It blocks a Bash command when a gh pr edit or gh issue edit segment reads its body from stdin (--body-file -, --body-file=-, -F -) and consumes a pipe. It allows the command if the producer is printf or echo of one variable and the command checks that variable's length or emptiness (${#V}, -n "$V", -z "$V").
The block message names the failure and the safe shape:
set -o pipefail; V=$(producer) || exit 1; [ ${#V} -gt N ] || exit 1; printf '%s' "$V" | gh … edit --body-file -.
Acceptance Criteria
Out of Scope
gh api -X PATCH … -f body="$V" with an unchecked variable: the same class, a second rule if it recurs.
- Other harness families' hook systems: the defect-note reached them.
Related
neomjs/neo-stage#24, neomjs/neo-stage#170: the two occurrences.
- A2A defect-note
2f129777 (2026-10-17 21:45Z).
Creation checks
- Live latest-open sweep at 22:03Z: the latest 20 open
neo issues; none equivalent. A search for "body-file" finds none.
- A2A all-status sweep: no claim on
.claude/hooks.
- MC: the 10-12 lesson is Vega's own record; no prior decision on a hook.
- Structure: a sibling of the existing
.claude/hooks/ guards; no Agent OS placement.
Origin Session ID: 964d6ca5-1709-49ac-a7a5-2e6ca64dd031
Retrieval Hint: "gh edit body-file stdin empty body blank pipeline guard hook"
Context
A seat has twice blanked a GitHub body by piping a transform into
gh … edit --body-file -:neomjs/neo-stage#24(13k chars of a folded decision): the sed failed on an unescaped/and printed nothing.neomjs/neo-stage#170, a PR under review: the node transform failed withMODULE_NOT_FOUND, because its path came from a glob that matched another session's scratch directory. The body sat at 0 chars for 33 s and was restored from GraphQLuserContentEdits.The same seat (Vega) had recorded the lesson after the first occurrence, and discipline did not hold. The defect-note at 21:45Z promotes it as a second occurrence.
The Problem
A pipeline cannot keep the old value when its producer fails.
--body-file -writes whatever arrives on stdin, and GitHub accepts an empty body forpr editandissue edit. The producer doesn't matter (sed, node, jq).set -o pipefailalone doesn't help either: it only changes the exit code after the consumer has already written.The Architectural Reality
.claude/settings.jsonruns two PreToolUse Bash guards:.claude/hooks/rgReplaceGuardHook.mjs(therg -rfootgun; it exportstokenizeShellCommand) and.claude/hooks/harnessIdGuardHook.mjs. Both fail open on a malformed payload.test/playwright/unit/hooks/rgReplaceGuardHook.spec.mjs.The Fix
Add
.claude/hooks/bodyFileGuardHook.mjsas a sibling that reusestokenizeShellCommand, and register it in.claude/settings.jsonbeside the rg guard.It blocks a Bash command when a
gh pr editorgh issue editsegment reads its body from stdin (--body-file -,--body-file=-,-F -) and consumes a pipe. It allows the command if the producer isprintforechoof one variable and the command checks that variable's length or emptiness (${#V},-n "$V",-z "$V").The block message names the failure and the safe shape:
set -o pipefail; V=$(producer) || exit 1; [ ${#V} -gt N ] || exit 1; printf '%s' "$V" | gh … edit --body-file -.Acceptance Criteria
gh pr view 1 --json body --jq .body | sed s/a/b/ | gh pr edit 1 --body-file -, and the same with anodeorjqproducer,--body-file=-,-F -, orgh issue edit.gh pr edit 1 --body-file body.md, a heredoc body, andgh pr create … --body-file -, where an empty body loses nothing.test/playwright/unit/hooks/bodyFileGuardHook.spec.mjscovers each arm. Mutation: a guard that never sees the pipe lets the sed shape through and fails the spec.Out of Scope
gh api -X PATCH … -f body="$V"with an unchecked variable: the same class, a second rule if it recurs.Related
neomjs/neo-stage#24,neomjs/neo-stage#170: the two occurrences.2f129777(2026-10-17 21:45Z).Creation checks
neoissues; none equivalent. A search for "body-file" finds none..claude/hooks..claude/hooks/guards; no Agent OS placement.Origin Session ID: 964d6ca5-1709-49ac-a7a5-2e6ca64dd031 Retrieval Hint: "gh edit body-file stdin empty body blank pipeline guard hook"