Why instructions matter
Connecting the CodeAlive MCP server gives an agent new tools — it does not change the agent’s habits. Coding agents ship with built-in exploration tools (Cursor’scodebase_search, Claude Code’s Grep/Glob, Codex’s shell search), and their planners reach for those first. Without an explicit instruction, an agent will happily run local grep over one checkout while a fully indexed, cross-repository semantic engine sits unused.
The fix is a short instruction file in the agent’s native format. This page covers the patterns that reliably work and where to put them for each agent.
Working with BSL codebases? Read the dedicated page — CodeAlive for BSL — first: the word “metadata” has a language-specific meaning, and agent instructions need to account for it.
Know what the instruction controls
Reliable code retrieval has two separate parts: CodeAlive keeps a server-side index of the default branch, while the coding agent must retrieve the right evidence for the task at hand. An instruction file improves the second part. It cannot compensate for a repository that is missing, still processing, or unavailable to the current connection. Start a research task withget_data_sources, passing the task as its query. This confirms the available source boundary and indexing status while narrowing multi-repository work to the most relevant sources. If an expected repository is absent or not ready, the agent should say so instead of searching an unrelated checkout and presenting the result as complete.
Where instructions live
Because Claude Code, Codex, Cursor’s CLI, and many others all read a repo-root
AGENTS.md, one well-written file covers most of your team regardless of which agent each person uses.
Patterns that work
Observations from CodeAlive’s own production prompt and from how other MCP vendors instruct agents converge on a few rules:1. Imperative plus a trigger condition
State when to use the tool, not just that it exists.2. Name the built-in tool you are overriding
Agents fall back to their native tools unless the instruction names them explicitly. This is the single most important pattern — and the most commonly missed one:3. Sequence the tools
Tell the agent what a good exploration looks like as an ordered path, so it doesn’t stop at the first tool:4. Teach the query grammar in one line each
The two most common failure modes are keyword-style semantic queries and question-style grep queries. One line each prevents both:5. Keep always-on context small
Instruction files are injected into every request. Keep the always-on CodeAlive section compact; move detailed examples and troubleshooting into on-demand mechanisms (Cursor’s Agent Requested rules, Claude Code skills). A bloated always-on rule gets skimmed by the model and taxes every prompt.6. Define the local–indexed boundary
The server-side index and the local working tree answer different questions. Use CodeAlive for architecture, cross-repository discovery, default-branch code, and repositories that are not checked out. Use local file tools for uncommitted changes and files the agent is actively editing. Say this explicitly. Otherwise agents tend to overcorrect in one direction: they either ignore CodeAlive and search only the checkout, or use indexed results to make claims about changes that exist only in the working tree.7. Bound the work and require evidence
Efficient retrieval is a short, scoped path rather than a loop of broad searches:Universal snippet
This block works verbatim inAGENTS.md, CLAUDE.md, and .cline/rules.md, and as the body of a Cursor .mdc rule:
AGENTS.md / CLAUDE.md — CodeAlive section
Per-agent specifics
Claude Code
CLAUDE.md routing rules and the search subagent pattern
Cursor
Rule types, and beating the built-in codebase_search
Codex
AGENTS.md placement and a complete example
- Cursor’s built-in
codebase_searchcannot be disabled in the default Agent mode. The working approach is a precedence rule that names it — see the Cursor page. - Codex reads the MCP server’s own
instructionsfield at initialization, and the CodeAlive server ships tool-choice guidance there.AGENTS.mdstill helps: server instructions describe the tools, whileAGENTS.mdsets project-level precedence over built-ins.
Verify it works
After adding instructions, test with a question that used to trigger built-in search:semantic_search (visible in the agent’s tool log), not a local grep. If the agent still reaches for built-ins, strengthen pattern #2 — name the specific tool it used and forbid it for exploration questions.
Do not stop at one successful demo. Keep a small set of representative questions — architecture, exact-symbol lookup, cross-repository flow, and a working-tree change — and rerun them when you change the model, agent, or instruction. Check the tool trace for four quality signals:
- the agent selected CodeAlive before built-in search for indexed-code exploration;
get_data_sourcesselected the intended repository or workspace;- the answer was based on fetched code rather than search snippets alone;
- local tools were used when the claim depended on uncommitted changes.
Related resources
Build a Code Research Agent
Full example prompt for your own agent on the Tool API
CodeAlive for BSL
BSL specifics — the “metadata” dichotomy
MCP Overview
Tool list and connection options
Tips & Tricks
More agent-specific tips