[BUG] Cross-project hook inheritance executes sibling project hooks inappropriately

Resolved 💬 6 comments Opened Aug 8, 2025 by george-hutanu-devhub Closed Aug 8, 2025

Summary

Claude Code is executing an npm/biome PostToolUse hook on Python FastAPI projects that don't have a package.json file, causing "ENOENT" errors after every Edit tool use.

Environment

  • Platform: macOS (Darwin 24.5.0)
  • Claude Code Version: Latest
  • Project Type: Python FastAPI ML service
  • Working Directory: /Users/devhub/WebstormProjects/polirate/political-fraud-detection-ml

Error Details

Every time the Edit tool is used, the following error appears:

⏺ PostToolUse:Edit [cd "$CLAUDE_PROJECT_DIR" && npm run biome:check] failed with non-blocking status 
  code 254: npm error code ENOENT
  npm error syscall open
  npm error path /Users/devhub/WebstormProjects/polirate/political-fraud-detection-ml/package.json
  npm error errno -2
  npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open 
  '/Users/devhub/WebstormProjects/polirate/political-fraud-detection-ml/package.json'

Project Configuration Analysis

I've thoroughly checked all possible hook configuration locations:

Project Hook Configuration

  • File: .claude/config/hooks.json
  • Content: Only contains Python-specific hooks using code-style-guardian agent
  • No npm/biome references found

Settings Files Checked

  • ~/.claude/settings.json - Does not exist
  • .claude/settings.json - Does not exist
  • .claude/settings.local.json - Contains only Python-specific permissions and hook config references
  • .claude/config/debug.json - Contains only Python debugging settings

Search Results

  • Searched entire .claude directory for "npm", "biome", "PostToolUse" - No matches found
  • No package.json file exists in the project (this is a Python project)

Expected Behavior

Claude Code should:

  1. Detect project type correctly - This is clearly a Python FastAPI project with requirements.txt, pyproject.toml, Python files, etc.
  2. Not execute JavaScript/Node.js hooks on Python projects
  3. Respect project-specific hook configurations that only define Python tooling

Actual Behavior

Claude Code is executing a hardcoded or default npm/biome PostToolUse hook regardless of:

  • Project type (Python vs JavaScript)
  • Absence of package.json
  • Project-specific hook configuration that doesn't include npm commands

Project Context

This is a Python FastAPI ML service with the following characteristics:

  • Uses Python 3.11+
  • FastAPI framework
  • SQLAlchemy + PostgreSQL
  • scikit-learn + TensorFlow for ML
  • Poetry/pip for dependency management
  • Has requirements.txt, pyproject.toml, alembic.ini
  • No JavaScript/Node.js components whatsoever

Impact

  • Severity: Minor (non-blocking but annoying)
  • Frequency: Every Edit tool usage
  • User Experience: Creates noise and confusion about project setup

Reproduction Steps

  1. Create or work in a Python project (no package.json)
  2. Set up .claude/config/hooks.json with only Python-specific hooks
  3. Use the Edit tool to modify any file
  4. Observe the npm/biome error in the output

Suggested Fix

Claude Code should:

  1. Check for project type before executing language-specific hooks
  2. Only run npm/biome hooks when package.json exists or project is explicitly JavaScript/TypeScript
  3. Respect user-defined hook configurations and not inject default hooks that conflict with project type
  4. Add project type detection logic to prevent cross-language hook contamination

This appears to be a case where a default or hardcoded hook is being applied universally instead of contextually based on project type.

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗