cc-plugin-sec-default: every plugin $.fs.write logs [ERROR] hooks chain failed for missing protected-path stats

Open Beginner friendly
#111,771 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
typescript
Domain
security

Research direction

Start in the cc-plugin-sec-default security plugin, where its $.fs.stat checks for protected paths feed the hooks chain; follow the path that turns a missing .claude or settings file into an error-level log. Reproduce with a small mod calling $.fs.write and the --debug-file command, then change missing protected-path stats to debug level or no output. Done when the same repro yields no hooks chain failed lines for absent protected paths.

Written by the indexing model from the issue text.

Description

area:hooks area:plugins bug has repro platform:macos

Version: Claude Code 2.1.329 (macOS)

What happens

With debug logging on (--debug or --debug-file), every $.fs.write made by a user mod makes the bundled cc-plugin-sec-default stat several protected paths:

  • <cwd>/.claude
  • <cwd>/.claude/settings.json
  • <cwd>/.claude/settings.local.json
  • ~/.claude/cowork_settings.json
  • the write target itself, when it does not exist yet

Each stat that hits a missing path is logged at error level, for example:

[DEBUG] $.fs.stat (cc-plugin-sec-default): <path> failed: ENOENT: no such file or directory
[ERROR] hooks chain failed: errorKind=HooksError

The write itself succeeds and nothing else fails. A mod that writes about 15 files during one run produces about 90 of these ERROR lines from a folder with no .claude setup, and about 40 from a project folder that has only .claude/settings.local.json.

Expected

A missing protected path is the normal case (it simply means the target is not a protected file), so it should not be logged at error level; debug level at most, or no line.

Repro

  1. A minimal mod whose tool.call hook calls $.fs.write on a new file a few times.
  2. From a folder without .claude/settings.json, run claude -p "Run the Bash command echo hi" --plugin-dir <mod folder> --debug-file <log>.
  3. grep -c 'hooks chain failed' <log> shows about five per write.
Dominant language
TypeScript
Stars
156k
Forks
25k
Avg merge
16h 19m
Merged PRs (30d)
5

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

  • No Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anthropics/claude-code

All issues in anthropics/claude-code

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.