Repository navigation
feat(checker): run as a Claude Code hook with --claude-code-hook - #60
Merged
Merged
Conversation
The checker reads a PostToolUse hook's input itself, so the hook in the README is one command instead of a shell pipeline that needed jq. A new docs/agent-setup.md walks a coding agent through installing and configuring the plugin, the checker and the hook, linked from the top of the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The guide follows the install.md format (installmd.org), at the repository root, so it can be piped into Claude Code from the README. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Worktrees under .claude/worktrees/ hold their own copies of tests/, which Vitest otherwise picks up and fails to run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude Code asks before writing its settings files and refuses the old step-7 command's quoting, and records Bash diffs in more cases than the docs said. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The README's Claude Code hook was a long shell pipeline squeezed into one JSON string. It needed
jqand couldn't work on Windows. The checker now does that work itself:With
--claude-code-hook, the checker:tool_input.file_path, ortool_response.bashEditDiff.changedFilesfor Bash;A call that changed no project file exits 0 without running Git or Oxlint.
It also adds a root
install.md, in the install.md format (OBJECTIVE, DONE WHEN, a TODO list, the steps, EXECUTE NOW). A user pipes it into Claude Code (curl -fsSL …/install.md | claude), or points their agent at it, to set everything up in their project:bashEditDiffEnabled;CLAUDE.md;The README links it from the top, with the one-liner. The format says to execute autonomously, but the guide keeps the steps where it asks the user first.
Changes
The hook's input parsing lives in
src/checker/claude-code.ts.cli.tsgained a hook path that filters files to the project, checks from the project's directory, and remaps exit codes. The plain CLI is unchanged.install.md's hook block must match the README's; a test enforces it.The guide tells the agent to ask before editing user settings or adding CI tooling, and not to fix existing over-max functions.
The guide says the package isn't on npm yet, so it stops at the install step until the first release.
Vitest now runs only
tests/**/*.test.ts. A Claude Code worktree under.claude/worktrees/holds its own copy oftests/, which Vitest otherwise picked up and failed on, blocking the pre-push hook.Verification
vp run ready: format, lint, typecheck and 107 tests pass.smoke-distalso runs the built bin in hook mode.The hook tests run the README's command with
/bin/shfrom outside the project, against a stand-in install. They cover:CLAUDE_PROJECT_DIR→ the current directory is the project;One
/refineround with two reviewers. Findings applied:nullinput;bun.lockb, where--basegoes, and running the hook once to check it.Live run, Claude Code 2.1.302, headless sessions on a scratch project with the packed build: every hook scenario behaved as documented:
CLAUDE_CODE_BASH_EDIT_DIFF=1): exit 2, and the agent fixed it;No
EAGAINappeared. A fresh agent followed the setup guide and got everything in place except the hook, because Claude Code protects its settings files. The fixes from that run are in the last commit:CLAUDE_CODE_BASH_EDIT_DIFF=1for a session.Observations
npm packfails withEBADDEVENGINESbecause of the pnpmdevEnginespin, whilevp pm packworks. This matters for the release process (Release process and npm publishing with provenance #19).