Skip to content

fix: whitelist .claude/plans/ in doc file creation hook#230

Merged
affaan-m merged 1 commit intoaffaan-m:mainfrom
neal-zhu:fix/whitelist-plan-files-in-doc-hook
Feb 16, 2026
Merged

fix: whitelist .claude/plans/ in doc file creation hook#230
affaan-m merged 1 commit intoaffaan-m:mainfrom
neal-zhu:fix/whitelist-plan-files-in-doc-hook

Conversation

@neal-zhu
Copy link
Copy Markdown
Contributor

@neal-zhu neal-zhu commented Feb 15, 2026

Summary

  • The PreToolUse:Write hook that blocks unnecessary .md file creation also incorrectly blocks Claude Code's plan mode from writing plan files to .claude/plans/*.md
  • This causes [Hook] BLOCKED: Unnecessary documentation file creation errors every time a plan is created or updated via plan mode
  • Added .claude/plans/ path to the whitelist regex so plan files are no longer blocked

Reproduction

  1. Install the plugin
  2. Enter plan mode (/plan or EnterPlanMode)
  3. Claude tries to write a plan file to .claude/plans/<name>.md
  4. Hook blocks it with: [Hook] BLOCKED: Unnecessary documentation file creation

Fix

Added &&!/\\.claude\\/plans\\//.test(p) to the condition in the doc file creation hook, alongside the existing whitelist for README.md, CLAUDE.md, AGENTS.md, and CONTRIBUTING.md.

Test plan

  • Verify plan mode can create/update .claude/plans/*.md files without being blocked
  • Verify random .md file creation is still blocked as expected
  • Verify whitelisted files (README.md, CLAUDE.md, etc.) are still allowed

Summary by CodeRabbit

  • Bug Fixes
    • Fixed documentation file handling to properly allow plan files in designated directories while maintaining existing restrictions on other documentation files.

The PreToolUse Write hook blocks creation of .md files to prevent
unnecessary documentation sprawl. However, it also blocks Claude Code's
built-in plan mode from writing plan files to .claude/plans/*.md,
causing "BLOCKED: Unnecessary documentation file creation" errors
every time a plan is created or updated.

Add .claude/plans/ path to the whitelist so plan files are not blocked.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 15, 2026

📝 Walkthrough

Walkthrough

Updated the Write hook's documentation file blocking logic to allow markdown and text files under the .claude/plans/ directory to pass through. Previously, all documentation files were blocked except for specific named patterns; now an additional path exception permits .claude/plans/ documentation.

Changes

Cohort / File(s) Summary
Hook Configuration
hooks/hooks.json
Modified Write hook PreToolUse condition to exclude .claude/plans/ documentation files from blocking rules, allowing .md and .txt files in that directory to pass through.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit's note on paths refined,
Where claude plans rest, no blocks confined,
Markdown flourishes, now set free,
In .claude/plans/ directory! 📝✨

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: whitelist .claude/plans/ in doc file creation hook' accurately describes the main change: whitelisting the .claude/plans/ directory in the documentation file creation hook to fix plan mode functionality.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Merge Conflict Detection ✅ Passed ✅ No merge conflicts detected when merging into main

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@affaan-m
Copy link
Copy Markdown
Owner

[openclaw-bot:pr-review]

Automated Review - CI checks are passing! ✅

Hi @neal-zhu, thanks for this contribution! All CI checks have passed successfully.

A maintainer will review this PR shortly. In the meantime, please ensure:

  • The PR description explains the changes
  • Tests cover the new/modified functionality
  • No breaking changes (or they're documented)

This is an automated review from OpenClaw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants