[BUG] Claude Code executes Node.js hooks on Python projects in multi-project workspace
Problem Summary
Claude Code incorrectly executes npm/biome PostToolUse hooks 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'
Detailed 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-guardianagent - 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
.claudedirectory for "npm", "biome", "PostToolUse" - No matches found - No
package.jsonfile exists in the project (this is a Python project)
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
Root Cause Analysis
Claude Code appears to be 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 only defines Python tooling
This suggests cross-project hook inheritance where hooks from sibling Node.js projects are being inappropriately applied to Python projects.
Expected Behavior
Claude Code should:
- Detect project type correctly - This is clearly a Python FastAPI project with
requirements.txt,pyproject.toml, Python files, etc. - Not execute JavaScript/Node.js hooks on Python projects
- Respect project-specific hook configurations that only define Python tooling
Actual Behavior
Claude Code is executing npm/biome hooks despite the project being pure Python with no JavaScript dependencies or configuration.
Reproduction Steps
- Create or work in a Python project (no
package.json) - Set up
.claude/config/hooks.jsonwith only Python-specific hooks - Use the Edit tool to modify any file
- Observe the npm/biome error in the output
Impact
- Severity: Minor (non-blocking but annoying)
- Frequency: Every Edit tool usage
- User Experience: Creates noise and confusion about project setup
Suggested Fix
Claude Code should:
- Check for project type before executing language-specific hooks
- Only run npm/biome hooks when
package.jsonexists or project is explicitly JavaScript/TypeScript - Respect user-defined hook configurations and not inject default hooks that conflict with project type
- 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.
---
This issue replaces #5384 with improved structure while preserving all technical details and investigation findings.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗