# tokenix with Claude Code
Claude Code has the deepest integration. A native `PreToolUse` hook sees every
`Grep`, `Bash` and `PowerShell` call before it runs, with no prompt changes.
## Install
```bash
tokenix index . # once per repository
tokenix install-hook --tool claude-code # all projects: ~/.claude/settings.json
tokenix install-hook --tool claude-code --local # this project only: .claude/settings.local.json
```
Restart Claude Code so it loads the new hook.
## What gets written
One entry in `hooks.PreToolUse`. Other hooks in the file are left alone:
```json
{
}
```
The command is the absolute path of the binary you ran `install-hook` with. If you
move the binary, run `install-hook` again.
## What it does
| `Read` (any file) | Never intercepted |
| `Grep` with unbounded `content` output | Adds `head_limit` (default 100) through `updatedInput` |
| `Bash` matching a filter | Rewritten to `tokenix run '<cmd>'` through `updatedInput`, same exit code. On Windows it re-runs under the same Git Bash, so bash syntax keeps working |
| `PowerShell` matching a filter | Rewritten to `& 'tokenix' run --shell pwsh '<cmd>'` |
| Anything else, or no/stale index | Passes through (exit `0`) |
`tokenix read <file> --symbol <name>` and `tokenix symbols` stay available if Claude
chooses to call them.
> The installer wires `PreToolUse` only. `tokenix hook-post` (PostToolUse
> redaction and compression) is not installed for Claude Code.
## Check that it works
```bash
tokenix gain # after a session: calls, intercepts, tokens removed
tokenix gain --history # recent hook decisions
tokenix # dashboard → Stats tab shows "Claude Code: installed"
```
## Day-to-day tips
- `TOKENIX_DISABLED=1 <command>` lets one command run without the hook.
- A filtered command whose output was clipped ends with a
`tokenix retrieve <key>` marker, and that command returns the full output.
- Add a line to your `CLAUDE.md` if you want Claude to reach for
`tokenix symbols`, `callers` or `impact` before editing shared code. The hook
itself needs no instructions.
## Remove
```bash
tokenix remove-hook --tool claude-code # add --local for the project file
```
Only entries that mention `tokenix` are removed from `PreToolUse`/`PostToolUse`.
[← Back to the README](../../README.md#-agent-guides)