Superego

Thread tools

An agent hands work to other threads with the thread tools (the bundled thread-tools extension). A thread it starts reports back when done (thread-reports) and can work in a git worktree of its own (worktrees). without: ['thread-tools'] removes the tools; without: ['thread-reports'] keeps them, without reports.

The tools

Tool Parameters Does
thread_start prompt (its first message), title, cwd, profile, worktree, machine starts a child, nested under this thread in the sidebar. Answers its link and id
thread_read thread, wait, machine its status, folder, who started it, its children, and its last answer (clipped at 6,000 characters). wait: true waits until it isn't working (its run ended, or it needs the user); Stop ends the wait. A thread can't wait on itself
thread_send thread, text, machine a message signed From [this thread](thread:<id>):, delivered when that thread is next free
thread_list machine this thread's parent, its children and the other threads in its project, with status and folder. On another machine, its newest 30
thread_archive thread (default: this one) puts a thread away and says what that did (below). Archiving this thread waits until this turn ends
thread_machines none the other machines this one reaches, for machine

thread is an id, from thread_start or thread_list. In a message, [its title](thread:<id>) links to the thread.

From an extension: superego.threads (start({ prompt, cwd, profile, parent, options }), send, lastAnswer, idle, archive; cheat sheet). A worktree there is options: { worktrees: true }, which is what worktree: true sends.

What a child gets

Context its prompt only: nothing of its parent's conversation
Folder cwd, else its parent's (a parent's worktree included)
Profile profile, else the folder's default (the project's, else yours, else none). Never its parent's. A project's profile must be allowed first
Worktree worktree: true: branch superego/<slug> from the folder's HEAD, in ~/.superego/worktrees/<repo>/<slug>. Left out, its profile's options decide; worktree: false overrides them. Outside git, the folder
Model its profile's, else the machine's default

With machine, it starts on that machine (in cwd there, or its default folder) as nobody's child: not nested, no reports. Read it with thread_read and the same machine.

Reports

When a child's run ends, or it stops to ask the user something, its parent gets a message:

From [Fix the login form](thread:812): finished.

The form now validates on blur; tests in login.test.ts.

Archiving

thread_archive takes a thread out of the sidebar. It takes no messages until unarchived; its children stay as they are.

So merge a child's branch before archiving it.

A lead profile

An agent that splits a task, hands out the parts and reviews them, writing no code itself. Its builders run the folder's default profile.

// .superego/profiles/lead/profile.ts
import { defineProfile } from 'superego'

export default defineProfile({
  description: 'Splits a change into parts, hands them out and reviews them',
  prompt: `You lead a change. You don't write the code: threads you start do.

1. Split the task into parts that can go on side by side.
2. Start a thread for each with thread_start and worktree: true. Its prompt is all it sees: the goal, the files
   involved, how to check its work, and to commit on its branch when done.
3. End your turn. Each thread reports back when it finishes or has a question, and that starts your next turn.
4. Review each report. thread_read gives the whole answer and the thread's folder; read its diff there
   (git -C <folder> diff main...HEAD). Ask for fixes with thread_send.
5. When a part is good, merge its branch into main, then archive the thread with thread_archive.
6. Once every part is merged and the checks pass, say what was built.`,
})

packages/cli/skill/thread-tools.md