gh is signed in as (read at startup with gh api user), on any GitHub repo: start it with the directory the repo is checked out in, and it works that repo and every submodule checked out in it (a repo without submodules is fine). Every few minutes it checks GitHub and works these kinds of job with coding agents (an orchestrator and workers, each on the harness and model you choose; Claude Code with Opus 5.5 by default):
| spec | the person’s
@psychiatrist spec [notes] comment on an issue | the orchestrator writes the spec read-only with the spec skill (problem, solution, user stories, implementation and testing decisions; open questions for the person), then breaks it into tracer-bullet tickets with the tickets skill, each with its blockers (both skills given in its task in full) | the spec and its tickets as one item: approving files the spec, then each ticket blockers first, with a Blocked by: #n line holding real numbers and Part of #spec |
Manual triggers are the person’s own comments containing @psychiatrist build, @psychiatrist review or @psychiatrist spec (anywhere in the comment, the rest of the line is extra instructions); comments the bot posted for them never count. Every PR, issue and commit header the bot writes is a Conventional Commit, type(scope): description as in the repo’s history: the agents’ reports are rejected until they are, and the graph fixes up any title that slips through.
It never merges, and nothing reaches GitHub except branch pushes and what you approve:
- Agents cannot push, write to GitHub (
ghwrites,gh api, curl to the API), check out a protected branch, or bypass git hooks: those tool calls are refused before they run (refusalinpackages/core/src/guard.ts, the guard every SDK session passes). The orchestrator also cannot edit files or change the repository. MCP tools run only when their server’s entry lists them (mcpRefusal): psychiatrist’sgatherfor every agent andapplyfor workers, and codegraph’s read tools. - The graph pushes only
bot/…branches or the head of your own PR it is fixing, neverdev,main,master,development(or other protected names), never forced (mayPush,pushinpackages/core/src/graph.ts). - Besides branch pushes and what you approve, the bot changes GitHub in two ways only: a ticket it schedules after others gets a
blockedlabel and a section of its own at the top of its description (<!-- psychiatrist:blocked -->: what blocks it and why), both removed when its blockers land and it starts; and/claimassigns an issue to you on your confirmed click. - Approving a HITL item runs exactly one command:
gh pr create,gh issue create,gh issue commentorgh pr review(postOfinpackages/core/src/tracker.ts, run as gh commands bypostCommandinpackages/core/src/github.ts). There is no merge, close or edit anywhere in the code. - Never-agent repos (
neverAgentin the repo’s config, below) only ever produce a HITL note, and triage refuses never-agent work elsewhere; the config’srulesgo to every agent.
Attribution
Nothing the bot puts on GitHub credits Claude or Claude Code. Agent sessions run with Claude Code’s attribution off (its commit trailer replaced), agents are told never to add it, and the graph enforces it: before every push it rewrites the commits not yet on GitHub so each carriesCo-authored-by: psychiatrist <…> and no Claude trailer or footer (signCommits in packages/core/src/graph.ts; trees, authors and dates unchanged, pushed history never touched). Every HITL item is signed when it is queued, so what you read is what posts: comments and review summaries end with 💊 Diagnosis by @psychiatrist, PRs and issues with 🧬 Synthesized by @psychiatrist (packages/core/src/sign.ts).
Waves
After each scan, the new issues the bot will build go to the orchestrator first (one read-only turn,planPrompt in packages/core/src/prompts.ts), together with any still waiting. It gives each ticket its blocking edges the way the tickets skill does: a ticket waits for another when it needs that ticket’s code or both change the same files or resources; everything else runs side by side. The graph runs them in waves (packages/core/src/plan.ts): every ticket whose blockers are built starts (at most MAX_PARALLEL at once) and the rest show “waiting · after …” on the Work tab. A ticket blocked by one in the same repo starts from that ticket’s pushed branch, and its PR targets that branch (a stacked PR: merge the first one first). A blocker that gets stuck holds its dependents until it is fixed or they are /skipped. Blockers outside the plan count too: a ticket’s own Blocked by: lines and anything the orchestrator finds it needs merged first (an unmerged PR, another team’s issue) are checked on GitHub every scan, and the ticket starts once they are closed. Stack or wait: for each ticket the orchestrator decides whether to build on one unmerged blocker in the same repo (a ticket the bot built, or an open PR that is close to done, not a draft or a fork): the ticket then starts once that branch exists, builds on it, and its PR merges into it (a stacked PR; GitHub retargets it to the base when that branch is deleted after merging). Every other blocker is waited out until it has merged into the base (its issue or PR closed; every bot PR closes its issue). While it waits a ticket carries the blocked label, a blocked-by-#n (or blocked-by-repo#n) label per blocker, and the bot’s section at the top of its description; all three go when it unblocks, and a blocked-by-… label no open issue uses any more is deleted from the repo. An issue that an open PR already closes (any PR, anyone’s, read from the open PRs’ closing keywords each scan; GitHub’s own link only covers PRs into the default branch) is not built: it shows as “PR open”, and is built only if that PR is closed without merging. Each planned ticket is labelled with its wave (wave-1, wave-2, …: its level in the plan, and never wave 1 while it waits on something outside the plan), the label replaced when a later plan moves it. The orchestrator sees every open PR in the tickets’ repos, so a ticket that needs one of them merged first (anyone’s) lists it and waits until it has merged. Every PR the bot opens for an issue closes it: the graph adds Closes #n (or owner/repo#n when the PR is in another repo, say a submodule) when the agent’s body lacks it. Every waiting ticket is marked on GitHub: the blocked label and the bot’s own section at the top of its description say what blocks it and why; both go when its blockers land and it starts. A blocker whose PR has merged is not built on: the ticket starts from the base branch, which holds its work. Before anything is built the orchestrator also checks the bot can build it: a ticket that needs code in a repo the bot cannot work in (code AGENTS.md or the config’s rules put elsewhere; never-agent repos; repos that are neither the main checkout nor one of its submodules) is not started. It shows as blocked, and its prerequisite issue goes to HITL to be filed in the repo it belongs in. Follow-up issues the orchestrator proposes name the repo they belong in, are tracer-bullet slices, and start with a Blocked by: line when they need other work first. Workers build each ticket in vertical slices (tracer bullets): the thinnest complete path through every layer first, then wider.
Tokens
Code is found with CodeGraph first: before an agent’s first turn the graph runscodegraph explore with the issue or PR text (one CLI call, no model) and puts the relevant source and call paths in its task, and every agent has the codegraph MCP server, all on one index: the main checkout’s, which covers its submodules (a synced copy per worktree cost about 2.5 GB of disk each). A repo without a .codegraph/ index gets no codegraph: its agents search with Grep, Glob and rg instead. GitHub is read by the graph through its tracker, never by a model: the scan, the assignment check, issue and PR text, linked issues and review comments. Every GitHub read and write goes through the Tracker interface (packages/core/src/tracker.ts): GitHubTracker (packages/core/src/github.ts) is the one module that runs gh, and tests pass a FakeTracker (packages/core/src/fake-tracker.ts) of scripted issues and PRs that records every write. Agents get those facts in their task and cannot call gh or the GitHub API. Agent digests are built from their activity, not by a model. The total of every token used, across restarts, is at the top right (state.sqlite): new tokens apart from cache reads, which cost about a tenth as much.
The agents
Each agent is a session the bot opens with the SDK’sstart() (packages/core/src/index.ts, Sessions), on a harness (packages/core/src/harness.ts): it is started or resumed with its role, model, effort, worktree, skills, MCP servers and the guard, sent turns (each with its own effort and report schema; a worker’s reply turn ends with a plain reply, and the bot’s own prompts say how each turn ends), in the job’s worktree (branch: "head": the graph makes the worktrees), steered with guidance mid-turn, interrupted by a pause, forked into a new session that continues its conversation, and reports its session id and token usage as it goes. Claude Code is the only harness for now (packages/core/src/claude-code.ts, through ai-sdk-provider-claude-code); prompts take the names of its tools (MCP tools, skill loading, file search, web search) from it rather than naming them themselves.
Each role’s harness, model and effort are resolved once at startup (resolveRoles in packages/core/src/roles.ts): ~/.psychiatrist/config.json, the repo’s .psychiatrist.json and the state config, in that order, then the CLI flags (--orchestrator, --worker, --orchestrator-effort, --worker-effort), each winning over the one before. With none set, both roles run claude-code/claude-opus-5-5, the orchestrator at high and workers at medium; the orchestrator’s second and later reviews of a build drop to medium, since they only check what changed, unless its effort is pinned. Unless the workers’ effort is pinned, the orchestrator gives every worker job its effort, among the levels the worker’s model supports (effortChoices and jobEffort in packages/core/src/roles.ts): each ticket’s in its plan, a review fix’s when its review sends the build back, and a feedback job’s or a squash fix’s in one short read-only turn before the worker starts. That turn is the orchestrator’s other exception besides the recheck: it runs at low, since it only picks a level, unless the orchestrator’s effort is pinned or its model has no low. A job it gives none, or a level the model lacks, runs at medium (with no effort set when the worker’s model has no medium, and the prompt says so), and a pin overrides every choice. A squash’s docs pass runs at the workers’ own effort. Activity shows each worker job’s effort and the reason, no reason given when there is none (build repo#12: worker at high (a new scheduler and its tests)). Startup stops, saying what to fix, on an unknown harness, a role not written harness/model, a harness that is not installed or signed in (claude auth status), or a pinned effort the model does not support (from Claude Code’s supported-models list, matched by name, alias, the dated id a short name stands for, or the name without a [1m] suffix; its xhigh is not used). A pin on a model the list lacks runs as given, marked unverified on the startup line. A model with no effort levels runs with none set. Sessions are resumed by their harness session id across passes and restarts (state.sqlite). Every Claude Code session gets:
- the repo’s project settings and
.claude, read from the trusted checkout (projectConfigRoot), never from the branch under work. The orchestrator’s chat is the exception: its session loads no project settings; - the repo’s AGENTS.md: Claude Code loads it in a main-repo worktree, and the graph appends it for submodule work;
- exactly these MCP servers: psychiatrist’s own for the session’s worktree (
psychiatrist mcp, below), codegraph (the repo’s pinned copy, or an installed one; only with an index) and the graph’s owndone/errorreport tools; no.mcp.json, plugin copies or claude.ai connectors; - psychiatrist’s own skills and only those, chat included (below);
- the orchestrator alone reads the web, with Claude Code’s own WebSearch and WebFetch: a worker’s session has them off and the guard refuses them;
- the orchestrator’s sessions are read-only: edit tools are off, and the guard refuses anything that changes the repository;
- no subagents, workflows, scheduling, notifications or questions mid-turn (at most 2 jobs and 2 agents at once,
MAX_PARALLEL; AGENTS.md allows 3).
psychiatrist’s skills
Agents follow ten skills of psychiatrist’s own: build, tdd, spec, tickets, interview, review, pr, commit, merge-conflicts and debug. Each SKILL.md is written from its behavior list in docs/skills alone and ships inside the binary (packages/core/src/skills.ts); nothing is read from the person’s plugins, so the bot needs no skill installed. A repo plugin’s skill of the same name replaces ours (a plugins/<name>/skills/<skill>/SKILL.md in the trusted checkout, with the files beside it; its code-review counts as our review); its other skills are not given. With several such plugins the first by name is used, and startup’s Activity says which plugins it left out and why (repoPlugin in packages/core/src/skills.ts).
Each Claude Code session gets them as a local plugin named psychiatrist, so its skills are psychiatrist:build and so on (placeClaudeCodeSkills in packages/core/src/claude-code.ts). The plugin lives outside every worktree, in a folder of the session’s own: ~/.psychiatrist/state/<owner>/<repo>/sessions/<session title>-<hash>/claude-code/ (the hash keeps titles that differ only in punctuation apart). When the session starts, that folder is removed and built again from the skills alone, and nothing is written through or copied from a symbolic link (a link where the session’s folder goes is removed, not followed). So the skill files never show in git status or reach a commit, and a branch under review cannot commit a plugin (a hook, say) that its reviewer loads. One exposure remains until agents run in the sandbox (docs/adr/0004-native-sandbox-whole-agent-by-default.md): every turn starts a new Claude Code process that loads the plugin folder as it is then, and a worker’s shell can reach the state directory, so a worker on any job could change what a running orchestrator session loads on its next turn. The sandbox closes it by giving each agent only its worktree and a private home. Claude Code’s skills allowlist names exactly those ten, so the repo’s .claude/skills, the person’s own plugins and Claude Code’s built-ins stay hidden. Where a prompt needs a skill’s whole text (build in a worker’s task, spec and tickets in a spec, interview in /create), it reads the same one, the repo plugin’s when it has it.
psychiatrist’s MCP server
psychiatrist mcp --worktree <dir> serves psychiatrist’s own MCP server (name psychiatrist) on stdio, from the same binary, for an agent’s harness to start; it is not for people (without --worktree, psychiatrist mcp is still the bot on a repo directory named mcp, and a missing or empty worktree stops it with a one-line error). Every path it takes is confined to that worktree: one outside it, through .., an absolute path or a symbolic link, is refused by both tools, and so is anything in .git, however it is spelled (a case-insensitive disk takes .GIT for .git). It has two tools (packages/core/src/mcp.ts):
gatherreads several files, line ranges (path:10-40; a range outside the file is refused, saying how many lines it has), sections (path#name: a markdown heading’s section, or a code declaration with its leading comments) and directories, and runs several text searches (git grepover tracked and untracked files, with context lines; patterns are Perl-compatible regexes unlessliteral; an empty pattern, or one git refuses, makes the call an error), in one call, line-numbered and cut at an output cap (40,000 characters unless the call setsmax).applymakes search/replace edits (each must match once, or setall; an empty search only creates a file that does not exist) or applies a unified diff (creating, deleting and renaming files, a rename keeping the file’s mode and never replacing a file that exists; hunks found by their context, so wrong line counts do not matter) across several files, then runsverifyin the worktree. A file named two ways (a.tsandA.tson a case-insensitive disk) is one file, a new one too. Every edit is worked out before anything is written, so one that does not fit changes nothing; a write that fails partway (a full disk, a read-only file) puts every file back, the one it failed on included, each on its own, and removes the directories it made; the reply names any file it could not put back. verify ends when its command exits: anything it left running in the background is stopped, and a second later the call ends even if something outside its process group still holds its output. When verify fails or runs past its timeout, or the server is stopped while it runs, every file it touched is restored byte for byte (mode included, new files and their directories removed) and the failing output comes back.
packages/core/src/mcp-main.ts; mcpServer in packages/core/src/mcp.ts). One left by a run that crashed (its parent gone) is stopped when its worktree is next checked, as codegraph’s are, so it never holds a worktree. Calls run one at a time. apply passes the guard: the orchestrator cannot call it, and its verify command is checked like any shell command. Activity shows gather as a read and apply as an edit naming its files and verify command.
Workers end a turn with a plain reply (what changed, checks, anything under QUESTIONS:). The orchestrator answers questions itself from the issue, code and docs; only one it cannot answer goes to HITL, and the job waits for your answer.
Using it
claude) and gh signed in (the bot works for that user). For 24/7, run it in tmux (tmux new -s psychiatrist 'psychiatrist ~/code/some-repo'); without a terminal it prints its event log instead of the screen.
Any repo
At startup, as it reads your login, it detects the project from the directory (the first argument, else where you ran it; any directory inside a checkout works): its git root, its GitHub repo (gh repo view, from the origin remote) and default branch, its submodules (each with its own GitHub repo, from its origin remote: they may belong to other owners; one not on GitHub is left out), the checks the graph runs before a review (a turbo workspace’s affected lint, typecheck and test; else the lint, typecheck and test scripts of its package.json with its package manager; else cargo test or go test ./...; else none, and the agents run the repo’s own), its own Claude plugin under plugins/, and codegraph when the repo has an index (its pinned copy, or an installed one). The first Activity line says what it found; the next names each role’s harness, model and effort (pinned or default, and for workers whether the orchestrator picks it per job).
Optional settings, from a .psychiatrist.json in the repo or a local ~/.psychiatrist/state/<owner>/<repo>/config.json here (which wins):
psychiatrist init [dir] [--yes] writes the last four into the repo’s .psychiatrist.json (packages/core/src/init.ts). It checks each harness psychiatrist runs as startup does (installed, signed in by claude auth status’s JSON on stdout) and lists the models of each one that is ready with their effort levels among the four (Claude Code’s supported-models list, each model once by the id its alias resolves to); a harness that is not ready is shown with what to run, and when none is ready init stops before asking anything. It then asks for each role’s harness/model (a number from the list, or any harness/model typed, aliases included) and effort (unpinned, or one of the levels the model supports; a model with none is not asked), the file’s own settings preselected, else claude-code/claude-opus-5-5 unpinned (a pin the chosen model lacks is dropped, and init says so); --yes takes those without asking. Each answer is checked at its prompt (a known harness that is ready, harness/model form, a level the model has) and asked again when it cannot run. Answers are read a line at a time, so piped answers all count; stdin closing (or ctrl+c) before the last one stops init with nothing written. What init writes is checked as startup reads it, under ~/.psychiatrist/config.json and the repo’s state config (resolveRoles over the same layers), before anything is written, and init names any role key another of those files sets over what it wrote. The file is merged: every other key stays, a byte order mark is accepted, and an effort left unpinned removes the file’s pin. A file that is not a JSON object, or a directory in its place, stops init untouched. Codex, opencode and pi appear in init as psychiatrist learns to run them.
The HITL queue, jobs, sessions, activity and token totals for every repo are kept in ~/.psychiatrist/state.sqlite. On first use, the practice imports its old state files from ~/.psychiatrist/state/<owner>/<repo>/ and leaves them there as backups. Each repo still has its own run logs under ~/.psychiatrist/runs/<owner>/<repo>/. For example, a monorepo whose work targets dev and keeps worktrees elsewhere: { "base": "dev", "worktrees": "~/code/worktrees", "neverAgent": ["payments"], "rules": "Never touch billing code." }.
The HITL tab lists what waits for you: ↑↓ and enter (or a click) open an item. A PR, issue, comment or review has buttons: ←→ chooses, enter or a click runs it. Approve asks once more (enter or click again) before it posts to GitHub as you; Reject puts /reject <id> in the prompt for an optional reason, and enter sends it. A question with options shows them with the recommended one picked: ↑↓ moves, ←→ jumps between questions and on to Submit and Leave parked, enter or a click picks. Each question also has Something else…: focus it and type your own answer in place. The commands work too: /approve <id> (optionally with an edited body), /reject <id> [why], /answer <id> <text>. ctrl+d on an item (open, or selected on the HITL tab) asks once, then deletes it and sends its ticket or PR back through the loop: its record is forgotten and a scan starts, so it is worked as new (a pending question is rejected first, freeing a job that waits on it). For items an update left stale or blocking. The queue is kept in SQLite across restarts.
The Unassigned tab lists open issues nobody is assigned: open issues nobody is assigned in the watched repos (never-agent ones left out), newest activity first. Claim (↑↓ then enter, or a click) asks once more, then assigns the issue to you on GitHub (gh issue edit --add-assignee @me, or /claim <repo#n>), and a scan starts at once: assigned, it is built like any of yours.
/create <idea> starts an interview in the orchestrator’s chat (the interview skill, given in full: one question at a time, with its recommendation, reading the docs and code first); answer by chatting. /create done [repo] (the main repo by default) writes the spec from the interview with the spec skill and breaks it into tracer-bullet tickets with the tickets skill; the spec and tickets wait in HITL as one item, filed blockers first when approved. Glossary terms and ADR-worthy decisions from the interview go into the spec and a docs ticket (the chat cannot write files).
/squash [branch] [PR numbers | all] (the main repo only; branch defaults to the base): takes your finished PRs into that branch (open, yours, not drafts, every check passing, never the branch’s own PR; or exactly the numbers given), squash-merges them one commit each (<title> (#n), stacked PRs after their base) onto a new bot/squash-… branch, runs the repo’s checks and has a worker fix what the PRs break together (two passes at most), documents what the branch lands, pushes it, and puts one PR into the branch in HITL. Its body ends with a Closes #n line for each PR it lands and for each issue those PRs close: merging it closes the issues, and since GitHub’s closing keywords never close PRs, the bot closes the landed PRs itself once the squash PR has merged, each with a comment linking it (a squash rejected in HITL, or closed unmerged, closes nothing; ~/.psychiatrist/state/<owner>/<repo>/squashes.json tracks them). It never merges into the branch itself; PRs that conflict or are not finished are left out and listed. /squash! does the same but takes your PRs whatever their CI on GitHub says (some only pass once merged together): drafts are still left out, the repo’s checks still have to pass on the squashed branch before it is pushed, and the PR body names the PRs that were red on their own.
Every build documents itself: the worker updates the docs its change makes stale (README files, docs/, GLOSSARY.md, an ADR for a lasting decision), and the orchestrator does not accept a build whose docs lag behind.
/reset! opens a dialog, “Are you sure? All data will be lost.” (Cancel focused): confirmed, it stops every agent, erases this repo’s state (the HITL queue, job records, sessions, activity, transcripts, token totals, squash tracking; its config.json stays) and every run’s logs, and starts a fresh run in the same terminal. Worktrees stay, as they may hold unpushed work.
Other commands: /pause, /resume, /run (scan now), /skip <job>, /guide <text>, /active, /help. Typing anything else talks to the orchestrator.
Each job gets a worktree in a checkout-specific subdirectory of the project’s worktrees folder, with node_modules cloned copy-on-write. An existing worktree directly in the project’s folder can still resume if Git lists it for that checkout. Worktrees are removed once the job’s branch is pushed: after an issue’s PR goes to HITL, after a fix is pushed to your PR, after a code review is drafted. A job that gets stuck commits its unfinished work, pushes it to its bot branch and removes its worktree too; only when the hooks refuse that push does the worktree stay, to resume next time. Every scan sweeps the worktrees of finished jobs and any worktree whose work is all on GitHub. With less than 5 GB free (the minFreeGb setting) no new job starts, and a full disk never crashes the app: state and log writes that fail are tried again later.
Between a worker’s reply and the orchestrator’s review the graph runs two checks itself, with no model: the branch must change something, and the repo’s checks (detected or configured, as above) must pass. A pass that fails either goes straight back to the worker with the output, so no review turn is spent on it, and the review is told the checks passed so it doesn’t rerun them.
The screen is built with OpenTUI (@opentui/react, on Node’s FFI): a header, Work / HITL / Flow / Debug tabs, the orchestrator’s chat on the right, and the prompt. Tickets, PR bodies, reviews and the orchestrator’s replies render as markdown, tables included. Lists scroll with the wheel or PgUp/PgDn, links open with a click (cmd+click in some terminals), and dragging over text copies it. Per run: runs/<stamp>/ (events, flow, debug, agent logs). Per job across runs: state/transcripts/.