Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Using PRECC with Cursor

PRECC was built as a PreToolUse hook for Claude Code, but the underlying skill library — cargo-wrong-dir, git-wrong-dir, npm-wrong-dir, jj-translate, and friends — is editor-agnostic. With a small shell snippet you can route every command typed in Cursor’s integrated terminal through precc-hook so the same rewrites that save tokens on Claude Code also save them on Cursor.

Requires precc ≥ 0.3.45. Earlier versions don’t plant the integration scripts under <data_dir>/integrations/cursor/. Run precc update to upgrade if you have an older release.

What’s covered

The integration catches commands you type into Cursor’s terminal. On zsh it auto-rewrites the command line before Enter; on bash it can only warn (the DEBUG trap fires after the command is finalised). Commands that Cursor’s agent spawns as bash -c subprocesses don’t load your interactive shell init, so the hook does not see them; closing that gap needs a PATH shim, which is not in this directory yet. Cursor’s non-shell tool calls (file edits, code search) are also out of scope.

Install

zsh (auto-rewrite)

source ~/.local/share/precc/integrations/cursor/precc-preexec.zsh

Run precc init once — it plants the script at the path above (uses <data_dir> from precc’s storage, so CLAUDE_CONFIG_DIR and other profile isolation is honoured). Then add the source line to ~/.zshrc. precc-hook and jq must be on PATH; the script no-ops cleanly if either is missing.

bash (warn-only)

source ~/.local/share/precc/integrations/cursor/precc-preexec.bash

Run precc init once — it plants the script at the path above. Then add the source line to ~/.bashrc. The DEBUG trap prints the suggested rewrite to stderr without applying it; you can copy the suggestion manually.

Verify

In Cursor’s terminal, cd /tmp (anywhere outside a Rust project) and type a Rust build command then press Enter. On zsh the buffer should change in-place to a PRECC-rewritten form (typically a cd PATH && …-style prepend). On bash you should see a [precc] suggested rewrite: … line on stderr.

Caveats

  • Adds the precc-hook per-keystroke latency. The hook targets <5 ms p50 but the p99 is higher on cold caches; see the hook-latency notes in this book.
  • No telemetry from this path. The hook will report under whatever agent_class it detects, which won’t be claude-code — your Cursor savings won’t appear on the public stats page.
  • The rewrite reason flashes via zle -M for one keystroke. Quiet, not modal.
  • For agent coverage, a PATH shim (wrappers at ~/.precc/bin/cargo, ~/.precc/bin/git, …) is the planned next step.