DocoAlpha cdf9039 · 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 and Gemini CLI load them at every session with the Doco hook below, and other agents keep a short version in their custom instructions.

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

## Doco

This project keeps its shared memory in Doco (https://doco.to): 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?", using your multiple-choice question 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 already named the workspace. If they have none, send them to https://doco.to/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.

### The duties

Four duties hold in every thread that uses Doco. Each collection's policies refine how, never whether.

1. **Load context first.** 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.
2. **Record the conversation.** Keep one Log per chat in the workspace's Agents chats collection, captured with `doco_capture`, superseded with `doco_changeset` as the chat goes on: who took part, what was asked, what came of it, what was left open, and the ids of the nodes it produced.
3. **Document every decision.** When a choice is made, `doco_capture` it as a Decision (the question, the choice, the alternatives and why they lost) in Product decisions (what to build and why), Design decisions (UX, interaction, visuals) or Architectural decisions (structure, technology, data). Setting up Doco is not a decision; the Log covers it.
4. **Update the process.** When a decision changes a business process, also change that process's steps, gateways or rules in the Processes collection, citing the decision's id.

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 first, before the duties, 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, and keep to the duties.

1. **Connection.** If Doco's tools (`doco_brief`, `doco_capture`) are missing, ask the user to connect Doco to you as https://doco.to/agents/connect shows and restart you, then stop; never add it or dig through your client's internals yourself. 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://doco.to/workspaces/<handle>` there for the workspace the user picked. Create a collection 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.

Setup is done when Doco's tools answer, `.doco/workspace` is saved, the hook is installed with its token, and the chat's Log is in Agents chats; give the user its link.

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. 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://doco.to/agents/doco-hook.mjs -o .doco/hook.mjs

Claude Code: .claude/settings.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": [
      {
        "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
          }
        ]
      }
    ]
  }
}

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
          }
        ]
      }
    ]
  }
}