Skip to content

feat: add PreToolUse search enrichment via code-review-graph enrich#103

Open
gzenz wants to merge 1 commit intotirth8205:mainfrom
gzenz:feat/pretooluse-search-enrichment
Open

feat: add PreToolUse search enrichment via code-review-graph enrich#103
gzenz wants to merge 1 commit intotirth8205:mainfrom
gzenz:feat/pretooluse-search-enrichment

Conversation

@gzenz
Copy link
Copy Markdown
Contributor

@gzenz gzenz commented Apr 5, 2026

Summary

When agents use Grep/Glob/Bash(rg/grep)/Read, a Claude Code PreToolUse hook automatically enriches results with structural context from the graph. Zero-friction adoption -- agents get structural context passively without calling graph tools explicitly.

  • New enrich.py module with pattern extraction and graph queries
  • New enrich CLI subcommand (reads hook JSON from stdin)
  • Updated hooks config in skills.py (Grep|Glob|Bash|Read matcher)
  • Platform-split instructions: CLAUDE.md gets lighter instructions focused on deep-analysis tools (hooks handle exploration); non-hook platforms (.cursorrules, AGENTS.md, GEMINI.md, .windsurfrules) keep stronger "prefer graph tools" guidance
  • 24 new tests in test_enrich.py
  • Updated docs: CHANGELOG, CLAUDE.md, COMMANDS, FEATURES, LLM-OPTIMIZED-REFERENCE, ROADMAP, USAGE

What the hook injects

For each search pattern, the enrichment provides:

  • Matching symbols with file:line location
  • Community membership (which module/subsystem)
  • Callers and callees (max 5 each)
  • Execution flows the symbol participates in (max 3)
  • Tests that cover it (max 3)

For file reads, it provides the same structural context for all functions/classes in the file.

Upgrade note

If upgrading from v2.1.0, delete the <!-- code-review-graph MCP tools --> section from your CLAUDE.md and re-run code-review-graph install to get the updated lighter instructions.

Test plan

  • 24 new tests (pattern extraction, search enrichment, file enrichment, hook output)
  • Full suite: 589 tests pass
  • Lint and type-check clean

@gzenz gzenz force-pushed the feat/pretooluse-search-enrichment branch 2 times, most recently from b7b0403 to 29d232a Compare April 5, 2026 14:12
When agents use Grep/Glob/Bash(rg/grep)/Read, a Claude Code PreToolUse
hook automatically enriches results with structural context from the
graph: callers, callees, execution flows, community membership, and
test coverage. Zero-friction adoption -- agents get structural context
passively without calling graph tools explicitly.

- New enrich.py module with pattern extraction and graph queries
- New `enrich` CLI subcommand (reads hook JSON from stdin)
- Updated hooks config in skills.py (Grep|Glob|Bash|Read matcher)
- 24 new tests in test_enrich.py
- Updated all docs: CHANGELOG, CLAUDE.md, COMMANDS, FEATURES,
  LLM-OPTIMIZED-REFERENCE, ROADMAP, USAGE
@gzenz gzenz force-pushed the feat/pretooluse-search-enrichment branch from 29d232a to 622e69a Compare April 5, 2026 15:10
gzenz added a commit to gzenz/code-review-graph that referenced this pull request Apr 6, 2026
…h8205#103

Combine nested hooks format from tirth8205#100 with permissions and enrich hook
from tirth8205#103. Rename PreCommit -> PreToolUse, use nested hooks arrays.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@tirth8205 tirth8205 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Major feature — passive graph enrichment via PreToolUse hooks is a compelling idea. New enrich.py module + CLI command + 237 lines of tests.

This needs rebase on latest main (has conflicts). We'll review the enrichment pipeline and hook integration in detail once it's rebased.

@gzenz
Copy link
Copy Markdown
Contributor Author

gzenz commented Apr 8, 2026

@tirth8205 thanks for your feedback. actually, instead of opening further pr's, i worked locally quite a bit and did many more improvements. for the sake of simplicity, i'll open a new pr based on current master with all of them.

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