-
Couldn't load subscription status.
- Fork 4
Troubleshooting
This guide helps you resolve common issues with Claude Hooks Manager.
Problem: After installing globally, claude-hooks command is not recognized.
Solutions:
- Check npm global bin path:
npm config get prefix
# Add the bin directory to your PATH
export PATH="$(npm config get prefix)/bin:$PATH"- Reinstall globally with proper permissions:
sudo npm install -g claude-hooks-manager
# OR better, configure npm to not require sudo
npm config set prefix ~/.npm-global
export PATH=~/.npm-global/bin:$PATH- Use npx instead:
npx claude-hooks-manager initProblem: npm install fails with EACCES error.
Solution: Configure npm to install global packages without sudo:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
npm install -g claude-hooks-managerProblem: Git commits succeed without running configured hooks.
Diagnostic steps:
- Check hook installation:
claude-hooks status
ls -la .git/hooks/- Verify Git hooks are executable:
chmod +x .git/hooks/*- Check if hooks are being bypassed:
# This bypasses hooks - don't use unless necessary
git commit --no-verify- Reinstall hooks:
claude-hooks remove --all
claude-hooks install --defaultsProblem: Hook scripts can't find required commands.
Solutions:
- Ensure PATH is set correctly in hooks:
# Add to .claude-hooks/config.json
{
"environment": {
"PATH": "/usr/local/bin:/usr/bin:/bin:./node_modules/.bin"
}
}- Use absolute paths in custom hooks:
const eslint = path.join(process.cwd(), 'node_modules/.bin/eslint');Problem: Hooks fail with timeout error.
Solutions:
- Increase timeout for specific hooks:
{
"hooks": {
"test-suite": {
"timeout": 300000 // 5 minutes
}
}
}- Disable timeout for debugging:
claude-hooks run test-suite --no-timeout- Run hooks in parallel:
{
"globals": {
"parallel": true,
"maxWorkers": 4
}
}Problem: Changes to config.json don't take effect.
Diagnostic steps:
- Validate configuration:
claude-hooks config validate- Check configuration hierarchy:
# Show effective configuration
claude-hooks config --effective
# Show where configuration is loaded from
claude-hooks config --show-sources- Clear configuration cache:
claude-hooks cache clearProblem: "Invalid configuration" error when running hooks.
Solutions:
- Check JSON syntax:
# Validate JSON syntax
jq . .claude-hooks/config.json
# Or use Claude Hooks validator
claude-hooks config validate- Common JSON errors:
- Trailing commas
- Missing quotes around keys
- Incorrect value types
- Use configuration schema:
{
"$schema": "https://claude-hooks.dev/schema/v1/config.json",
// Your config with IDE validation
}Problem: Hooks take too long to execute.
Optimization strategies:
- Enable parallel execution:
{
"globals": {
"parallel": true
}
}- Run only on changed files:
{
"hooks": {
"lint-check": {
"config": {
"changedOnly": true
}
}
}
}- Use caching:
{
"cache": {
"enabled": true,
"ttl": 3600
}
}- Profile hook execution:
claude-hooks run --profileProblem: Hooks fail with heap out of memory error.
Solutions:
- Increase Node.js memory:
export NODE_OPTIONS="--max-old-space-size=4096"- Process files in batches:
{
"globals": {
"batchSize": 50
}
}- Exclude unnecessary files:
{
"fileFilters": {
"exclude": ["node_modules/**", "dist/**", "coverage/**"]
}
}Line ending problems:
# Configure Git to handle line endings
git config --global core.autocrlf true
# Configure hooks to handle CRLF
{
"globals": {
"lineEndings": "auto"
}
}Path separator issues:
- Use forward slashes in configurations
- Use
path.join()in custom hooks
Script execution policy:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUserXcode command line tools required:
xcode-select --installFile watching limits:
# Increase file descriptor limit
ulimit -n 2048Permissions on CI:
# In CI configuration
before_script:
- chmod +x .git/hooks/*Problem: Existing Git hooks conflict with Claude Hooks Manager.
Solutions:
- Backup and migrate existing hooks:
claude-hooks init --preserve-existing
claude-hooks migrate-hooks- Chain existing hooks:
{
"hooks": {
"custom-wrapper": {
"type": "pre-commit",
"command": "sh .git/hooks/pre-commit.old && claude-hooks run pre-commit"
}
}
}Problem: Hooks fail in CI but work locally.
Common causes and solutions:
- Missing dependencies:
# .github/workflows/ci.yml
- name: Install dependencies
run: |
npm ci
npm install -g claude-hooks-manager- Skip certain hooks in CI:
{
"globals": {
"skipCI": true
},
"hooks": {
"interactive-hook": {
"skipCI": true
}
}
}- CI-specific configuration:
# Set CI environment
export CI=true
export CLAUDE_HOOKS_ENV=ci# Debug all hooks
export CLAUDE_HOOKS_DEBUG=*
git commit -m "test"
# Debug specific hook
export CLAUDE_HOOKS_DEBUG=format-check
git commit -m "test"
# Debug configuration loading
export CLAUDE_HOOKS_DEBUG=config
claude-hooks status# Run with verbose output
claude-hooks run format-check --verbose
# Or set in configuration
{
"globals": {
"verbose": true
}
}# Test hook without committing
claude-hooks run format-check --test
# Test with specific files
claude-hooks run lint-check --files "src/index.js,src/utils.js"
# Test with custom configuration
claude-hooks run test-check --config '{"coverage": false}'# Create a debug hook
cat > .claude-hooks/custom/debug-env/index.js << 'EOF'
#!/usr/bin/env node
console.log('Environment Variables:');
Object.keys(process.env).filter(key => key.startsWith('CLAUDE_')).forEach(key => {
console.log(`${key}=${process.env[key]}`);
});
EOF
chmod +x .claude-hooks/custom/debug-env/index.js
claude-hooks run debug-env- Check the logs:
# View recent hook execution logs
claude-hooks logs
# View logs for specific hook
claude-hooks logs format-check- Validate your setup:
# Run diagnostic checks
claude-hooks doctor
# Check specific subsystems
claude-hooks doctor --hooks
claude-hooks doctor --config
claude-hooks doctor --git- Search documentation:
# Search CLI help
claude-hooks help search <term>
# Search online docs
claude-hooks docs search <term>- GitHub Issues: Search existing issues or create new ones
- Discord Community: Join our Discord for real-time help
-
Stack Overflow: Tag questions with
claude-hooks-manager
When reporting issues, include:
- System information:
claude-hooks info --system- Configuration:
claude-hooks config --show- Debug output:
CLAUDE_HOOKS_DEBUG=* claude-hooks run <failing-hook> 2> debug.log- Minimal reproduction:
- Steps to reproduce
- Expected behavior
- Actual behavior
# Disable all hooks
claude-hooks disable --all
# Re-enable when fixed
claude-hooks enable --all# Remove from project
claude-hooks uninstall
# Remove globally
npm uninstall -g claude-hooks-manager# Reset configuration
claude-hooks config reset
# Reinstall default hooks
claude-hooks install --defaults --force