---
title: "Organisation context"
---

# Organisation context

Use Govern's Context Platform from the CLI, with workspace binding, the context commands and their JSON and exit codes, the chat's retrieval step, the team work tools, and what is sent.

Govern's Context Platform holds what your organisation knows (indexed code and documents, Team memory, agent instruction files, and the team work registry with its overlaps) and decides who may see what. The CLI reaches it the way the Editor and the Agents app do: the same client code, the same published API, the same rules.

It needs a signed-in session ([Sign in to Govern](https://neuralinverse.com/docs/cli/sign-in/)). Nothing here works, or is sent, while you are signed out.

There are three parts:

- **`neuralinverse context …`** (and `/keystone-context …` in a session): commands with a readable form, a stable `--json` form and documented exit codes, for people, scripts, hooks and CI.
- **The chat's retrieval step:** before each prompt, organisation context for the folder you work in is added to that prompt's request.
- **The agent's team work tools:** `work_declare`, `work_check_overlap`, `work_update` and `work_ack_overlap`.

## The workspace binding

Every feature starts from the **binding** of the working folder: the git repository it is in, and the Govern project that repository belongs to.

- The repository's git files are **read, never run.** No git process is started, so a cloned repository's `core.fsmonitor`, hooks, `include.path` or `url.<base>.insteadOf` cannot run anything or change the address. Files are read with a size limit, no symbolic link is followed, and a configuration git would reject is refused.
- The remote used is `origin`, else the remote the current branch tracks. It is normalised to `https://host/owner/repo` (no user name, password, port, query or fragment), and that address is the only thing about the repository that is sent, to `GET /api/v1/context/project?repoUrl=`. **Govern decides the project** from your own permissions; nothing in the folder names a project or a server.
- Your organisation's **managed policy** can pin repositories to projects, forbid repositories (nothing about them is sent, and every command that would name them is refused with exit code 6), and refuse agents organisation context in folders without a binding.

The binding policy is the managed setting `workspaceBindingPolicy` (JSON text or an object), the same document the Editor uses. It is read only from the managed layer (the managed settings file, the remote policy or the signed organisation policy); a value in user or project settings is dropped with a warning. A policy that does not parse binds nothing until it is fixed.

```jsonc
// managed-settings.json
{
  "workspaceBindingPolicy": {
    "rules": [
      { "repository": "https://github.com/acme/payments", "projectId": "proj-payments" },
      { "repository": "https://github.com/acme-private/**", "forbid": true }
    ],
    "unboundAgents": "refuse"
  }
}
```

`neuralinverse context status` shows the binding, and why a folder is not bound.

## Commands

```text
neuralinverse context status [--json]
neuralinverse context retrieve "query" [--space ID] [--budget N] [--json | --prompt]
neuralinverse context attributions [REQUEST_ID] [--json]
neuralinverse context memory list [--space ID] [--status S] [--kind K] [--query Q] [--limit N] [--cursor C] [--json]
neuralinverse context memory show ID [--json]
neuralinverse context memory accept ID
neuralinverse context work declare --intent "retry logic" [--area PATH]... [--service NAME]... [--work-item URL] [--team ID] [--json]
neuralinverse context work update ID [--intent ...] [--status active|paused] [--area PATH]... [--service NAME]... [--work-item URL] [--json]
neuralinverse context work finish ID [--reason R] [--json]
neuralinverse context work list [--mine] [--all] [--limit N] [--json]
neuralinverse context overlap check --area PATH... [--service NAME]... [--branch B] [--strict-exit] [--json | --advisory]
neuralinverse context overlap list [--all] [--json]
neuralinverse context overlap ack ID
neuralinverse context agent-files effective [--tool claude|codex|agents|gemini|cursor|copilot|windsurf|cline] [--write] [--json]
neuralinverse context watch [--space ID] [--last-event-id ID] [--max-events N] [--duration SECONDS] [--json]
```

In a session, `/keystone-context <the same arguments>` runs the same commands.

### status

The server (verified by discovery now), your organisation (its 12-digit Account ID and name), the binding, whether the binding policy is managed, the chat's retrieval setting, and what the deployment and your own collaboration policy offer (from `GET /api/v1/context/capabilities`; a member that is missing or not exactly `true` counts as off).

### retrieve

One retrieval for the space of the binding: the project's space, else the setting `contextPlatform.defaultSpaceId`, else the organisation's start space; `--space` chooses one. Passages are printed with their citations (`[n] kind source path:lines`). `--prompt` prints the block the chat would add to a prompt, for handing organisation context to another tool's agent.

### attributions

Alias `answer`. Shows the context behind an answer. With no argument it uses the last answer that used organisation context (its request id is kept in `<configDir>/context/last-answer.json`, ids only, mode 0600). It asks `GET /api/v1/context/attributions/{requestId}` and prints what Govern recorded: the client, the time, the number of chunks and tokens, and the position in the evidence chain. A record written a moment ago can still be missing ("not recorded yet": try again). An id you may not see reads the same as one never recorded.

### memory

Team memory of the space, read-only, except `accept`. Accepting is a person's decision: the CLI shows the text exactly as it would be accepted (hidden characters spelled out) with its SHA-256, and accepts only when you type the first 12 characters of that hash on a terminal.

### work and overlap

The team work registry, advisory only. Areas are names (paths relative to the working folder, patterns with `*`, service names), never contents. A secret file's name (`.env`, keys, credentials, in any spelling) is dropped before the request, and the count of what was left out is shown.

- `overlap check` registers nothing. It exits `0` even with overlaps, or `3` with `--strict-exit`. `--advisory` prints the delimited advisory an agent can be given.
- `overlap ack` needs a person on a terminal.
- A declared item is kept alive by the server's time-to-live (shown in the answer). Update or finish it, or let it expire.

### agent-files effective

The agent instruction files in force for you and the bound project (organisation, department, team, project, repository and personal layers), as one text with provenance. `--write --tool T` writes it to that tool's local override file (`CLAUDE.local.md` for `claude`, `AGENTS.override.md` for `codex` and `agents`), never to a tracked file and never through a link, after adding the file to `.git/info/exclude`. A tool without a local override file gets nothing written.

### watch

The organisation's event feed (`GET /api/v1/context/events`, server-sent events), resumed with `Last-Event-ID` after a disconnect. At most `--max-events` events (default 1000) and `--duration` seconds (default 3600, at most 86400); Ctrl+C stops it. When Govern cannot replay from the id you gave, the feed reports `resume_gap` and continues from now. The last id is printed at the end so a later `watch --last-event-id` continues there.

### Decisions that need a person

Accepting Team memory and acknowledging an overlap are decisions recorded under your name. The CLI asks for them only when standard input and standard error are both a terminal. From a pipe, a script, CI or an agent's shell they are refused (exit code 4) and nothing is sent. There is no `--yes`.

### JSON output

Every `--json` object has a `schema` member; a breaking change bumps its version.

| Command | `schema` |
|---|---|
| status | `neuralinverse.context.status/v1` |
| retrieve | `neuralinverse.context.retrieve/v1` |
| attributions | `neuralinverse.context.attributions/v1` |
| memory list | `neuralinverse.context.memory.list/v1` |
| memory show | `neuralinverse.context.memory.entry/v1` |
| work declare, update, finish | `neuralinverse.context.work.item/v1` |
| work list | `neuralinverse.context.work.list/v1` |
| overlap check | `neuralinverse.context.overlap.check/v1` |
| overlap list | `neuralinverse.context.overlap.list/v1` |
| overlap ack | `neuralinverse.context.overlap.ack/v1` (`outcome`: `acknowledged`, `already`, `declined`, `unknown_overlap`, `failed`) |
| agent-files effective | `neuralinverse.context.agentfiles.effective/v1` |
| watch | One line per event, `neuralinverse.context.event/v1`, and a last line `neuralinverse.context.watch.end/v1` |
| any failure | `neuralinverse.context.error/v1`: `error {code, reason}` |

### Exit codes

| Code | Meaning |
|---|---|
| 0 | Done (including overlaps found without `--strict-exit`) |
| 1 | Govern could not be reached, answered with an error, or the answer could not be used; no space or repository applies |
| 2 | Usage error |
| 3 | `overlap check --strict-exit` found open overlaps |
| 4 | A decision that needs a person, without a person on a terminal, or the person declined |
| 5 | Not signed in, or the session ended |
| 6 | Refused by your organisation: a policy refusal (403), a forbidden repository, or the feature off for you (including `contextPlatform.enabled: false`) |

## The chat's retrieval step

While you are signed in and `contextPlatform.enabled` is not `false`, every prompt is preceded by one retrieval for the space of the binding (the agent rule of the managed binding policy applies). The passages are added to **that prompt's request only**:

- as a block that says it is untrusted data, between markers with a boundary that is new for every block (a passage that contains the boundary is left out);
- each passage numbered and labelled with its source;
- within the budget `contextPlatform.tokenBudget` (256 to 32000, default 4096);
- never saved with the session or sent again with a later prompt.

A notice lists the citations. A refusal by your organisation's policy (403) is shown and never retried or routed around. When Govern cannot serve (no answer, 503), the prompt goes out **without** organisation context, the reason is shown, and the CLI asks again only after a back-off. No local file is ever used instead.

When the model provider is your organisation's Govern gateway (provider `keystone`), each model call of the prompt carries `X-Keystone-Context-Request-Id` with the retrieval's id, which joins the call to the retrieval in Govern's evidence chain. No other provider receives it.

```jsonc
{ "contextPlatform": { "enabled": true, "tokenBudget": 4096, "sourceKinds": ["codebase", "docs"], "defaultSpaceId": "space-..." } }
```

Your prompt's text is sent to Govern (`POST /api/v1/context/retrieve`) for this. Set `"contextPlatform": { "enabled": false }` to stop it; your organisation can set it in managed settings.

## The agent's team work tools

While you are signed in, the agent has the work registry tools of the Editor's agents:

| Tool | What it does |
|---|---|
| `work_check_overlap` | Before editing: does another team's work touch the same files, symbols or area? Registers nothing |
| `work_declare` | Register this session's work with a short neutral intent and the areas it will change |
| `work_update` | Change areas, intent, or `active` and `paused` |
| `work_ack_overlap` | Acknowledge an overlap, only after your answer on the terminal |

Names only; secret file names are dropped before anything is sent. The advisory comes back between data markers and never blocks anything. The CLI registers an item only when the agent declares one, and finishes it when the session ends.

`work_ack_overlap` acknowledges only when **you** answer "Acknowledge" to the question it asks on your terminal. A permission rule, `full-auto` mode, `--print`, a helper agent or a program driving the CLI cannot give that answer, and the advisory stays open.

## What is sent

Only to the API address of your verified Govern deployment, with your access token (refreshed once after a 401, never printed) and `X-Keystone-Client: neuralinverse-cli/<version>`; https only, no redirect followed, every answer bounded.

| Request | When |
|---|---|
| `GET /api/v1/context/project?repoUrl=https://host/owner/repo` | To bind a folder (also without `repoUrl`, for the organisation's start space) |
| `GET /api/v1/context/capabilities` | `status` |
| `POST /api/v1/context/retrieve` | `retrieve`, and each prompt of a chat |
| `GET /api/v1/context/memory/entries`, `GET .../entries/{id}`, `POST .../entries/{id}/accept` | `memory` |
| `POST /api/v1/context/work/items`, `GET` and `PATCH .../items/{id}`, `POST .../items/{id}/heartbeat`, `POST .../items/{id}/finish`, `POST /api/v1/context/work/overlap/check`, `GET /api/v1/context/work/overlaps`, `POST .../overlaps/{id}/ack` | `work`, `overlap`, and the agent's tools (repository as `host/owner/repo`, branch, commit, intent label, area names) |
| `GET /api/v1/context/agent-files/effective?project=&tool=` | `agent-files`, and the first prompt of a chat (then every 5 minutes, or when the feed says the files changed) |
| `POST /api/v1/context/agent-files/sessions` | Once per set of instruction files a chat used |
| `GET /api/v1/context/attributions/{requestId}` | `attributions` |
| `GET /api/v1/context/events` | `watch` |

For the platform itself, see [Context](https://neuralinverse.com/docs/context/).
