Skip to content

Simplify hook scripts: extract helpers, fix bugs, improve perf#38

Closed
aseembits93 wants to merge 1 commit intomainfrom
simplify-hook-scripts
Closed

Simplify hook scripts: extract helpers, fix bugs, improve perf#38
aseembits93 wants to merge 1 commit intomainfrom
simplify-hook-scripts

Conversation

@aseembits93
Copy link
Copy Markdown
Contributor

Summary

  • Extract emit_block() and append_auto_allow() helpers in suggest-optimize.sh to replace 9 duplicated emit patterns and 8 duplicated auto-allow blocks (net -40 lines)
  • Fix missing systemMessage field in the Python API-key-check block output (was inconsistent with all other outputs)
  • Fix code_challenge_method=sha256S256 in oauth-login.sh per RFC 7636
  • Merge two git log calls into one — avoids redundant DAG traversal on every hook invocation
  • Consolidate two jq parses of hook input JSON into a single call
  • Defer settings.json check past the HEAD gate — skips unnecessary I/O on the most common exit path (no new commits)
  • Add fast node_modules/.bin/codeflash file check before falling back to slow npx codeflash --version

Test plan

  • All 32 existing bats tests pass
  • Verify OAuth login flow still works with S256 parameter (if server was already accepting sha256, confirm it also accepts the spec-correct value)
  • Smoke test: make a Python/JS commit and confirm the stop hook triggers correctly

🤖 Generated with Claude Code

- Extract emit_block() and append_auto_allow() helpers to eliminate 8+9
  repeated code blocks in suggest-optimize.sh (-40 lines net)
- Fix missing systemMessage field in Python API-key block output
- Fix code_challenge_method=sha256 → S256 per RFC 7636 in oauth-login.sh
- Merge two git log calls into one to avoid redundant DAG traversal
- Consolidate two jq parses of hook input JSON into a single call
- Defer settings.json auto-allow check past the HEAD gate so it's
  skipped on the most common exit path (no new commits)
- Add fast node_modules/.bin/codeflash file check before slow npx fallback

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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