.agents/memory/2026-02-27-block-co-authored-by-attribution-hook-implementati.md

1.3 KiB

2026-02-27 Session Notes

Block Co-Authored-By Attribution Hook Implementation

Nicholai requested implementation of a PreToolUse hook to block any git commits that contain Claude Code's automatic "Co-Authored-By: Claude" attribution. The session involved planning and beginning implementation of the blocking mechanism.

Technical Approach

The solution uses a bash script (~/.claude/hooks/block-coauthor.sh) that intercepts Bash tool calls before execution. The hook reads JSON input via stdin, extracts the git command being run using jq, and scans for the case-insensitive pattern Co-Authored-By:.*Claude. If found, it outputs a JSON response with permissionDecision: "deny"; otherwise it exits cleanly to allow execution.

The PreToolUse hook is registered in ~/.claude/settings.json with a 5-second timeout and matcher targeting the Bash tool.

Work Completed

Read existing settings.json to understand the hook structure and confirm the format for adding new hook entries. The file contains existing SessionStart, UserPromptSubmit, and SessionEnd hooks that call signet commands.

Next Steps

Create the bash script and update settings.json to register the PreToolUse hook. Test by attempting a commit through Claude Code (should be blocked) and a manual git commit outside Claude (should work normally).