CodeSearch keeps a local index of the repositories you work in. A coding agent asks it where something is implemented and gets back whole declarations, ranked — so it opens two or three files instead of reading its way through the tree.
The app does the indexing, over two indexes: BM25 for ranking by
relevance, and an n-gram index for matching patterns against the
text. A small codesearch command answers queries by
asking the running app. Nothing is uploaded: the index, and your
source, stay on your Mac.
Setup
The app walks you through this on first launch. It is four steps, in order — the command cannot reach an app with no profile, and the agent skill is no use before the command exists.
-
Choose a code directory
Point CodeSearch at a folder that holds your projects. It scans for git repositories inside and lists what it found. One folder of many checkouts is the normal case; you can add more later.
Choosing the folder your checkouts live in. -
Install the command-line tool
The
codesearchexecutable ships inside the app bundle. Installing it links that executable onto your path: into/usr/local/binwhen you can write there, and into~/.local/binotherwise. macOS asks you to confirm the folder once, which is what lets a sandboxed app write to it.It is a link, not a copy, so the tool stays in step with the app across updates. If it lands in
~/.local/binand your shell does not look there, add that folder to yourPATH.
Agents: installing the tool, and the skill to copy. -
Copy the agent skill
A skill file tells a coding agent when to reach for
codesearchand how to read what comes back. CodeSearch shows you the file to copy; save it ascodesearch/SKILL.mdin your agent's skills folder —~/.claude/skillsfor Claude Code. The same window is one click away later, under Agents.You do not have to use one. The skill is what makes the agent reach for the index on its own, rather than you telling it to every time.
The skill step: one button opens the file to copy. -
Build the first index
Run it once from the app. After that it reindexes in the background on a schedule — every 30 minutes by default, and adjustable per profile.
The first run, under way.
Indexing Profiles
A profile is one index over one set of code. Most people need one. Separate profiles are worth it when you want different scopes — work and side projects, say — because a query can be limited to one profile, so splitting them is how you keep results narrow.
Each profile holds:
- Directories to scan, and the repositories found inside them.
-
Excluded global paths — globs such as
**/node_modules/**, for keeping particular paths out. - Honour .gitignore, on by default, so build output and vendored dependencies stay out.
- Repositories only, which ignores anything in the folder that is not a git checkout.
- Languages and repositories to leave out, each a checklist: a language you have no interest in, or a checkout that is only noise.
- Reindex interval — 10, 15 or 30 minutes, 1, 6 or 12 hours, or daily — and a switch to pause the profile entirely.
A profile is shown over four tabs. Info holds the directories, the repositories found in them and the settings above. Schedule has the reindex interval and the history of recent runs. Index reports what the index actually contains — chunk count, size on disk, the language breakdown — and which indexes are built. Query searches the profile from inside the app, with the same modes and filters the command line takes, which is the quickest way to see what a query would return.
Enabled indices
Two indexes are built over the same chunks, and a search names which one it wants:
- BM25 ranks by relevance, for describing behaviour rather than matching text.
- N-gram matches a pattern against the text itself, for a symbol or a fragment of code.
Both are built by default. The Index tab has a switch for each, under Enabled Indices; the setting applies to every profile, and at least one has to stay on. Turning one off makes the next run cheaper and smaller, at the cost of the searches that need it: a query in a mode whose index was not built skips that profile and says so.
Usage from the CLI
Two commands. The tool holds no index of its own — each call is one message to the app, and the answer printed. If the app is not running, the tool starts it.
List the profiles. The answer is JSON, and the id is
what a query takes to search one of them. One that has never been
indexed has no lastIndexedAt:
$ codesearch profiles list
[
{
"chunkCount" : 48213,
"id" : "88DE9BEE-96F5-4D19-8054-7E8E16531BC8",
"lastIndexedAt" : "2026-10-13T09:14:00Z",
"name" : "My Code"
}
]
Search. --index names which index to search. It is
required; there is no default:
-
bm25— by relevance. The query is split into words, and declarations named by one of them come first. It is prose, not a pattern. For "where do we do X". -
ngram— by pattern, case-sensitive, best matches first. For a symbol or a fragment of code. The pattern runs over each chunk's whole text:%is any run of characters,_is exactly one, and\makes the next one literal. A pattern with no%of its own is found anywhere in the chunk.
$ codesearch query "where do we validate coupons" --index bm25
$ codesearch query "reindex(" --index ngram --limit 20
$ codesearch query "%func %(ctx context.Context%" --index ngram
Several words are one query. Text that itself begins with a dash
goes after a bare -- —
codesearch query --index ngram -- "--verbose".
Without --profile, every indexed profile is searched at
once and the results come back one profile after another. The
options:
-
--profile <id>searches one profile, by the idprofiles listshows. -
--limit <n>is how many results, per profile. It defaults to 100 and goes up to 1000, with either index. -
--filter <json>keeps only results whose metadata matches: afield(name,kind,module,namespace,receiver,language,path), anop(is,contains,startsWith,endsWith— all of which ignore case) and avalue. Conditions nest under"all"or"any".pathis the file's absolute path. -
--format text|json. Text is the default, for reading; JSON is what a script or an agent should use.
$ codesearch query retry policy --index bm25 --format json \
--filter '{"field": "language", "op": "is", "value": "swift"}' | jq '.results[0]'
As text, each result is a block: a rule, its fields one per line, another rule, then its source exactly as it is in the file, running to the next rule.
================
NO: 1
NAME: settle
KIND: function
FILE: /Users/you/Code/ledger/ledger.go
LINES: 3-9
LANGUAGE: go
REPO: ledger
RECEIVER: Ledger
SCORE: 4.217
================
func (l Ledger) settle(amount int) int {
return amount
}
The fields come in this order — NO, NAME,
KIND, FILE, LINES,
LANGUAGE, REPO, MODULE,
NAMESPACE, RECEIVER, SCORE —
and one the index does not know is left out.
As JSON it is {"results": [...]}, each with
repo, file_path (absolute),
language, chunk_type, name,
start_line, end_line,
content, module_context,
namespace, receiver and
score — always all of them, with "" or
0 where the index does not know. A refused request
prints {"detail": "..."}. The exit status is 0 when the
command ran, 1 when the app could not be reached, and 2 when the
arguments were wrong or the app refused the request.
Each result is a whole declaration. A high bm25 score
means the query's words are prominent in that declaration, and one
that defines a word you searched for is moved ahead of
those that merely use it. Every ngram result scores 1,
so its place in the list is its rank. Treat the results as a list of
files worth opening rather than as complete answers.
codesearch --help prints all of this.
A profile that cannot answer the index you asked for — because that index was never built for it — is left out rather than failing the search, and the tool names it on standard error. If no profile can answer, the command exits 2 and says why.
Usage by coding agents
With the skill installed, an agent reaches for CodeSearch on its own when it is looking for where something lives in a codebase it does not know — and skips it when a path or exact symbol is already known, because grep is cheaper and exact for that.
Worth telling your agent, if it has not worked it out:
- Search before reading. The hits say which files to open.
-
Use
--index bm25with the words the code itself would use — "webhook retry backoff" — and--index ngramwhen you have a symbol or a fragment, such asretryBackoff(. -
Nothing outside an indexed profile is visible.
codesearch profiles listsays what is covered.
Supported languages
Files are split into whole declarations — a function, a class, a method — rather than fixed-size windows, so a hit is something you can read on its own. Twenty kinds of file are understood:
- Swift .swift
- Go .go
- Python .py
- Ruby .rb
- JavaScript .js .jsx .mjs .cjs
- TypeScript .ts .mts .cts
- TSX .tsx
- Java .java
- Rust .rs
- C .c .h
- C++ .cpp .cc .cxx .hpp .hh .hxx
- C# .cs
- PHP .php
- Scala .scala .sc .sbt
- Elixir .ex .exs
- SQL .sql
- CSS .css
- Dockerfile Dockerfile .dockerfile
- Markdown .md .mdx
- Jupyter .ipynb
Troubleshooting
codesearch talks to the app over a local connection and
starts the app itself when it is not running, so there is nothing to
leave switched on for a search to work. If a command still reports
that it could not reach CodeSearch, the usual cause is a link that
no longer points at the app — it was moved, or a different copy was
installed. Open Agents: a link that is not this
app's is reported there. Installing again replaces a link in the
folder the app installs into; one left somewhere else on your
PATH, such as ~/bin, has to be removed by
hand. A real file called codesearch is never replaced —
the app says so and offers the ln -s to run yourself.
Scheduled reindexing only runs while the app does. Launch at login, under Settings → General, is what keeps it on time.
Searching when no profile has been indexed yet says so, and a
profile named with --profile that has no index is
refused rather than returning nothing. If the tool reports that
CodeSearch answered in a form it does not understand, the app and
the tool are different versions: quit CodeSearch, open it again, and
retry.