Skip to content

release: v2.1.1 — index-first hooks - #30

Merged
denfry merged 2 commits into
mainfrom
feat/index-first-hooks
Sep 25, 2026
Merged

denfry merged 2 commits into
mainfrom
feat/index-first-hooks

Conversation

@denfry

@denfry denfry commented Sep 25, 2026

Copy link
Copy Markdown
Owner

Problem

With the skill installed, Claude Code still starts most code questions with Grep: skills are only consulted when the model decides to, and grep is its habit. The 2.1.0 pilot showed the index saves ~19% tokens when it is used.

Solution

codebase-index install-hooks [--global] merges two hooks into .claude/settings.json or ~/.claude/settings.json (other hooks are kept; idempotent; --uninstall removes them):

  • SessionStart — in an indexed repository, one line of context naming search/refs/impact --compact.
  • PreToolUse Grep|Bash — the first code search of a session, before any codebase-index command has run, is denied with the index command to use instead. The same call repeated runs; the first index command turns the guard off for the session. Docs/log/config searches, ps | grep pipelines and unindexed directories are never intercepted. CBX_GUARD=0 disables it.

Hooks run as codebase-index-hook (stdlib-only, ~0.1 s). The plugin's hooks/hooks.json registers the same pair.

Verification

  • 735 tests pass (16 new in tests/test_hooks_guard.py), ruff, mypy, link check.
  • Installed globally on a dev machine: a Grep in an indexed repo was denied with the suggested command; after one codebase-index call in the session, Grep ran.

Compatibility

Opt-in: nothing changes until install-hooks is run (or the plugin is updated).

Agents with the skill installed still reached for Grep out of habit. Add
`codebase-index install-hooks [--global]`, which merges two hooks into the
Claude Code settings while keeping every other hook:

- SessionStart: in an indexed repository, a one-line note naming the
  commands that answer code questions.
- PreToolUse on Grep|Bash: the first code search of a session, before any
  codebase-index command has run, is sent back with the index command to
  use instead. Repeating the call lets it through, the first index command
  turns the guard off for the session, and searches over docs, logs or
  config, `ps | grep` pipelines and unindexed directories pass untouched.

The hooks run as `codebase-index-hook`, a stdlib-only entry point (about
0.1 s per call); CBX_GUARD=0 disables the guard. The plugin registers the
same hooks.
Version bump with every mirror synced (plugin.json, requirements.lock, skill stamps) and the 2.1.1 release notes.
@denfry denfry changed the title feat(hooks): make Claude Code search through the index by default release: v2.1.1 — index-first hooks Sep 25, 2026
@denfry
denfry merged commit 7cfbf14 into main Sep 25, 2026
11 checks passed
@denfry
denfry deleted the feat/index-first-hooks branch September 25, 2026 05:05
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.

1 participant