# Book Time: decide how each part fails

> Book Time, one of our live products, is a small set of reading games on Cloudflare Workers. It was built on one design rule: before you pick a tool, decide what happens when it breaks.

Case study · Clandestine Hours · 2026-10-12 · https://clandestinehours.com/notes/book-time-decide-how-each-part-fails/

- **Product:** Book Time, our own: paste a public reading list (Goodreads, Fable or Livraddict) and pick your next book with a wheel, a duel bracket, an AI quiz or a tier list
- **Stack:** SvelteKit 2 on Cloudflare Workers · KV for game state and rate limits · D1 with Better Auth for creator accounts · Workers AI through an AI Gateway for the quiz · PostHog · Vitest
- **Timeline:** First commit in January 2026; 268 commits by October 2026; still shipping
- **Team:** One engineer, with Claude Code

Book Time is one of the three products we keep live. It started in January 2026 as a wheel of fortune for a Goodreads shelf. It is now four games: spin a wheel, run a head-to-head duel bracket, take an AI quiz about your own books, or rank them in a tier list (rows from best to worst). You paste a public reading list from Goodreads, Fable or Livraddict, and play. No login needed. Every game gives you a link to share.

It is small, so it's a good place to show one design habit we try to apply in all our projects.

*Diagram: One Cloudflare Worker runs the SvelteKit app. It reads public reading lists from the three providers, keeps each game's books and the rate-limit counters in KV, stores creator accounts in D1, and asks Workers AI for quiz questions through an AI Gateway.*

## How it fails decides where it can be used

Every tool you add has a failure mode, and the failure mode decides what the tool may be trusted with. A part that fails *open* lets requests through when it breaks. One that fails *closed* blocks them. Here is an example from Book Time.

**Rate limiting.** Book Time has a small rate limiter, which caps how often one visitor can call us. It is backed by KV, Cloudflare's key-value store. KV is fast and cheap, but it is eventually consistent: a new value can take a moment to show up everywhere. It can also be briefly unavailable. So the limiter is written to fail open. We use it to slow abuse down, and nothing depends on it being exact. Anything that must be correct, such as accounts and sign-ups, lives in D1 (Cloudflare's SQL database) behind Better Auth.

We try to ask the same question of each part: when it breaks, which way does it fall, and is that acceptable for what it guards?

## Integrate first, build when you can name the cost

Before building a feature, we try to answer three questions. Does it fit the product's direction? Should we integrate something that already exists instead of building it? What does it cost? Accounts come from Better Auth, validation from zod, HTML parsing from linkedom, analytics from PostHog. We aim to build our own only when we can say what integrating would cost us.

These questions also help catch a recurring mistake: a setting added "for later" that no code ever reads. In a codebase run by one person, an unused option tends to come back months later as a question nobody remembers the answer to.

## Small guardrails

- **Themes are fixed, contrast-checked sets.** There is no raw colour picker. The one custom theme takes four picks and derives the rest. It adjusts each colour until the text is legible. A script checks the palette contrast.
- **Tests cover the pure parts.** Vitest tests cover the parts with no framework in them: the template parser and sanitiser, the challenge engine's decisions, the theme contrast matrix. They run on every deploy, before the build.
- **Deploys are one command:** type-check and tests, build, database migrations, deploy.

## Try this

Pick one external service your product depends on: flags, payments, email, a model API. Write down what happens when the call fails. Does your code allow, deny, or crash? If the answer is "allow" and the service guards something that matters, move that check somewhere that fails closed.
