Skip to content

PreToolUse hook blocks Read/Grep on non-code files (docs, markdown, configs) #188

@digijoebz

Description

@digijoebz

Problem

The cbm-code-discovery-gate hook installed by codebase-memory-mcp install blocks all Read and Grep tool calls, including on non-code files like markdown docs, JSON configs, and spec documents. This makes it impossible to read or search documentation files without going through the MCP server.

Reproduction

  1. Install via curl -fsSL https://raw.githubusercontent.com/DeusData/codebase-memory-mcp/main/install.sh | bash
  2. Restart Claude Code
  3. Try to read a markdown file: Read docs/README.md
  4. Result: BLOCKED: For code discovery, use codebase-memory-mcp tools first...
  5. Same for Grep on any file

Expected Behavior

The hook should only gate code file reads (.ts, .js, .py, etc.), not documentation, configuration, or other non-code files. Markdown, JSON, YAML, TOML, and other config/doc formats should pass through to Read/Grep without blocking.

Workaround

Remove the hook from ~/.claude/settings.json:

import json
with open('~/.claude/settings.json') as f:
    settings = json.load(f)
hooks = settings.get('hooks', {})
for event in list(hooks.keys()):
    hooks[event] = [h for h in hooks[event] if 'cbm-code-discovery' not in str(h.get('command', ''))]
settings['hooks'] = hooks
with open('~/.claude/settings.json', 'w') as f:
    json.dump(settings, f, indent=2)

Environment

  • codebase-memory-mcp 0.5.7
  • Claude Code 2.1.87
  • Linux amd64

Suggestion

The hook script should check the file extension or path pattern before blocking. Something like:

# Only block for code files, not docs/configs
if [[ "$FILE_PATH" =~ \.(ts|js|py|go|rs|java|c|cpp|h)$ ]]; then
    # suggest MCP tools
else
    # allow Read/Grep to proceed
fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingeditor/integrationEditor compatibility and CLI integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions