CLAUDE.md and AGENTS.md: tell your agent to use the graph
By Steven Van ·
Graphify's copy-paste rule for CLAUDE.md or AGENTS.md, plus optional CLI hooks, tells coding agents to query the code graph before grepping.
Agents tend to reach for grep even when a code knowledge graph is connected, and Graphify has published a guide on getting them to use the graph first. The fix it describes is a short rule in the instruction file the agent reads at the start of a session: CLAUDE.md for Claude Code, AGENTS.md for Codex and many other agents, and .cursor/rules/ for Cursor.
What the rule says
Graphify says vague rules such as "use Graphify when helpful" get ignored, and a concrete trigger works better. A rules card on the connect-agent page in Graphify, added on September 20, generates text with your repository filled in. The suggested rule tells the agent to:
- Ask Graphify about the task before the first grep, glob or file read, and open the files it returns first.
- Ask Graphify for a function's callers before changing it.
- Cite the Graphify result (symbol and file path) in its answer.
- Keep using grep for exact strings, such as error messages or config keys.
- Read its own edits from disk, since the graph reflects the default branch.
Committing the file means every teammate's agent reads the same rule.
Hooks in the open-source CLI
The open-source Graphify CLI can also register hooks that fire just before the agent runs a search or reads a file, adding the graph's answer for that search. Graphify's reasoning is that instructions at the top of a long session fade, while a reminder at the moment of the grep does not.
- graphify claude install writes a ## graphify section to CLAUDE.md and registers PreToolUse hooks in .claude/settings.json.
- graphify codex install writes an AGENTS.md section for Codex.
- graphify cursor install writes .cursor/rules/graphify.mdc.
Install with uv tool install graphifyy and graphify update . first. The hooks nudge by default and never block. For Claude Code, setting GRAPHIFY_HOOK_STRICT=1 blocks the first raw read in a session until the agent has queried the graph. Each installer has a matching uninstall, such as graphify claude uninstall. Hooks are not part of the hosted MCP server, where the instruction block does that job.
Checking that it works
Ask a code question without naming Graphify, then read the tool calls. If the first call is a Graphify tool, the rule works. If it is a file search, Graphify suggests tightening the trigger. At the end of a task, the agent can also be asked to list every Graphify call it made, and the list should match the transcript.