Skip to content

fix(hooks): bootstrap hook injects context via plain stdout - #6

Merged
roadhero merged 1 commit into
mainfrom
fix/bootstrap-stdout-context
Sep 14, 2026
Merged

roadhero merged 1 commit into
mainfrom
fix/bootstrap-stdout-context

Conversation

@roadhero

@roadhero roadhero commented Sep 14, 2026 •

Copy link
Copy Markdown
Owner

Summary

The bootstrap-claude-md.sh SessionStart hook emitted its nudge as a hookSpecificOutput.additionalContext JSON object. Per the current hooks docs, SessionStart is one of the events that inject context via plain-text stdout; that's the documented, unambiguous idiom. Switch to printing the nudge directly and drop the jq output call. jq is still required to read .cwd from the stdin payload.

Behavior is unchanged: silent unless a git work tree (root != $HOME) lacks a root CLAUDE.md; fail-open; never writes a file.

Test plan

  • Emit is now plain text (not JSON), verified against a scratch repo
  • test-bootstrap-claude-md.sh (9 cases) updated to assert the plain-text nudge; passes
  • Full gate: shellcheck, jq, template parity, guard 597 + format 4 + bootstrap 9
  • CI green on ubuntu-latest

Summary by CodeRabbit

  • Bug Fixes

    • Updated the SessionStart message format to emit a plain-text line for improved compatibility.
    • Preserved existing behavior for project detection, missing configuration files, and successful hook completion.
  • Tests

    • Updated validation to confirm the plain-text message is emitted and the hook exits successfully.

The SessionStart bootstrap hook emitted its nudge as a hookSpecificOutput
additionalContext JSON object. Plain-text stdout is the documented way a
SessionStart hook injects context Claude can see, so emit the nudge directly and
drop the jq output call (jq is still used to read the stdin payload). Behavior is
otherwise unchanged: silent unless a git repo lacks a root CLAUDE.md. Test asserts
the plain-text nudge instead of parsing JSON.
@coderabbitai

coderabbitai Bot commented Sep 14, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: d9e63f8c-de6d-4fc1-a830-c598e266f59c

📥 Commits

Reviewing files that changed from the base of the PR and between 8c8732d and d89637e.

📒 Files selected for processing (2)
  • hooks/bootstrap-claude-md.sh
  • tests/hooks/test-bootstrap-claude-md.sh

📝 Walkthrough

Walkthrough

The SessionStart bootstrap hook now prints its nudge as one plain-text stdout line instead of a JSON object. The behavioral test now validates the plain-text output while retaining the clean-exit check.

Changes

SessionStart context output

Layer / File(s) Summary
Plain-text hook output
hooks/bootstrap-claude-md.sh
The hook documentation now describes one-line stdout context. The hook uses printf '%s\n' instead of constructing a JSON hookSpecificOutput object.
Behavioral output validation
tests/hooks/test-bootstrap-claude-md.sh
The test now checks for non-empty output containing no CLAUDE.md at its root and still requires a clean exit.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/bootstrap-stdout-context

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@roadhero
roadhero merged commit 13a8a30 into main Sep 14, 2026
1 of 2 checks passed
@roadhero
roadhero deleted the fix/bootstrap-stdout-context branch September 14, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant