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

# Context

> Sync your GTM knowledge base — markdown/MDX files — into the workspace context repository with defineContext.

**Context** is your workspace's GTM knowledge base: an ICP definition, personas, positioning, playbooks — the qualitative knowledge that grounds agents and workflows. `defineContext` syncs a local folder of markdown/MDX into the workspace's context repository as code.

## Define context

```ts context/context.ts theme={null}
import { defineContext } from "@cargo-ai/cdk";

export const context = defineContext({ dir: "context" });
```

Everything under `dir` is synced on deploy:

```text theme={null}
context/
├── context.ts
├── icp.md
└── personas/
    └── head-of-growth.md
```

Add a `.md`/`.mdx` file and it's picked up automatically; edit one and it re-syncs.

<Note>
  The sync is **additive** — files added in the UI are left in place. Your code
  is the source of truth for the files it manages, not for the whole repo.
</Note>

## Inline files

Alongside (or instead of) a local `dir`, pass `files` to generate context entries in code — each key is a path in the repo, each value its contents. Inline files are merged over anything synced from `dir`, so they can add to or override it:

```ts context/context.ts theme={null}
import { defineContext } from "@cargo-ai/cdk";

export const context = defineContext({
  dir: "context", // sync a local folder of .md/.mdx
  files: { "generated/icp.md": buildIcp() }, // + inline additions/overrides
});
```

There is one context repo per workspace, so `defineContext` is a singleton.

## From the CLI

```bash theme={null}
cargo-ai context repository get
cargo-ai context graph get        # the knowledge graph derived from context
```
