glep / Guides
Using glep with Cursor
Install the glep preToolUse hook for Cursor so the agent's Grep and Glob calls are redirected to the glep index, and see how it maps each field.
The cursor/ folder in the repository contains a preToolUse hook for Cursor, hooks/glep_redirect.py, and an installer. Cursor has no skill file; the hook’s message tells the agent which command to run.
First principles
Cursor and Claude Code send different payloads and expect different replies, but the decision is the same in both: allow the built-in call, or deny it and name the equivalent glep command. So one hook file serves both editors. It reads the payload, decides, and formats the reply for whichever editor called it. Like the Claude Code hook, it never runs glep itself and allows every call it cannot translate.
Requirements
glepon your PATH. See Installation.python3on your PATH, for the hook.- A
.glep/index in the working directory. Runglep indexonce in the project root.
Install
git clone https://github.com/velofy/glep
glep/cursor/install.sh
The script copies the hook to ~/.cursor/hooks/glep_redirect.py and makes it executable.
If ~/.cursor/hooks.json does not exist, the script creates it with this content. If it already exists, the script prints the same block for you to merge into hooks.preToolUse:
{
"version": 1,
"hooks": {
"preToolUse": [
{
"command": "./hooks/glep_redirect.py",
"matcher": "Grep|Glob"
}
]
}
}
What the hook does
The hook allows the call unchanged unless glep is on the PATH and the working directory (the payload’s cwd) contains a .glep/ directory. Malformed input is also allowed through.
When both are present, it denies Grep and Glob calls with Cursor’s permission format:
{
"permission": "deny",
"user_message": "Use glep via Bash (indexed search).",
"agent_message": "This project has a glep index. Run the equivalent indexed search via Bash instead: glep -i -g '*.rs' -e 'foo bar'"
}
Grep parameters are translated the same way as in the Claude Code hook, with two extra spellings:
patternbecomes-e,-istays-i, andcase_sensitive: falsealso becomes-i.output_modebecomes-lor-c, andmultilinebecomes-U.glob(orinclude) becomes-g, andtypebecomes-t.-C,-Aand-Bpass through, andpathis appended.offsetandhead_limitbecome| tail -n +Kand| head -Npipes on the shown command.-n: false, withoutput_modeset tocontentor left out, is left to the built-in tool.
For Glob, the hook reads glob_pattern (or pattern) and target_directory (or path), and suggests glep --files 'pattern' dir.
One hook for both editors
The Cursor copy of glep_redirect.py detects which editor called it. Payloads with hook_event_name: preToolUse or a cursor_version field get the Cursor format above. Anything else gets Claude Code’s hookSpecificOutput format, so the same file also works as a Claude Code hook. See Using glep with Claude Code.
The repository tests both formats with cursor/hooks/test_hook.sh.
Uninstall
Remove the glep entry from ~/.cursor/hooks.json and delete ~/.cursor/hooks/glep_redirect.py.