[BUG] Hook Configuration Progressive Duplication Causing Performance Issues

Status Fixed / completed
Maintainer reply ✓ Yes — dicksontsai
Activity 6 comments · opened Jul 15, 2025 · closed Jul 24, 2025
💡 Likely answer: A maintainer (dicksontsai, collaborator) responded on this thread — see the highlighted reply below.

Summary

Claude Code hooks progressively duplicate during sessions,
causing multiple simultaneous executions (up to 10+ ESLint
processes) after each file edit, resulting in severe performance
degradation.

Environment

  • Claude Code Version: v1.0.51
  • OS: macOS (Darwin 24.5.0)
  • Platform: PNPM-based Next.js 15 project
  • Config Location: .claude/settings.local.json

Problem Description

  1. Progressive Duplication: Hooks gradually multiply over time

during active Claude Code sessions

  1. Performance Impact: Multiple ESLint processes run

simultaneously (observed up to 10 instances)

  1. Resource Consumption: High CPU/memory usage from duplicate

processes

  1. Workflow Disruption: Significant slowdown during file editing

operations

Steps to Reproduce

  1. Configure PostToolUse hooks for ESLint checking
  2. Use Claude Code for extended file editing session
  3. Observe progressive increase in hook execution time
  4. Check system processes during file edits - multiple ESLint

instances running

Expected Behavior

Single hook execution per configured trigger event.

Actual Behavior

Multiple identical hook executions (2x, 5x, 10x+) for single
trigger event, increasing over session duration.

Current Configuration (After Manual Cleanup)

{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{
"type": "command",
"command": "python3 '/path/to/eslint_check.py'"
}
]
}
]
}
}

Workaround

Manual cleanup of configuration file and Claude Code session
restart.

Suspected Root Cause

Hook registry not properly cleared between operations, leading to
accumulation of hook configurations in memory.

View original on GitHub ↗

6 Comments

Soljourner · 1 year ago

+1 getting the same behavior. PreTool Hook is getting duplicated and eventually causes Claude Code to stop working when trying to process hooks. Can't find a clear cause of the duplication. I can watch hooks get called without a duplicate being added to the settings.local.json, but other times I look and I have 100s of the same hook.

funCapital · 1 year ago

I can confirm, I also have the same issue on version 1.0.52, got a 16k+ stop hooks at one point

OldBigBuddha · 1 year ago

I noticed the same phenomenon. I am using VSCode on Ubuntu Server via SSH from MacOS.

Environment

Claude Code Version: v1.0.53
OS: macOS (Darwin 24.5.0) / Ubuntu 22.04 on GCE Instance
Node version: v22.5.1
Config Location: .claude/settings.local.json

After looking into the settings in detail, it appears that each hook is being duplicated 64 times.

<img width="936" height="129" alt="Image" src="https://github.com/user-attachments/assets/e70e2cc2-f737-4eb8-b1c3-b97144adbcbe" />

Unfortunately, this setting is not managed by git, so it is unclear when it was duplicated. If my memory is correct, MaxListenersExceededWarning started appearing on Monday of this week when using claude code.

dicksontsai collaborator · 1 year ago

This regression was fixed in v1.0.53 in that /hooks will no longer duplicate configs. However, you will need to manually clean up your settings file due to the regression.

I am adding a fix in the next release v1.0.56 that will deduplicate the hooks commands when reading settings files that have duplicates, but you should still clean up the settings file.

dicksontsai collaborator · 1 year ago

The deduplication logic is now deployed.

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.