joemattie
stuff
← index
writing2026-07-209 min readupdated 2026-07-23

Building Authorbot

Joe Mattie
software engineer · mad scientist

I spent most of the last few days finishing Authorbot. It started as the machinery behind The Causal Projector. It is now a hosted and offline authoring system another person can install from npm.

Both @authorbot/create and the authorbot CLI are published on npm, currently at 0.1.29 0.1.30 0.1.39 0.1.40. Work on 0.1.41 is already underway. The public project site is live at authorbot.joemattie.com, and the complete path works.

I’m calling it done. It is still v0.1 software, and I expect bugs, but the project I set out to build is there. Future work is maintenance and whatever I learn from other authors using it, not a missing final 15 percent.

What it does

Authorbot manages authorship without pretending to be an author. It never calls a language model. Humans and external agents write and edit the prose. Authorbot keeps the chapters, comments, decisions, assignments, attribution, revisions, and published site tied together through Git.

The durable source of truth is a normal repository. Chapters are Markdown. Story notes and other long-lived records are readable files. If Authorbot disappears, the book doesn’t become an archaeological dig through an abandoned SaaS database.

A database handles the live parts Git is lousy at: sessions, scoped agent tokens, annotations, votes, leases, and the work queue. It is a projection and can be rebuilt. The API is the only write path, so humans and agents get the same validation and attribution rules.

The reading site starts as plain HTML. Turn collaboration on and a reader can select a sentence, leave an anchored note, reply, and vote. An author can promote that discussion to work, an agent can claim it with a lease, and the accepted revision lands in Git as one attributed commit.

There is no hidden model call in that loop. Authorbot doesn’t silently rewrite a chapter or pick whichever agent has the loudest release notes this week. It coordinates the people and tools doing the work.

The browser now handles direct chapter and planning-document edits, revision review, chapter history, story navigation, reader controls, and exact permissions for each agent token. Hosted mode runs the site, API, D1 database, and GitHub writer on Cloudflare. Local-dev mode runs the same book format, API rules, schema, publisher, browser UI, attribution, and commit path entirely on one machine.

How I built it

I started with the product contract, schemas, invariants, and an aggressive phase plan. Then I ran Claude Code in Ultracode mode and kept feeding it work until my usage meter looked like a speedometer after a police chase.

This wasn’t one magic prompt followed by 70,000 lines of immaculate code. The main session split each phase into small jobs. Builders worked on separate subsystems. An integrator pulled them together. Review agents attacked the result from governance, security, data integrity, and product angles. Other agents tried to disprove those findings before the fixes landed. Tests decided whether a phase was done.

The final log directory contains 306 subagent transcripts. That doesn’t mean 306 agents ran at once, or that all of them were useful. It means the orchestrator kept creating disposable workers instead of expecting one context window to remember an entire platform.

The last clean release tag contains 195 commits and 174,770 physical lines of code. That breaks down to 100,362 lines of product code and 74,408 lines of tests. I counted the maintained TypeScript, JavaScript, Astro, CSS, SQL, Python, and shell files while excluding docs, configuration, lockfiles, fixtures, dependencies, generated files, and build output. The 0.1.40 worktree is slightly larger, but it isn’t a stable commit yet. Raw LOC is a pretty stupid measure of quality, but it does convey that this stopped being a cute little static-site generator several releases ago.

The Git history shows the same shape. Early phases established the book format, validator, CLI, and static publisher. Then came the API, inline discussion, durable records, governance, leases, and GitHub writer. The next stretch was installer work, production failures, browser flows, accessibility, teardown, agent tokens, the collaborator skill, and a fairly brutal redesign of the reader and author console.

I directed the product, wrote and corrected the contracts, made the ugly boundary calls, and kept pushing the implementation back toward something I would trust with a book. Fable did a ridiculous amount of the construction and coordination. Ultracode routed plenty of work through Opus 4.8 too. It felt less like pair programming and more like supervising a very fast engineering team whose members vanish whenever their narrow task ends.

Then I switched to Codex and dogfooded the actual UI at an unreasonable pace. I kept The Causal Projector open in local dev, clicked through the book like an author instead of a test runner, and fired off every bit of friction as soon as I saw it. Move this button. Keep that state when I change pages. Show the real diff. Put History next to Edit. Let me open a character without losing the chapter. Fix the mobile layout. Again.

That loop is why the later releases came so quickly. Shared browser state landed, then direct chapter editing, planning-document editing, granular agent permissions, chapter history, revision review, reply-to-work promotion, safer upgrades, reader controls, story tabs, character drawers, and a lot of small layout fixes that don’t deserve release-note poetry but do decide whether software feels good.

It also produced the offline version. authorbot dev creates a managed branch and Git worktree, starts the real API against private SQLite, and serves the Astro/Vite UI on 127.0.0.1. Browser and agent writes still become narrow attributed commits. Direct editor saves stay dirty until I commit them myself, and API writes pause rather than mixing with uncommitted work. Once the packages are installed, the whole authoring loop works without GitHub, Cloudflare, or a network connection.

For Authorbot itself, I can point that local stack at The Causal Projector while running publisher and UI source through Vite. That made visual dogfooding fast enough to be useful: change the CSS, reload the actual book, notice the next awkward thing, and keep going. Local sessions can validate and open a draft pull request when the book is ready, but they can’t merge or deploy on their own.

The expensive part

The plan meters don’t translate cleanly into dollars, so I measured both halves from their local logs.

The Claude build was the number I published first. I scanned 378 JSONL files, deduplicated repeated transcript entries by request ID, and found 10,849 distinct paid requests. They contained 177,348 uncached input tokens, 34,840,263 cache-write tokens, 1,851,336,819 cache-read tokens, and 8,422,620 output tokens, for 1,894,777,050 total tokens.

Claude Code recorded 25.45 million five-minute cache writes and 9.39 million one-hour writes. Anthropic charges 1.25 times base input for the first kind and twice base input for the second.1 Pricing the actual Fable 5, Opus 4.8, and Opus 4.7 mix correctly comes to $1,711.61 through the API.

That stopped being the final number when I used Codex for the dogfood and finish. I scanned the three Authorbot Codex session trees and deduplicated the usage snapshots inherited by their subagents. My July 23 snapshot produced 18,609 distinct model calls, 62,415,522 uncached input tokens, 2,311,807,744 cached input tokens, and 5,897,561 output tokens, for 2,380,120,827 total tokens.

Claude and Codex together processed 4,274,897,877 tokens. That includes cache writes and reads, so it isn’t 4.27 billion unique words. It is the amount of text the models processed while building and fixing the thing.

Tokens processed by toolClaude build, Codex dogfood and fixes, and the combined July 23 snapshot.
Claude1.895B
Codex2.380B
Combined4.275B
Where the tokens wentClaude cache reads and writes plus Codex cached input dominate the total.
Cached context4.198B
Uncached input62.593M
Output14.320M

At GPT-5.6 Sol’s standard API rates, the refreshed Codex total is $312.08 of uncached input, $1,155.90 of cached input, and $176.93 of output.2 The Codex phase comes to $1,644.91. Added to Claude, the project’s API-equivalent model cost is $3,356.52.

API-equivalent project costThe Claude build and Codex dogfood pass through the v0.1.40 hotfix.
Claude build$1,711.61
Codex finish$1,644.91
Combined$3,356.52
Codex finish, by token bucketGPT-5.6 Sol standard API rates applied to the local logs.
Uncached input$312.08
Cached input$1,155.90
Output$176.93
What I actually paid, approximatelyProrated subscriptions across the roughly 100-hour build. Anthropic supplied the credits for free.
Subscription share$55
Anthropic credits$0 paid
Approx. total~$55

That isn’t my invoice. The repository went from its first commit to the current hotfix work in about 100 hours, a little over four days. Most of the work ran inside the Claude Max 20x and ChatGPT Pro subscriptions I already pay for, both $200 a month.3 Anthropic also gave me $100 in credits for free.

Prorating those subscriptions across the build window adds about $55. The credit grant cost me nothing, so my approximate development cost was $55. I spent $0 in new cash beyond subscriptions I already had. That ignores electricity and my time.

The log total answers a different question: what would the recorded model calls cost at standard API rates? That answer is $3,357, which is more than twice my original finished-build guess and about 61 times what I actually paid.

The installable part

For a hosted book, npx @authorbot/create walks through five stages:

  1. Check Node, Git, GitHub, and Cloudflare.
  2. Create the book repository and its files.
  3. Publish the reading site.
  4. Add sign-in, comments, votes, settings, and the work queue.
  5. Invite an agent with a scoped token.

You can stop after any stage. A solo writer can use Authorbot as a Git-backed publisher without turning on collaboration. The wizard handles the GitHub App setup too. It also has unpublish and teardown commands, because a setup tool that creates cloud resources without knowing how to remove them is how every terrible dashboard begins.

For a local book, the entry point is smaller:

npx authorbot dev

That starts the complete authoring stack without publishing anything. authorbot dev status shows the server, managed worktree, Git state, and private local-state directory. authorbot dev agent-env loads the starter token for a local agent. authorbot dev pr validates the book, builds the production site, and opens a draft pull request without merging or deploying it.

Agents install the collaborator skill with:

npx skills add JoeMattie/authorbot

The skill teaches the contribution loop, the API, and the safety rules. It ships narrow drafter, critic, continuity, and reviewer roles. An agent gets a scoped token, claims work through the API, and submits a draft for review. It never gets direct GitHub write access, and it can’t manufacture a vote from another agent into human approval.

Where it landed

The hosted path is running on The Causal Projector. That book currently has 12 published chapters, not 24. Readers can sign in, select prose, comment, and reply. I can turn those discussions into work, hand the job to an agent, review the revision, and inspect the resulting Git history.

The local path runs the same book without touching the hosted service. I can edit chapters and story files in the browser, work directly in the managed checkout, or let a local agent use the API. The projection rebuilds from Git, and the private SQLite state stays outside the book.

Version 0.1.40 is the current code, and the fixes heading toward 0.1.41 have already started. npm still showed 0.1.39 when I took this snapshot, so the registry was one hotfix behind the source. authorbot.joemattie.com explains the system, the README covers both hosted and local-dev modes, and the repository has the deeper setup, architecture, API, and operating notes.

If you want to see it doing the job, read The Causal Projector and leave a comment on a sentence. I still need mileage from people who aren’t me, but Authorbot itself is done enough that I’m taking it off the active-project list.

Footnotes

  1. Anthropic’s model and prompt-caching prices, checked July 21, 2026. Five-minute cache writes cost 1.25 times base input, one-hour writes cost twice base input, and cache hits cost 0.1 times base input.

  2. OpenAI’s API pricing listed GPT-5.6 Sol at $5 per million uncached input tokens, $0.50 for cached input, and $30 for output, checked July 23, 2026. The local Codex logs recorded no cache-write tokens for these sessions.

  3. Claude Max 20x and ChatGPT Pro each cost $200 a month. See Anthropic’s plan comparison and OpenAI’s ChatGPT Pro documentation.

aiwritingclaude-codeauthorbot