> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nekt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Context

> Teach your AI agents how your business runs so their answers match your definitions and rules.

Context is a library of business knowledge that grounds Nekt's AI in your organization's definitions. You write documents that explain what your metrics mean, which records count as paying customers, how the stages of your funnel are defined — and every agent that queries your data reads those documents before generating SQL.

Without Context, agents have to guess from raw table and column names. With Context, they answer questions the way you would.

### What's in a context document

Each document combines two things:

* **Prose** that describes a metric, segment, rule, or definition in plain language.
* **Annotations** that link the prose to specific resources in your workspace, so the AI knows exactly which tables, fields, and pipelines the definition refers to.

Annotations can reference:

| Annotation       | Links to                                           |
| ---------------- | -------------------------------------------------- |
| Table            | A table in the Catalog                             |
| Field            | A column inside a table                            |
| Layer            | A storage layer in the Lakehouse                   |
| Query            | A saved [Query](/queries/overview)                 |
| Notebook         | A saved [Notebook](/notebooks/overview)            |
| Source           | A [Sources](/sources/overview) connector           |
| Destination      | A [Destinations](/destinations/overview) connector |
| Context document | Another document, for cross-references             |

When an agent retrieves a document, the annotations bring in the resolved resource names, layers, and descriptions automatically — so the model gets both the business definition and the underlying schema in one place.

### Creating a context document

Open **Context** from the sidebar. You'll see two views:

* **All documents** — every context document in your workspace.
* **Templates** — starter prompts that help your agent draft your first documents.

<Steps>
  <Step title="Start from a template or blank">
    Pick a template that matches what you want to document, or click **New document** to start from scratch. If you don't know where to begin, the *Don't know where to start?* template lets your agent explore your workspace and propose what to document first.
  </Step>

  <Step title="Write the definition in prose">
    Explain the concept the way you would to a new analyst. Focus on intent — what counts, what doesn't, why — rather than how the SQL should be written.
  </Step>

  <Step title="Add annotations">
    Reference the tables, fields, layers, queries, notebooks, sources, or destinations the definition depends on. Annotations keep the document anchored to real resources as your warehouse evolves.
  </Step>

  <Step title="Save">
    The document is indexed immediately. The next agent question that touches that topic will use it.
  </Step>
</Steps>

### Templates

Nekt ships with starter prompts that cover the definitions most teams need first:

<CardGroup cols={2}>
  <Card title="Revenue & MRR" icon="dollar-sign">
    How revenue is recognized and MRR is calculated, including multi-currency handling.
  </Card>

  <Card title="Active customers definition" icon="users">
    Which subscription statuses count as paying, and the internal orgs that never do.
  </Card>

  <Card title="Sales funnel stage definitions" icon="filter">
    What counts as an MQL, SAL, and SQL, and which lead sources are excluded.
  </Card>

  <Card title="Product usage & credits" icon="chart-pie">
    How customers consume the product, unit conversions, and plan-limit signals.
  </Card>

  <Card title="Cross-cutting rules" icon="list-check">
    The gotchas that apply to every analysis: exclusions, soft deletes, currencies.
  </Card>

  <Card title="Don't know where to start?" icon="circle-question">
    Let your agent explore your workspace and propose what to document first.
  </Card>
</CardGroup>

### How agents use Context

When you ask a question through the [MCP Server](/mcp-server/overview) or any other AI integration, Nekt runs a semantic search over your context documents and feeds the most relevant ones into the SQL generation step. The agent reads the business rules first, then writes a query that respects them.

This means the same question — *"What was revenue last month?"* — produces different SQL for different organizations, because each organization's definition of revenue lives in its own context library.

### Best practices

<Note>
  Prefer prose plus annotations over raw SQL. Describe what a metric *means*, not how to compute it. Schemas change; definitions don't.
</Note>

Keep documents focused. One document per concept is easier to retrieve precisely than a single document covering everything.

Cross-reference instead of repeating. If *active customers* is defined in one document, link to that document from others rather than re-explaining the rule.

Update documents when business rules change. A stale definition is worse than no definition — the agent will follow it confidently.

### Programmatic access

AI agents can also create, update, and delete context documents through the MCP Server. See [`create_context_document`](/mcp-server/tools#create_context_document), [`update_context_document`](/mcp-server/tools#update_context_document), and [`delete_context_document`](/mcp-server/tools#delete_context_document) for the full schemas.
