CLAUDE LABJP
FORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as OctoberFORK — Claude Code 2.1.212 changes what /fork does: it copies your conversation into a new background session with its own row in claude agents, so you can keep working. The old in-session subagent is now /subtaskLIMITS — WebSearch calls are now capped at 200 per session by default, and subagent spawns get the same 200 ceiling, so a runaway search or delegation loop stops on its ownMCPBG — MCP tool calls running past two minutes now move to the background automatically, keeping the session usable. Tune the threshold with CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSPLANFIX — Fixed plan mode auto-running file-modifying Bash commands such as touch and rm without a permission prompt or an SDK canUseTool callbackSONNET5 — Claude Sonnet 5 is running on introductory pricing of $2 per million input tokens and $10 per million output. After August 31 it moves to $3 and $15IPO — Bankers are reportedly lining up investor meetings for Anthropic ahead of a possible public listing as soon as October
Articles/API & SDK
API & SDK/2026-05-03Advanced

Building an Offline-Capable AI Notes App with Claude API and Local-First Sync — A Production Design with Replicache and IndexedDB

A production design guide for combining Claude API with a local-first sync engine. Walks through Replicache, IndexedDB, mutation queues, and idempotency keys with full TypeScript code.

claude-api81local-firstreplicacheofflineindexeddbproduction111

Premium Article

A user opens your notes app on a train, hits a tunnel, and the AI suggestions go silent. They reopen the app and find their draft missing. After one experience like that, they will never trust the AI features again.

Local-first design is the direct answer. Writes go to local storage first; sync and AI calls live in a separate layer. The idea sounds simple, but the moment you bring in a heavy, billed, latency-prone service like Claude API, the implementation difficulty explodes. I have built similar architectures across four sites, and getting the mutation queue wrong once meant calling the same prompt three times and tripling our API bill.

This article walks through a production design for an offline-capable AI notes app built around Replicache and IndexedDB, including the pitfalls I learned the hard way. The end goal is an app where typing and seeing AI suggestions never freezes — even in airplane mode — and where everything reconciles automatically when the connection returns.

Why naive AI plus local-first usually breaks

The first thing to internalize is that AI features and local-first sync run on fundamentally different rhythms.

Local-first sync assumes optimistic writes. Whatever the user types is saved locally first; the diff is sent to the server later. Replicache, Triplit, and Yjs are all built around this optimistic mutation pattern.

Claude API, on the other hand, has hundreds of milliseconds to several seconds of latency per request, and it bills you for every input token times every output token. Critically, sending the same prompt twice costs you twice. If you stuff API calls directly into Replicache's mutation queue, the retry logic happily re-runs every "failed" call and the bill keeps growing while reliability stays the same.

In other words, you have to design the boundary between "what gets synced" and "when AI is invoked" carefully or you will lose both reliability and cost control. The whole point of this article is how to draw that boundary.

Overall architecture

The structure I have settled on uses these layers.

  • UI layer (React): Reflects user input into local DB instantly. AI completions render via streaming.
  • Local DB layer (IndexedDB + Dexie): Stores note bodies, AI outputs, and metadata.
  • Sync engine (Replicache): Synchronizes notes across clients. AI outputs are not synced.
  • AI job queue (Cloudflare Queues): Processes Claude API calls server-side.
  • API gateway (Hono on Cloudflare Workers): Handles Replicache push/pull and AI job submission.

The crucial separation is "Replicache only syncs user edits" and "Claude API runs in an independent job queue." AI outputs are completed on the server and pushed back to local DB as result notifications.

With this design, note editing works perfectly in airplane mode, queued edits sync the moment the device comes back online, and AI jobs run after that.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
Indie developers stuck with AI features that silently fail on flaky connections will be able to ship offline-capable apps with confidence using a Replicache + Claude API split design
You will get complete TypeScript code for caching AI completions in IndexedDB and replaying them through a mutation queue when the network returns
You will be able to prevent duplicate billing, version conflicts, and partial failures in production by separating sync and AI job execution at the right layer
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API & SDK2026-07-13
Coalescing Concurrent Claude API Calls: Single-Flight Against Duplicate Inference and Cache Stampede
A design for collapsing identical prompts that fire at the same instant into a single upstream Claude call, using single-flight (request coalescing). In-process and distributed implementations, jittered retries, and negative caching, with measured results.
API & SDK2026-07-03
How Many Concurrent Claude API Requests Can You Actually Hold? Sizing Production Infrastructure with Little's Law and Measured Memory
Concurrency, queue depth, and memory are numbers you can derive, not guess. A working method for sizing Claude API production deployments with Little's Law, a memory probe, and a 30-minute load check — learned the hard way from an OOM crash.
API & SDK2026-06-28
A Silent Drop to a Weaker Model Is Scarier Than an Error: Designing a Capability Floor for Claude API Fallback
When a model becomes unavailable in an unattended pipeline, automatically dropping to a weaker model is dangerous. Drawing on years of running automated indie pipelines, this is how to use per-task capability contracts and a degradation budget to decide where to stop.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →