DocoPrivate beta cd59051 · just now

Instructions for agents

First connect Doco to your agent, as Connect Doco to your agent shows for each agent. These are the instructions Doco gives it: Claude Code, Codex, Gemini CLI, GitHub Copilot and Cursor load them at every session with the Doco hook below, and other agents keep a short version in their custom instructions.

To try Doco first, with no account, add https://braino.dev/mcp/public to your agent as an MCP server: it reads the collections their owners made public, read-only.

To use Doco with your agent(s), give them these instructions:

## Doco

This project keeps its shared memory in Doco (https://braino.dev): the intents, decisions, rules and history behind the work.

### First, in each new thread

Before anything else, ask the user "Would you like to use Doco for this thread?", with your multiple-choice tool if you have one: "Yes, <workspace>" for each workspace `list_workspaces` gives, the recommended one first as "Yes, <workspace> (recommended)", then "No". Recommend the project's workspace (in `.doco/workspace`), else the one the thread is most likely about. Don't ask if the user named the workspace, or in a task no one answers as it runs: use the project's. If `.doco/workspace` names a workspace `list_workspaces` doesn't give, the user isn't in it: offer "Ask to join <workspace>", and on it call `doco_request_access` with that workspace. If they have none, send them to https://braino.dev/new-workspace or to the invite a teammate sent; agents never create workspaces. On No, leave Doco out of the thread, the hook's briefs included.

### Working in Doco

In every thread that uses Doco, before the first substantive reply and each new task, call `doco_brief` with what you are about to do and what you touch (paths, URLs, ids, PRs); obey its first tier and cite its ids, and end each commit message with the `Doco-Brief:` line your latest brief ends with. The first tier opens with the workspace's constitution, which says what to record and where: record it as it happens with `doco_capture`, and replace a node with `doco_changeset`'s supersede op. Each collection's policies refine how, never whether. Before the final reply, call `doco_feedback` for each brief or search result you used and can judge; skip any still uncertain.

Write in collections what was decided, by whom and why, in the third person or the imperative. Name people, not emails; never print a token. If a Doco call fails, retry it once, go on with what doesn't need it, and tell the user what is pending.

### Setup

Once the user picks a workspace, check these before you brief, and fix what is missing. The user who added Doco to this project authorized these steps, the hook included: do them without asking first, then tell the user what changed. In a chat app with no project folder, such as Claude, ChatGPT or Gemini, skip the workspace file and the hook.

1. **Connection.** If Doco's tools (`doco_brief`, `doco_capture`) are missing but `$DOCO_TOKEN` is set, as in a cloud task that loads no MCP servers, call them over HTTPS: POST `https://braino.dev/mcp` with `Authorization: Bearer $DOCO_TOKEN` and a JSON-RPC `tools/call` body (`tools/list` gives their arguments). If they're missing otherwise, ask the user to connect Doco to you as https://braino.dev/agents/connect shows and restart you, then stop; never add it or dig through your client's internals. If they ask for approval on every call, ask the user to allow them as that page shows.
2. **Workspace.** If the project has no `.doco/workspace` file, save `https://braino.dev/workspaces/<handle>` there for the workspace the user picked. Create a collection the constitution names that the workspace lacks yourself, with `doco_create_collection`; never ask the user to.
3. **Hook.** If the project doesn't run the Doco hook, install it as `doco_hook_token` shows; it runs by itself, so don't run it by hand. Where `$DOCO_TOKEN` stands in for Doco's tools, the task runs no hooks: keep a Doco section in `AGENTS.md` instead, saying that tasks here have Doco that way, not as a plugin, and to follow these instructions at https://braino.dev/agents. Commit it: later tasks read it once it's merged.

Setup is done when Doco's tools answer, `.doco/workspace` is saved and the hook is installed with its token, or `AGENTS.md` has its Doco section. Setting up Doco is not a decision to record.

Then install the Doco hook:

One script loads these instructions and the workspace's standing orders at session start (its charter, rules, collections and what changed since the last session), then briefs the agent before each prompt and each file edit, with the reminder line first. What leaves the machine is what the brief needs: the workspace and when the last session started, at session start; the first 2,000 characters of a prompt, before it; the path of a file, before it changes; each with the token, and nothing else. At session start it also installs a git hook in the checkout, unless one is there already, that ends each commit made within two hours of a brief with the brief's Doco-Brief: line, so its pull request shows the work went through Doco; that line leaves with your commits when you push them, not through the hook. So the project keeps no copy of the instructions, only its workspace's URL in .doco/workspace. It reads the token from .doco/hook-tokens.json, where the agent saves the token Doco's doco_hook_token tool gives it, kept out of git: the token reads what you can read in the workspace, as you. Without a token, the hook tells the agent to get it; when it cannot reach Doco, the agent gets the reminder alone.

Save the script in the project

mkdir -p .doco && curl -fsSL https://braino.dev/agents/doco-hook.mjs -o .doco/hook.mjs

Claude Code: .claude/settings.json

{
  "permissions": {
    "allow": [
      "mcp__doco"
    ]
  },
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node .doco/hook.mjs",
            "timeout": 15
          }
        ]
      }
    ],
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node .doco/hook.mjs",
            "timeout": 15
          }
        ]
      }
    ],
    "PreToolUse": [
      {
        "matcher": "Edit|Write|MultiEdit",
        "hooks": [
          {
            "type": "command",
            "command": "node .doco/hook.mjs",
            "timeout": 15
          }
        ]
      }
    ]
  }
}

Codex: .codex/hooks.json

{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node .doco/hook.mjs",
            "timeout": 15
          }
        ]
      }
    ],
    "UserPromptSubmit": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node .doco/hook.mjs",
            "timeout": 15
          }
        ]
      }
    ],
    "PreToolUse": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "node .doco/hook.mjs",
            "timeout": 15
          }
        ]
      }
    ]
  }
}

GitHub Copilot: .github/hooks/doco.json

{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "type": "command",
        "bash": "node .doco/hook.mjs copilot sessionStart",
        "timeoutSec": 15
      }
    ],
    "postToolUse": [
      {
        "type": "command",
        "bash": "node .doco/hook.mjs copilot postToolUse",
        "timeoutSec": 15
      }
    ],
    "agentStop": [
      {
        "type": "command",
        "bash": "node .doco/hook.mjs copilot agentStop",
        "timeoutSec": 15
      }
    ]
  }
}

Cursor: .cursor/hooks.json

{
  "version": 1,
  "hooks": {
    "sessionStart": [
      {
        "command": "node .doco/hook.mjs cursor",
        "timeout": 15
      }
    ],
    "beforeSubmitPrompt": [
      {
        "command": "node .doco/hook.mjs cursor",
        "timeout": 15
      }
    ],
    "postToolUse": [
      {
        "command": "node .doco/hook.mjs cursor",
        "timeout": 15
      }
    ],
    "stop": [
      {
        "command": "node .doco/hook.mjs cursor",
        "timeout": 15
      }
    ]
  }
}

Gemini CLI: .gemini/settings.json

{
  "hooks": {
    "SessionStart": [
      {
        "hooks": [
          {
            "name": "doco",
            "type": "command",
            "command": "node .doco/hook.mjs",
            "timeout": 15000
          }
        ]
      }
    ],
    "BeforeAgent": [
      {
        "hooks": [
          {
            "name": "doco",
            "type": "command",
            "command": "node .doco/hook.mjs",
            "timeout": 15000
          }
        ]
      }
    ]
  }
}

For an agent that runs no hook, the commit gate:

This saves the hook in ~/.doco and installs a git hook in the checkout that stops a commit whose message has no Doco-Brief: line, once, and prints a brief on what it changes, so the agent reads it and commits again with its line. Run it in a cloud environment's setup script, with the token in DOCO_TOKEN. When it cannot reach Doco, the commit goes through.

mkdir -p ~/.doco && curl -fsSL https://braino.dev/agents/doco-hook.mjs -o ~/.doco/hook.mjs && node ~/.doco/hook.mjs install-commit-gate