Guides
AI Agent Context Guide
How to keep your AI coding agent grounded in your data context with the ClariLayer MCP: recall before answering, remember corrections, and reconcile against your source.
Your AI coding agent should not guess which table, join, or definition is right. With the ClariLayer MCP installed, it does not have to: it can recall the context you have saved, ground its answer in it, and surface a caveat when a definition has a known mismatch. This guide shows the working loop in practice.
If you have not connected yet, start with the Quickstart — install the MCP into Claude Code, Cursor, or Codex, and confirm the connection. This guide assumes your agent already has the four ClariLayer tools available.
The recall-first loop
The whole value of ClariLayer comes from four moves your agent makes in order:
- recall the relevant context before answering (get_analysis_context).
- answer from the recalled definitions, carrying their status into the response.
- remember anything new it learned or you corrected (remember).
- reconcile a definition against the warehouse when a number looks off (reconcile).
The first move is the one that changes everything. An agent that recalls before answering stops re-deriving your data model from scratch every session.
Make recall the default
Recall is a tool your agent decides to call — ClariLayer exposes it, but it does not force a call. To get consistent grounding, make recall the first thing your agent does for any data question. The cleanest way is a project rule.
In Claude Code or Cursor, add a line to your project rules or CLAUDE.md:
Before answering any question about our metrics, schema, or warehouse, call the ClariLayer
get_analysis_contexttool and ground your answer in what it returns. If a returned entry has acaveat, include that caveat in your answer.
That is the difference between "can recall in-flow" (always true — the tool is there) and "always recalls first" (true because your rule says so).
Reading what recall returns
Each recalled entry comes back with three things your agent should use:
- content — the definition, schema note, saved query, or note.
- provenance — where it came from (
you,sql_import,dbt,query_history), so the agent can tell a hand-saved fact from an imported one. - status —
assertedorcaveat.
Use status to shape the answer. An asserted entry is usable context but not independently checked, so ground on it without presenting it as proven. A caveat entry has a known mismatch, so carry the caveat into the answer. Your agent will not see a verified status today — see Verified vs Asserted for why.
Remember corrections as you go
When you correct your agent — "no, revenue has to subtract refunds" — have it remember that, so the next session starts from the corrected understanding. A remembered entry is saved asserted with provenance you. Remembering is capture, not verification: it stores the claim, it does not check it. That is fine; the point is that your institutional memory stops evaporating at the end of each chat.
Good things to remember: the real join paths, the columns that are in cents, the tables that hold refunds or test data, and the precise inclusion and exclusion rules for the metrics people argue about.
Reconcile when a number looks off
The acute moment is "why don't these two numbers match?" When it happens, have your agent reconcile the relevant definition: it runs the check against any source it can reach — the stored SQL against your warehouse is the common case, not a requirement — captures the result shape, and calls reconcile. A declared-vs-actual mismatch comes back as a caveat; otherwise the entry stays asserted.
ClariLayer never holds your source credentials and never runs SQL server-side — your agent is the connector and sends only the result shape plus any preview rows it chooses to include. Reconcile is how an asserted definition earns a caveat when it has drifted from the data.
A grounded answer looks like this
An answer grounded in ClariLayer carries the definition, its provenance, and its status:
Active Customer means an account with at least one billable subscription in the trailing 30 days, excluding internal test workspaces (saved by you). Heads up: this definition currently has a caveat — when I reconciled it last, the actual result did not match the declared shape, so confirm the window before using this for ARR-facing work.
That answer uses your saved definition, names where it came from, and is honest about its trust state. It does not pretend the raw SQL alone contains the business truth.
It compounds
Every recall, remember, and reconcile adds to a store that is yours. Your agent grounds on more of your context each week, and that context travels across Claude Code, Cursor, and Codex. And that team layer exists today: the Governed Context Edge — org canon, Diff-to-team, adjudication — is in a hand-run private pilot. Request access on the For teams page.
See also
- Quickstart — install the MCP and mint a key.
- recall, remember, reconcile — the verb pages.
- The Context Layer — the mental model.