Claude Code executes wrong project hooks in multi-project workspace

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

Problem Summary

Claude Code incorrectly executes Node.js/npm hooks on Python projects when both project types exist in the same workspace, causing ENOENT errors during Edit tool operations.

Environment

  • Platform: macOS (Darwin 24.5.0)
  • Project: Python FastAPI ML service (no package.json)
  • Location: /Users/devhub/WebstormProjects/polirate/political-fraud-detection-ml
  • Workspace: Contains both Python and Node.js projects

Error Details

Every Edit tool use triggers this error:

⏺ 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

Root Cause

Cross-project hook inheritance: Claude Code is executing hooks from sibling Node.js projects on Python projects that don't have the required files (package.json).

Expected Behavior

  • ✅ Detect current project type (Python vs Node.js)
  • ✅ Only execute hooks appropriate for the detected project type
  • ✅ Respect project-specific hook configurations
  • ✅ Prevent cross-language hook contamination

Suggested Fix

Implement project-type detection before executing language-specific hooks:

  1. Check for project indicators (package.json, requirements.txt, etc.)
  2. Filter hooks based on detected project type
  3. Only run compatible hooks for the current project

Impact

  • Severity: Minor (non-blocking but confusing)
  • Frequency: Every Edit tool use
  • User Experience: Creates confusion about project setup

Related

This replaces the original issue #5384 with a clearer, more structured format.

View original on GitHub ↗

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