grep for what code does. Ask in plain words and get back the functions that do it, ranked by probability. Built for coding agents and developers on top of jinter and TypeSafe's Jev model.
$ jrep "retries failed payments" src/
0.94 src/billing/retry.ts:12-80 retryFailedPayment(invoice, attempt)
0.81 src/jobs/payment-worker.ts:40-95 handlePaymentFailure(job)
jrep matches on behavior rather than identifier names, so an agent or developer does not need to guess whether the codebase calls a concept retryFailedPayment, backoffCharge, or requeueInvoice. Use rg for exact strings and symbol names; use jrep to find where a behavior lives.
When an agent explores an unfamiliar codebase with rg, it guesses keywords, reads false positives across tests and lockfiles, and burns context window turns. jrep replaces that loop with one behavioral query while keeping API cost and latency bounded:
- Syntax-aware function chunking. Files are parsed into function, method, and class chunks (~10 to 300 lines) with tree-sitter (and
go/parserfor Go), so every match returns an exactpath:start-endline range and declaration signature ready to open. - Noise filtering that cuts 40% to 70% of wasted tokens.
jrepfollows.gitignoreand automatically skips binaries, lockfiles (70% of tokens in one repository), installed dependencies (node_modules,vendor,bower_components), translation catalogs (43% of chunks inminiflux, with zero effect on match rank), docs (11% of tokens), files over 1 MB, and test files (unless your question asks about tests or you pass--tests). Nothing is skipped silently:stderrreports every skipped count before any chunk is sent to Jev. - Multi-chunk and multi-question packing (
-q). Every Jev request carries ~240 tokens of fixed framing overhead.jreppacks up to 24 KB of chunks from a file into a single call and asks every-qquestion in that same request, reducing total tokens by about a third and making additional questions in the same scan nearly free. - Cheap retry narrowing (
--refine). When a question misses and you reword it,--refine "earlier question"re-asks only the 300 chunks that scored highest on the earlier question from its cached answers. Across real agent retry benchmarks,--refinematched full-rescan accuracy at 9% of the cost. - Line-number-free SQLite cache shared across git worktrees. Answers and chunk layouts are cached in SQLite per repository (
~/Library/Caches/jrepon macOS). Because cache keys omit line numbers, editing the top of a file only re-asks the modified function. Repeat searches and--thresholdadjustments cost zero API calls (dropping a 15.9 s cold scan to 1.1 s warm). - A rate limiter that finds your account's limit. TypeSafe sets rate limits per account and its replies don't say what they are, so
jrepstarts at 400,000 tokens and 320 requests a second, speeds up while TypeSafe keeps up (to at most ten times that), and on a 429 or 529 cuts its rate, waits outRetry-After, then settles just under the rate that was refused. What it learns is kept inratelimits.jsonin the cache folder, under a hash of the API URL and key, so the next search starts at the right speed.JREP_MAX_TPSandJREP_MAX_RPSset a fixed ceiling instead and turn the remembering off. - Connections kept open between searches. Within a search, every call shares one HTTP/2 connection. Across searches, a small background helper keeps that connection open, so the next search skips the TCP and TLS handshake (see Background helper).
export TYPESAFE_API_KEY=... # fish: set -Ux TYPESAFE_API_KEY ...
make install # embeds 33 common language grammars (~20 MB binary)To embed all 206 tree-sitter grammars (~33 MB binary), run go install ./cmd/jrep instead.
jrep "sends the password reset email" src/auth # scope to the likeliest folder first
jrep "validates webhook signatures" -q "parses webhook payloads" src/
jrep --refine "validates webhook signatures" "checks the HMAC header" src/
jrep -s "exports invoices as CSV" . # local keyword pre-pass before calling Jev
jrep --json "retries failed payments" src/| Flag | Purpose |
|---|---|
-q "question" |
Ask an additional question in the same scan at almost no extra cost (repeatable) |
--refine "earlier" |
Re-run a reworded question on only the 300 chunks that best matched "earlier" (~9% of full scan cost) |
-s, --keywords 'a|b' |
Pre-filter chunks locally by the question's non-stopword terms, or by a custom regular expression |
--threshold 0.6 |
Minimum probability in [0, 1] to count as a match (default 0.6) |
--top 10 |
Maximum matches returned per question (default 10, 0 = no limit) |
--tests, --docs, --no-ignore |
Include test files, documentation, or gitignored files |
--max-filesize 1M |
Skip larger files and list them on stderr (default 1M, 0 = no limit) |
--model jev-1.13.0 |
Override the pinned Jev model version |
--json |
Emit one newline-delimited JSON object per match |
--no-cache, --clear-cache |
Ignore cached answers on read, or delete this repository's SQLite cache and exit |
Run jrep -h for the full flag and environment variable list (TYPESAFE_API_KEY, JREP_CACHE_DIR, JREP_MAX_RPS, JREP_MAX_TPS, JREP_NO_DAEMON).
Exit codes: 0 when at least one chunk matches, 1 when nothing reaches --threshold (prints the highest-scoring candidate so you can lower --threshold or rephrase), and 2 on error.
Note
Every uncached chunk searched is sent to TypeSafe, and cost scales with the amount of code scanned (~0.7 cents and ~1 second per 400 chunks). Pass the folder most likely to hold the code rather than the repository root; stderr prints jrep: asking Jev about N chunks whenever uncached chunks are sent.
A search that calls Jev starts a small helper process, jrep --internal-relay <socket>, and leaves it running for later searches.
The helper keeps jrep's HTTPS connection to TypeSafe open, so the next
search skips the TCP and TLS handshake that every run would otherwise
start with (two round trips, 50–200 ms depending on the network). The
first search goes direct and doesn't wait for the helper.
- It only holds connections. Each search still reads files, uses the cache, prints and exits by itself, and sends its own API key with every call. The helper never stores the key, and different keys never share a connection.
- It listens on a unix socket that only you can open:
$XDG_RUNTIME_DIR/jrep/on Linux, otherwise~/.cache/jrep/relay/(~/Library/Caches/jrep/relay/on macOS). - It exits after 10 minutes with no searches, or within a second once its
socket is deleted. Each jrep binary, proxy setting
(
HTTPS_PROXY,NO_PROXY, ...) andSSL_CERT_FILEgets its own helper. - If the helper can't start or dies, searches go direct as before, with no message.
JREP_NO_DAEMON=1 turns it off. To stop a running helper, delete its
socket (rm $XDG_RUNTIME_DIR/jrep/*.sock) or run
pkill -f 'jrep --internal-relay'.
jrep is a thin CLI around the jinter search engine (cmd/jrep/main.go and internal/output). See PLAN.md for the full design rationale and benchmark notes:
1. walk list files via git ls-files / .gitignore, filter binaries, generated files, translations, docs, and tests
2. chunk split files into ~10-300 line functions/blocks via go/parser and tree-sitter (reusing cached layouts)
3. narrow optional -s keyword regex pre-pass or --refine top-300 lookup from an earlier question's cache
4. key sha256(model + normalized question + repo-relative path + chunk code)
5. cache batched SQLite lookup in WAL mode (shared across the repo's worktrees)
6. ask Jev pack uncached chunks per file (<= 24 KB) with all -q questions, dispatch in parallel
7. save persist each call's answers to SQLite as it returns so interrupted runs keep progress
8. rank sort by probability, apply --threshold and --top, print text or JSON
skills/jrep/SKILL.md teaches coding agents how to scope searches to the deepest likely folder, batch questions with -q, and recover from misses with --threshold and --refine. Run make install-skill to copy it to ~/.claude/skills/jrep/ for Claude Code.
Or paste this section into a project's AGENTS.md or CLAUDE.md:
## Searching code
Use `jrep` to find code by behavior; use `rg` for exact strings and symbol names.
jrep "retries failed payments" src/billing/
jrep "validates webhook signatures" -q "parses webhook payloads" src/webhooks/
- Phrase the question as what the code does: "sends the password reset email", not "where is the email code".
- Output is `probability path:start-end signature`, best first. Read the printed line ranges rather than whole files.
- Exit code 0 means matches, 1 means none above the threshold (prints the best candidate), 2 means error. On 1, lower `--threshold 0.3` (served from the cache for free) or rephrase.
- `-q` adds questions to the same scan at almost no extra cost; prefer one call with several `-q` flags over separate calls.
- Pass the single deepest folder likely to hold the code (`ls` first); step up to the parent or add another folder only after a miss.
- When a search misses and you reword the question, pass `--refine "your earlier question"` to search only the 300 chunks that best matched the earlier one (~10% of the cost of a new scan).
- `-s` pre-filters chunks locally by the question's words (or `--keywords 'a|b'`): faster and cheaper on large repos, at the cost of missing code that uses different vocabulary.
- Test files are skipped unless the question mentions tests ("the tests for payment retries") or you pass `--tests`. Docs are skipped unless you pass `--docs`.