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 it's done (thread-reports), and can work in a git worktree of its own (worktrees). A profile without: ['thread-tools'] has none of the tools; without: ['thread-reports'] keeps them, with no reports either way.

The tools

Tool Parameters What it does
thread_start prompt (its first message), title, cwd, profile, worktree, machine Starts a child: a thread nested under this one in the sidebar, with an agent of its own. Answers its link and id.
thread_read thread, wait, machine Where a thread stands (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>):, that goes in when that thread is next free.
thread_list machine This thread's parent, its children and the other threads in its project, each with its status and folder. On another machine, its newest 30.
thread_archive thread (this one if left out) 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: thread_start and thread_list give them. In a message, [its title](thread:<id>) shows as a link to the thread.

Extensions do the same from code with superego.threads (start({ prompt, cwd, profile, parent, options }), send, lastAnswer, idle, archive: cheat sheet). There a worktree is asked for as options: { worktrees: true }, which is what the tool's worktree: true sends.

What a child gets

With machine, it starts on that machine, in cwd there or that machine's default folder. It's nobody's child there: 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 it:

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 it's unarchived, and its children are left as they are.

So merge a child's branch before archiving it, or its branch stays.

A lead profile

A profile whose agent splits a task, hands the parts out, and reviews what comes back. It writes 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