-
Notifications
You must be signed in to change notification settings - Fork 2
feat(hooks): add Claude Code PostToolUse hook for linting and typechecking #257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
…cking - Add lint-and-typecheck-hook.ts script that runs ESLint and TypeScript typecheck on files after Claude modifies them using Write or Edit tools - Configure PostToolUse hook in .claude/settings.json to trigger on Write|Edit - Add TypeScript configuration for .github/scripts directory - Update eslint.config.js to support .github/scripts with separate tsconfig - Document the hook in root CLAUDE.md with usage, configuration, and troubleshooting The hook provides immediate feedback to Claude about lint errors and type issues introduced by its changes, enabling faster iteration and cleaner code. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
👋 Hi! I'm Claude, an AI assistant here to help with code reviews and answer questions about your PR. You can tag me anytime with 💡 Tip: Ask me to explain code, suggest improvements, review specific changes, or help with AI Toolkit development patterns. This repository contains the AI Toolkit - standardized, one-shot setup for Claude Code AI workflows. When working on changes, make sure to follow the Nx monorepo patterns and update relevant CLAUDE.md files. |
🤖 Claude Code Review
SummaryThis PR adds a Claude Code PostToolUse hook that automatically lints and typechecks files after Claude modifies them using the Write or Edit tools. The implementation includes:
AnalysisCode QualityThe hook script is well-structured with clear separation of concerns:
ConfigurationThe ESLint and TypeScript configurations are properly set up:
Potential IssueThere's a configuration inconsistency in {
"composite": true,
"noEmit": true
}Having both Since the script is executed via Minor Observations
VerdictThe implementation is solid and follows the project's conventions. The composite/noEmit inconsistency is a minor configuration oddity that doesn't affect functionality since tsx handles execution. The code is well-tested through error handling patterns and graceful degradation. 💡 Want a fresh review? Add a comment containing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📋 Review verdict: APPROVE
👆 The main review comment above is the source of truth for this PR review. It is automatically updated on each review cycle, so always refer to it for the most current feedback.
This formal review submission is for the verdict only. 1 inline comment(s) are attached below.
| "outDir": "../../dist/.github/scripts", | ||
| "rootDir": ".", | ||
| "types": ["node"], | ||
| "noEmit": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having both composite: true and noEmit: true is contradictory. Composite projects are designed to emit declaration files for project references, but noEmit prevents any output.
Since this script runs via npx tsx (no build step needed), consider either:
- Remove
composite: truesince you're not using project references features, OR - Remove
noEmit: trueif you want proper integration with the monorepo's build system
This doesn't break anything currently since tsx handles transpilation, but the config is misleading.
| "noEmit": true | |
| { | |
| "extends": "../../tsconfig.base.json", | |
| "compilerOptions": { | |
| "outDir": "../../dist/.github/scripts", | |
| "rootDir": ".", | |
| "types": ["node"], | |
| "noEmit": true | |
| }, | |
| "include": ["**/*.ts"], | |
| "exclude": ["node_modules"] | |
| } |
Summary
This PR adds a Claude Code PostToolUse hook that automatically lints and typechecks files after Claude modifies them using the Write or Edit tools. This provides immediate feedback to Claude about any issues introduced by its changes.
Changes
.github/scripts/lint-and-typecheck-hook.ts: New TypeScript script that:.ts,.tsx,.js,.jsx,.mts,.cts,.mjs,.cjsfiles).claude/settings.json: Configuration for the PostToolUse hook to trigger on Write|Edit tool usage.github/scripts/tsconfig.json: TypeScript configuration for the scripts directoryeslint.config.js: Updated to support linting.github/scriptswith a separate tsconfigCLAUDE.md: Documented the hook with:How It Works
WriteorEdittool to modify a file, the PostToolUse hook is triggeredTesting
Linear Issue
Closes: https://linear.app/uniswap/issue/DEV-49/add-claude-code-hook-for-linting-and-typechecking-only-the-files-it
Autonomous implementation using claude-opus-4-5-20251101
✨ Claude-Generated Content
Summary
Adds a Claude Code PostToolUse hook that automatically lints and typechecks files after Claude modifies them using the Write or Edit tools, providing immediate feedback about any issues introduced by changes.
Changes
.github/scripts/lint-and-typecheck-hook.ts: New TypeScript script that:.ts,.tsx,.js,.jsx,.mts,.cts,.mjs,.cjs).claude/settings.json: Configuration for the PostToolUse hook to trigger on Write|Edit tool usage.github/scripts/tsconfig.json: TypeScript configuration for the scripts directoryeslint.config.js: Updated to support linting.github/scriptswith a separate tsconfigtsconfig.json: Added.github/scriptsas a project referenceCLAUDE.md: Documented the hook with usage, configuration, benefits, and troubleshooting guideTechnical Details
The workflow operates as follows:
WriteorEdittool to modify a file, the PostToolUse hook is triggeredThe hook can be tested manually:
Closes: https://linear.app/uniswap/issue/DEV-49