Nightcall: an AI software company that runs on GitHub labels

Most agent tooling I try is busy making the model smarter. In my experience that is rarely what breaks a team. What breaks a team is the boring part: who decides what, where the state of the work lives, what it cost, and what happens when something fails at 3am.

Nightcall is my answer to those questions for a team of coding agents. It is one long-running Effect-TS program that runs a small virtual software company against GitHub repositories, built entirely on the published @llm4ts/* packages. Nightcall itself contains no model calls. It is only organization.

The bet: GitHub is the whole control plane

The idea comes from Paperclip: an org chart, atomic task checkout, heartbeats, budgets, governance gates. I took those and made one structural change. GitHub replaces the server, the database and the UI.

There is no dashboard to build and no database to keep in sync. If I want to know what the company is doing, I look at the repo, like I would with a human team.

The org chart

CEO/CTO (human)      scope & merge authority. Speaks via issues and PRs.
└─ Chief of Staff    deterministic orchestrator. NOT an LLM.
   ├─ Tech Lead      LLM, read-only. Triage authority.
   ├─ Engineers ×N   LLM, implementPlanFlow. Implementation authority.
   └─ QA Reviewer    LLM, read-only, fresh context. Ship authority.

Each role has exactly one kind of authority. The Tech Lead reads a ready issue and either bounces it with concrete questions, writes acceptance criteria, or (only when I mark it as an epic) splits it into at most five children. It never writes code. The Engineer runs llm4ts implementPlanFlow in its own worktree with those criteria in its plan. QA reviews the final diff with a fresh context.

That last one matters more than it looks. The Engineer already has an internal review-and-fix loop, but that loop shares the Engineer’s blind spots. A reviewer who has never seen the conversation is the agent version of “someone else reviews your PR”.

Roles live in a registry: role → flow + connector + budget. Adding a Docs or Release role is one row and one flow. The orchestrator does not change.

The manager is not an LLM

This is the rule I care most about: any decision that can be code is code. LLMs hold judgment roles only. The orchestrator, budgets, bookkeeping, label transitions and reports are plain deterministic Effect programs.

The Chief of Staff wakes up every two minutes and does one heartbeat: poll, decide, act. Polling and acting go through llm4ts GitHubTool. The decision in between is a pure function, so the claim policy is testable without a single fake:

// One heartbeat of the Chief of Staff: poll → decide → act. Polling and
// acting go through GitHubTool; the decision in between is a pure function
// so the claim policy is testable without any fake at all.
export const decide = (
  snapshots: ReadonlyArray<TargetSnapshot>,
  config: CompanyConfig,
  spentTodayUsd = 0
): HeartbeatDecision => {
  const inFlight = snapshots.reduce((count, snapshot) => count + snapshot.wip.length, 0)
  const throttled = spentTodayUsd >= config.dailyBudgetUsd
  let seats = throttled ? 0 : Math.max(0, config.engineerParallelism - inFlight)
  // ...

The heartbeat is idempotent. Run it twice, or after a crash, and it converges to the same actions, because every action is derived fresh from GitHub label state plus an append-only ledger. GitHub labels are the only org-level state. Any local mirror of that state would drift, so there isn’t one. The only local state is per-issue execution state: the persisted llm4ts plan and trace inside the issue’s worktree.

On restart, before the first heartbeat, Nightcall reconciles every issue it had in progress: worktree and plan still there, resume; branch pushed but worktree gone, recreate the worktree from the branch; nothing recoverable, comment, delete the branch and start over.

Labels are the management interface

Everything lives in a factory:* namespace, and the factory never touches an issue without one. There is no backlog self-triage. Putting a label on an issue is how I delegate.

Label Meaning Set by
factory:ready pick this up human only
factory:epic you may decompose this human only
factory:needs-info Tech Lead bounced it with questions orchestrator
factory:wip claimed, first write wins orchestrator
factory:review PR open with Closes #N, QA approved orchestrator
factory:failed attempts or budget exhausted, see comment orchestrator
factory:budget-N per-issue budget override ($N) human only
factory:fresh discard everything and restart from origin human only
factory:ship waive the QA verdict and ship human only

(The full table in DESIGN.md also has the staged-pipeline labels.)

Notice which labels are human only. Scope, decomposition, money and overrides stay with me. The agents can move work along, but they cannot give themselves more of it.

Failure is designed, not improvised. After two failed attempts an issue goes to factory:failed instead of looping. The branch is pushed without a PR, as evidence for the autopsy. Retrying is a human act: strip failed, add ready again. Every worktree is isolated per issue, so a crashed run is, in the words of the design doc, “a self-contained crime scene”.

Money is enforced, not discussed

An LLM never reasons about its own budget. The Chief of Staff enforces it:

When an issue leaves wip, it gets an invoice comment: total, per-seat breakdown, review rounds, turns, model, budget left. The same line goes in the PR body. One of the later changes was to treat running out of budget as a governance pause rather than a failure, which is what it is. Nothing went wrong, the company just hit the limit I set.

If you have ever tried to explain AI spend to a CFO, you will understand why I wanted cost per pull request on the pull request itself.

Steering with a text file

COMPANY.md is injected into every agent’s system prompt. It is the company handbook, and it is how I change strategy without touching code. It is deliberately short, because every line in it is context spent on every task. My favorite part is the escalation rule:

When genuinely blocked, stop and report precisely (what was attempted, what failed, what is needed) rather than guessing. An honest factory:failed is cheaper than a wrong PR.

That sentence is also good advice for human engineers.

Where I changed my mind

The founding decision record is dated 31 July 2026 and lists auto-merge as a non-goal. Four days later I amended it. Once the staged pipeline got a mend stage that keeps open PRs rebased and mergeable, the merge click stopped adding much. Green checks now auto-merge by default, and NIGHTCALL_AUTO_MERGE=off brings the human gate back.

The amendment puts it better than I can now: “Merge authority is now exercised through issue scope, labels, and revert — not the button.” That is how I already lead human teams. I don’t approve every merge. I decide what gets worked on and I can roll things back.

Engineer parallelism, on the other hand, still defaults to one. The reason is in the design doc: semantic PR collisions arrive before git ones, and there is no merge-conflict role. Going parallel is a config change, not a design change, when I’m ready for it.

Running it

NIGHTCALL_TARGETS=owner/repo pnpm start

Observe mode is the default. The daemon polls the factory:* labels and logs what it would claim, writing nothing. NIGHTCALL_CLAIM=1 arms the full pipeline (claim, Tech Lead triage, Engineer, QA, PR), once a coding agent CLI is available (LLM4TS_CODER, default claude) and gh is authenticated. NIGHTCALL_PIPELINE=staged splits the work into plan, code, review and QA workers that run concurrently across issues.

What it does not do yet

Some things wait for what the design calls the trust bar: three issues end to end, unattended, on a deliberately boring sandbox repo with real CI, before Nightcall may get factory:ready on llm4ts issues. Publishing the ledger to an orphan branch, a Mermaid standup dashboard and a dedicated machine account all wait for it too. Nightcall working on its own repo comes last, never first, because orchestrator bugs must not be edited by the buggy orchestrator.

It also has a sibling. Dunder Mifflin uses the same architecture (deterministic Chief of Staff, heartbeat, seats, budgets, ledger) against a Basecamp card table instead of GitHub, and does content instead of code.

The takeaway

If you are putting coding agents to work, borrow the org design before you borrow the prompts:

  1. Keep the manager deterministic. Let LLMs judge, not schedule, count or bill.
  2. Keep the state where your team already looks. For software, that is the repo.
  3. Give every role one kind of authority, and keep scope and money human.
  4. Make failure cheap and visible: an honest failed label and a pushed branch beat a wrong PR.

The code is on GitHub. Start with DESIGN.md, it is the most useful file in the repo.