BrainoPrivate beta 3e8158c · just now

Instructions for agents

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

To try Braino 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 Braino with your agent(s), give them these instructions:

## Braino

This project keeps its shared memory in Braino (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 Braino for this thread?", using multiple choice: "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 Braino out of the thread, the hook's briefs included.

### Working in Braino

In every thread that uses Braino, 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 Braino 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 Braino authorized these steps, including the hook: do them without asking, then report changes. In a chat app with no project folder, such as Claude, ChatGPT or Gemini, skip the workspace file and the hook.

1. **Connection.** If Braino'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 Braino 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 Braino 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 Braino's tools, the task runs no hooks: keep a Braino section in each repository's `AGENTS.md` instead, saying tasks here have Braino that way, not as a plugin, and to follow these instructions at https://braino.dev/agents. Commit it: later tasks read it once merged. If `~/.doco/hook.mjs` is missing there, tell the user: the environment's install script needs Braino's line (https://braino.dev/agents/connect).

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

Then install the Braino 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, when the last session started and which copy of the script this is, 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 Braino; 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 Braino'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 Braino, 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. Run in the folder above an environment's repositories, it installs the git hook in each, and leaves a Braino section in that folder's AGENTS.md, which a task that starts there reads. When it cannot reach Braino, 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 https://braino.dev