Team
Overview
Autocode is a local-first desktop app for running coding agents. Every task gets its own branch and worktree, where Claude Code, Codex, or a terminal does the work, and you review, integrate, and open a pull request without leaving it.
The Problem
Coding agents are now good enough that the bottleneck is everything around them. Start Claude Code in your repository and your working copy is its. Start a second agent and the two write into the same files; keep working yourself and you’re editing underneath both.
The workarounds are terminal tabs, a stash you hope you remember, and branches named after a passing thought. When a terminal closes, the conversation that explains the code goes with it, and a week later nobody can say which change came from which attempt.
The Rule
A task is a place, not a prompt. Creating one makes a workspace: a branch, a directory, and a record that outlives the session that made it.
Everything follows from that. Agents run inside a task instead of beside your checkout, so no two ever share a working directory. Reopening a task is instant, because the branch, worktree, and sessions are already there. And the app stays out of the two things it sits between: it isn’t a chat window, and it isn’t your editor, which is one click away.
Tasks and Worktrees
Add a local repository and it becomes a project. Creating a task derives a branch from its title, such as autocode/stream-course-chat-answers, and runs git worktree add into Autocode’s own data folder, not your repository. The result is a full checkout at the base branch, with its own index and HEAD, that nothing else touches.
A task can also start from another task, which is how stacked work happens: build the quiz retry in one task, open a second on top of its branch to add citations, and ship each on its own. The base can be changed later, and is saved with the task.
A branch per task
Named from the task’s title, so the graph reads like the task list.
A worktree per task
A full checkout with its own index and HEAD, kept in Autocode’s data folder, not your repository.
Stacked tasks
A task based on another task. Its pull request opens against that task, not main.
Agent Sessions
Inside a task, one click starts Claude Code, Codex, or a terminal in the task’s worktree, through a real pseudo-terminal rendered with xterm.js. The agent starts with the task’s title and description in its prompt, so the task is the brief. Sessions sit as tabs beside open files, each named after its prompt or last command.
Every session keeps a transcript. While an agent writes, the changes panel refreshes at most once a second, so the diff keeps up without rescanning git on every keystroke.

Review
The right-hand panel is the task’s pull request before there is one: what the agent changed, the recent commits, and a commit box. A file’s diff opens as a tab, and one toggle turns it into a CodeMirror editor, so fixing the one line the agent got wrong doesn’t mean switching apps.
Saves are guarded, because an agent may be writing to the same file. A save carries the content you started from, and the main process refuses it if the file on disk has moved on, asking you to review the newer edits instead of overwriting them. Bigger changes go to Cursor, VS Code, or Finder through Open.

Integration
Tasks drift, and so does main. Integrate brings in either the base branch’s latest changes or the committed branch of another task. It won’t start with uncommitted changes, and a conflict marks the task dirty with what conflicted, so you resolve it in the worktree and carry on.

Shipping goes through the GitHub CLI. Push publishes the branch with an explicit refspec, and the pull request opens against the task’s base, which for a stacked task is the task beneath it. Its title and body come from the task, and once it exists the task shows its state.

Architecture
Autocode is an Electron app with a hard line through the middle. The main process owns every side effect: the filesystem, git, SQLite, and the pseudo-terminals. The React renderer reaches them only through a small preload bridge of typed channels, and every payload is checked with Zod in both directions, so a bad response fails as loudly as a bad request.
Durable state lives in SQLite through Drizzle, with migrations applied on startup. TanStack Query holds what comes from the main process and Zustand only what’s on screen, so a task’s status never exists only in the renderer.
Electron main
Every side effect
- FilesystemPaths resolved twice, past symlinks
- gitWorktrees, branches, integrate, push
- SQLiteProjects, tasks, sessions, via Drizzle
- Pseudo-terminalsnode-pty, inside tmux when it’s there
Preload bridge
Typed channels
React renderer
Only what’s on screen
- TanStack QueryEverything from the main process
- ZustandUI state, like the selected task
- xterm.jsRenders the pseudo-terminals
- CodeMirrorDiffs and edits, languages on demand
Provisioning
Creating a workspace is two steps, in a deliberate order. The task and its planned worktree are written to the database first, marked as provisioning, and only then does git run. If the app dies halfway, the plan survives, and on the next launch each task left provisioning is reconciled: a worktree git already knows is adopted, and anything else is provisioned again.
Failure is just as deliberate. A worktree is only removed if this attempt created it, so a retry never deletes something that was already there, and the task keeps the error for the sidebar to show.
let provisionedWorktree: ProvisionedWorktree | null = null;
try {
provisionedWorktree = await gitWorktreeService.createTaskWorktree({
plannedWorktree: resolveTaskWorktreePlan(taskWorkspace),
project,
task: taskWorkspace.task
});
return taskWorkspaceRepository.finalizeTaskWorkspace({
baseRef: provisionedWorktree.baseRef,
branchName: provisionedWorktree.branchName,
projectId: project.id,
taskId: taskWorkspace.task.id,
timestamp: new Date().toISOString(),
worktreePath: provisionedWorktree.worktreePath
});
} catch (error) {
const message = extractErrorMessage(error);
// Only removes the worktree if this attempt created it.
await cleanupProvisionedWorktree(gitWorktreeService, project, provisionedWorktree);
taskWorkspaceRepository.markTaskFailed(taskWorkspace.task.id, message, new Date().toISOString());
throw new Error(message);
}src/main/services/task-workspace-creation-service.ts — provision, then finalize or record the failure.
Base refs get the same care. The preferred base is checked before use, falling back from the default branch to its remote copy to HEAD. An empty repository is refused with a clear message, and a taken branch name gets a numbered suffix instead of reusing someone else’s ref.
Surviving Restarts
An agent halfway through a refactor shouldn’t die because you quit the app. When tmux is installed, each session runs in its own tmux session on a dedicated socket, apart from any tmux you use, and the app only attaches. Quitting Autocode ends the attachment, not the agent.
- Read src/main/services/agent-session-runtime-manager.ts
- Edit handleRuntimeExit: keep the runtime if tmux is alive
- Ran bun test tests/agent-session-runtime.test.ts
- ✓ reattaches to a live tmux session
- ✓ finalizes a session whose tmux exited
Quit the app. The agent keeps working.
async function handleRuntimeExit(sessionId: number, exitCode: number, provider: AgentProvider) {
const sessionName = tmuxSessionNames.get(sessionId);
if (sessionName) {
const alive = await runtimeDependencies.isTmuxSessionAlive(sessionName);
if (alive) {
// The tmux attach process disconnected (app closing or crash),
// but the agent is still running inside tmux. Remove the dead
// runtime without finalizing so reconcile can reconnect later.
runtimes.delete(sessionId);
// ...reattach to the same tmux session
return;
}
tmuxSessionNames.delete(sessionId);
}
const displayName = getAgentProviderDisplayName(provider);
await finalizeSession(sessionId, {
exitCode,
killRuntime: false,
lastError: exitCode === 0 ? null : `${displayName} exited with code ${exitCode}.`,
status: exitCode === 0 ? "completed" : "failed"
});
}src/main/services/agent-session-runtime-manager.ts — the attachment exited, but did the agent?
On launch, every session the database thinks is running is checked. A live one is reattached, with a line in its transcript saying so; one that’s gone is closed as interrupted, with the reason. Without tmux, sessions end with the app, and reconciliation records that honestly.
Transcripts are append-only JSON lines with sequence numbers, written through one queue per session so input, output, and system messages land in order. Reopening a long session reads the file backwards until it has the last screenful. And if a tmux session can’t be cleaned up after a failed start, Autocode won’t start a second process, because two copies of one agent in one worktree is exactly what it exists to prevent.
Boundaries
Every file request names a task and a relative path, and the main process resolves it twice, once as given and again after following symlinks, so a link in the worktree can’t point the editor at the rest of your disk. The window runs with context isolation on and Node integration off.
An app launched from the Dock doesn’t get your shell’s PATH, which is where Claude Code and Codex live. Autocode searches your PATH plus the usual install locations, resolves each CLI once, and caches it, and a missing CLI shows as “not installed or not on PATH” instead of a spawn error.
Performance
A terminal-first app is judged by how it feels while output pours in. After the features landed, a series of passes went at the hot paths: memoised diff splitting, debounced resize observers, themes hoisted out of render, cached directory snapshots, a lazily loaded inspector and editor, and parallel startup reconciliation. Refreshes are scoped to the task that changed, so an agent in one task never repaints another.
Design
It looks like an IDE on purpose, because that’s where the work ends up: tasks on the left, sessions and files as tabs in the middle, and the worktree’s files and changes on the right. The palette is near-black and quiet, so the colour on screen is the agent’s output and the diff.
The details lean the same way. Tabs are rectangular, file types have icons, and each agent tab carries its tool’s mark. The provider bar is three words, terminal, codex, and claude, instead of a menu, because starting a session should cost one click.
Decisions
Run the CLIs, don't call the models
Autocode never calls a model API. It runs the agents you already use, signed in as you already are, so it inherits their improvements and never holds a key. The cost is that it only sees what a terminal shows, so sessions are kept as transcripts, not structured tool calls.
tmux over a custom daemon
Surviving restarts needs something that outlives the app. A background service of Autocode’s own would be a second program to install, update, and debug. tmux already does it, on its own socket, and without it the app still works, minus that one guarantee.
Sandbox off, for now
The renderer runs with context isolation and without Node, but the Electron sandbox is off so the preload bridge behaves the same in development and packaged builds. It’s written down as a temporary compatibility choice, not a default to forget.
What’s Next
Review comes next. The changes panel shows uncommitted work and recent history, but a task’s real diff is everything on its branch since its base, which is what a reviewer needs before a pull request exists. Close behind: waiting for an agent to be ready before handing it the task, so the brief never lands in a startup prompt.
After that, signed builds, and several agents on one task at once with a way to compare their attempts. The foundation is ready for it: every attempt is a branch, every session a transcript, and integrating one task into another is a single dialog.