Professional-grade quality validation hooks for Claude Code with project-specific optimizations.
- Project-Specific Optimizations: Tailored hooks for React apps, Node.js backends, and VS Code extensions
- TypeScript Compilation Check: Fast
tsc --noEmitvalidation with incremental builds - ESLint Integration: Auto-fix capability with project-specific rules
- Prettier Formatting: Automatic code formatting with customizable settings
- Smart Caching: TypeScript config detection with SHA256 checksums for <5ms performance
- Module Alias Support: Full support for path aliases (@src, @components, etc.)
- Security Focused: Uses CLAUDE_PROJECT_DIR environment variable (best practices)
- Exit Code Handling:
0for success (silent)2for quality issues (blocks the edit)
# React/Next.js/Vite projects
curl -sSL https://raw.githubusercontent.com/your-username/claude-code-ts-quality-hook/main/install.sh | bash -s react-app
# Node.js backend projects
curl -sSL https://raw.githubusercontent.com/your-username/claude-code-ts-quality-hook/main/install.sh | bash -s node-typescript
# VS Code extensions
curl -sSL https://raw.githubusercontent.com/your-username/claude-code-ts-quality-hook/main/install.sh | bash -s vscode-extensionFor detailed step-by-step instructions, troubleshooting, and configuration options:
📖 See Complete Installation Guide →
# 1. Clone repository
git clone https://github.com/your-username/claude-code-ts-quality-hook.git
# 2. Copy files to your project (choose your project type)
cp claude-code-ts-quality-hook/.claude/settings.react-app.json /path/to/your/project/.claude/settings.local.json
cp -r claude-code-ts-quality-hook/.claude/hooks /path/to/your/project/.claude/
# 3. Install dependencies
cd /path/to/your/project
npm install -D typescript eslint prettier- JSX/TSX Support: Full React and TypeScript integration
- React Rules: ESLint rules optimized for React development
- Hook Validation: Rules of Hooks enforcement
- Build Optimization: Supports Next.js, Create React App, Vite
- File Types: Components, hooks, pages, tests
- Server Optimization: Node.js specific TypeScript settings
- Backend Rules: ESLint rules for server-side development
- Module Support: CommonJS and ES modules
- File Types: Services, controllers, models, middleware, routes
- Extension API: Optimized for VS Code extension development
- Webview Support: Separate configs for main extension and webviews
- Security Rules: Webview security best practices
- File Types: Extension main, commands, providers, webviews
- Node.js 14.0.0+ with npm/yarn
- Existing TypeScript/JavaScript project
- Claude Code IDE
For detailed system requirements and troubleshooting, see INSTALLATION.md.
{
"typescript": {
"enabled": true,
"incremental": true,
"jsx": "react-jsx"
},
"eslint": {
"enabled": true,
"autofix": true,
"extends": ["react-app", "react-app/jest"]
},
"prettier": {
"enabled": true,
"autofix": true
}
}{
"typescript": {
"enabled": true,
"target": "ES2020",
"module": "commonjs"
},
"eslint": {
"enabled": true,
"env": ["node", "es2021"]
},
"prettier": {
"enabled": true,
"singleQuote": true
}
}{
"typescript": {
"enabled": true,
"lib": ["ES2020", "DOM"]
},
"eslint": {
"enabled": true,
"env": ["node", "browser"]
},
"vscodeSettings": {
"webviewSecurityPolicy": {
"enableScripts": true
}
}
}- Trigger: Runs automatically after Claude Code's Write, Edit, or MultiEdit tools
- Project Detection: Automatically selects the appropriate hook based on your configuration
- File Processing: Validates TypeScript/JavaScript files with project-specific rules
- Quality Checks:
- TypeScript compilation (
tsc --noEmit) - ESLint validation with auto-fix
- Prettier formatting (optional)
- TypeScript compilation (
- Result: Returns appropriate exit code to Claude Code
- 0: All checks passed (edit allowed)
- 1: General error (configuration issue, missing dependencies)
- 2: Quality issues found (edit blocked until fixed)
- TypeScript:
.ts,.tsx(with JSX support) - JavaScript:
.js,.jsx(with JSX support) - Test files:
*.test.*,*.spec.*
- TypeScript:
.ts(server-focused) - JavaScript:
.js(server-focused) - Test files:
*.test.ts,*.spec.ts
- TypeScript:
.ts(extension and webview) - JavaScript:
.js(legacy support)
node_modules/dist/,build/,out/,.next/.d.tsdeclaration files- Config files (
*.config.js,*.config.ts) - Coverage and cache directories
The hooks automatically detect and use appropriate configs:
tsconfig.json(main)tsconfig.build.json(build-specific)tsconfig.test.json(test-specific)tsconfig.webview.json(VS Code webviews)
Each hook intelligently maps files to the correct TypeScript configuration:
- Webview files →
tsconfig.webview.json - Test files →
tsconfig.test.json - Source files →
tsconfig.json
- Sub-5ms Validation: SHA256 caching for config files
- Incremental Builds: TypeScript incremental compilation
- ESLint Caching: Automatic cache management
- Parallel Execution: TypeScript, ESLint, and Prettier run concurrently
Test any hook manually:
# Test React app hook
node .claude/hooks/react-app/quality-check.js src/App.tsx
# Test Node.js hook
node .claude/hooks/node-typescript/quality-check.js src/server.ts
# Test VS Code extension hook
node .claude/hooks/vscode-extension/quality-check.js src/extension.ts
# Check exit code
echo $?Each hook maintains its own TypeScript configuration cache:
- Location:
.claude/hooks/{project-type}/tsconfig-cache.json - Purpose: Maps files to appropriate TypeScript configs
- Validation: SHA256 checksums detect config changes instantly
- Auto-regeneration: Rebuilds cache when configurations change
find .claude/hooks -name "tsconfig-cache.json" -delete{
"prettier": {
"enabled": false
}
}{
"typescript": {
"enabled": true
},
"eslint": {
"enabled": false
}
}{
"general": {
"debug": true
}
}For React projects with additional file types:
{
"supportedExtensions": [".ts", ".tsx", ".js", ".jsx", ".mjs"]
}- Verify correct settings file:
.claude/settings.local.json - Check file path in command:
node .claude/hooks/{project-type}/quality-check.js - Ensure Node.js can execute the script
- Verify
tsconfig.jsonexists in project root - Check TypeScript installation:
npx tsc --version - Enable debug mode to see processing details
- Verify
.eslintrc.*configuration exists - Check ESLint installation:
npx eslint --version - Ensure file extensions match ESLint configuration
- Check
.prettierrcorprettier.config.jsexists - Verify Prettier installation:
npx prettier --version - Disable Prettier if not needed:
"prettier": { "enabled": false }
- Enable incremental builds:
"incremental": true - Use project references for monorepos
- Check for large
node_modulesin TypeScript path
# Clear all caches and regenerate
rm -rf .claude/hooks/*/tsconfig-cache.json
rm -rf node_modules/.cachenpx create-react-app my-app --template typescript
cd my-app
cp path/to/claude-code-ts-quality-hook/.claude/settings.react-app.json .claude/settings.local.json
cp -r path/to/claude-code-ts-quality-hook/.claude/hooks .claude/npx create-next-app@latest my-app --typescript
cd my-app
cp path/to/claude-code-ts-quality-hook/.claude/settings.react-app.json .claude/settings.local.json
cp -r path/to/claude-code-ts-quality-hook/.claude/hooks .claude/mkdir my-backend && cd my-backend
npm init -y
npm install -D typescript @types/node
cp path/to/claude-code-ts-quality-hook/.claude/settings.node-typescript.json .claude/settings.local.json
cp -r path/to/claude-code-ts-quality-hook/.claude/hooks .claude/npx @vscode/vscode-generator-code my-extension
cd my-extension
cp path/to/claude-code-ts-quality-hook/.claude/settings.vscode-extension.json .claude/settings.local.json
cp -r path/to/claude-code-ts-quality-hook/.claude/hooks .claude/claude-code-ts-quality-hook/
├── .claude/
│ ├── hooks/
│ │ ├── react-app/
│ │ │ ├── quality-check.js
│ │ │ └── hook-config.json
│ │ ├── node-typescript/
│ │ │ ├── quality-check.js
│ │ │ └── hook-config.json
│ │ ├── vscode-extension/
│ │ │ ├── quality-check.js
│ │ │ └── hook-config.json
│ │ └── quality-check.js # Generic hook
│ ├── settings.local.json # Default settings (React)
│ ├── settings.react-app.json # React app settings
│ ├── settings.node-typescript.json # Node.js settings
│ └── settings.vscode-extension.json # VS Code extension settings
├── examples/
│ └── sample-project-setup.md # Setup examples
├── README.md # This file
├── LICENSE # MIT License
├── package.json # Package metadata
└── .gitignore # Git ignore rules
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Submit a pull request
Before submitting a PR:
- Test with all three project types (React, Node.js, VS Code extension)
- Verify TypeScript, ESLint, and Prettier integration
- Check performance with large projects
- Ensure error messages are clear and helpful
- Uses
CLAUDE_PROJECT_DIRenvironment variable (recommended by Claude Code) - No directory traversal vulnerabilities
- Validates all file paths before processing
- Sanitizes command arguments
- No execution of user-provided code
Typical performance on a modern development machine:
- TypeScript check: 50-200ms (incremental: 10-50ms)
- ESLint validation: 30-100ms (cached: 5-20ms)
- Prettier formatting: 10-50ms
- Total hook execution: 100-350ms (optimized: 25-120ms)
All hooks have been validated with comprehensive testing:
- React App Hook: Correctly detects TypeScript, JSX, and React-specific issues
- Node.js TypeScript Hook: Validates server-side TypeScript patterns
- VS Code Extension Hook: Catches extension API and webview issues
- Generic Hook: Works across all file types
- TypeScript compilation errors (type mismatches, missing properties)
- ESLint rule violations (unused variables, missing error handling)
- Prettier formatting inconsistencies
- Project-specific optimizations verified
- All hooks return correct exit codes (0 for success, 2 for errors)
- Caching system working for sub-5ms config validation
- CLAUDE_PROJECT_DIR environment variable handling verified
Run ./test-runner.sh to execute the full test suite.
- Claude Code - The IDE that powers these hooks
- TypeScript - JavaScript with types
- ESLint - JavaScript linting utility
- Prettier - Code formatter
Our implementation offers several enhancements:
- Prettier Integration: Automatic code formatting support
- Enhanced Configuration: More granular control over rules and behavior
- Better Documentation: Comprehensive setup guides and examples
- Security Improvements: Following latest Claude Code best practices
- Project-Specific Optimizations: Tailored configurations for different use cases
MIT License - see LICENSE file for details.
- ✨ Initial release with project-specific hooks
- ✨ React app, Node.js backend, and VS Code extension support
- ✨ Prettier integration
- ✨ Enhanced TypeScript config caching
- ✨ Security improvements with CLAUDE_PROJECT_DIR
- ✨ Comprehensive documentation and examples
If you encounter issues:
- Check the troubleshooting section
- Enable debug mode for more information
- Search existing issues on GitHub
- Create a new issue with:
- Your project type (React/Node.js/VS Code extension)
- Debug output (with sensitive info removed)
- Steps to reproduce the issue
- Inspired by bartolli/claude-code-typescript-hooks
- Built for the Claude Code community
- Thanks to all contributors and testers