How to rewrite a critical production service with Claude Code behind a black-box test harness
Confirmed by source: Company engineering post by Checkly describing a completed production rewrite of a 92M-msg/day service, including harness design, a real first-deploy failure, staged rollout, and measured post-migration results with zero incidents. (checked 2026-10-19)
The problem
A high-throughput background service is becoming a bottleneck and paging on-call, but rewriting it by hand is slow and risky, and letting an agent rewrite it without a clear definition of correct behaviour is how you ship silent regressions into production.
Tools needed
- Claude Code
- Black-box test harness with golden-file oracles
- Docker Compose for real boundary services
- Playwright (test runner and network tooling)
- Toxiproxy for failure injection
- Feature flags for staged traffic migration
- CI that runs the harness against both legacy and rewrite
Step-by-step recipe
- Build the test harness before any rewrite code: treat the service as a black box, feed realistic inputs, and assert outputs against golden files recorded from the legacy system (mask non-deterministic fields such as UUIDs and timestamps while still type-checking them).
- Model every production boundary at the lowest unit (each queue, each database table, each cache), and run real instances of those services under Docker Compose rather than mocks; add failure cases with a network proxy so infrastructure outages are covered.
- Seed inputs from real production-shaped data (configurations crossed with outcome types), aim for high code coverage on the legacy service, and feed coverage gaps back to the agent to propose missing cases.
- Point Claude Code at the legacy implementation as a reference and give one clear goal: produce a new service in the target language that passes the harness; discard runs that fail the bar.
- Deploy first to non-production and internal accounts, then migrate customer cohorts behind a feature flag while CI blocks any change that breaks the harness for either the legacy or the new daemon.
- When a production bug appears, reproduce it in the harness first (TDD), then fix; keep both daemons in sync until the cutover is complete and decommission the legacy workload only after monitoring holds.
- Use the rewrite as a chance for human-supervised cleanups the agent will not invent on its own (static configuration, richer observability).
Copyable prompt
Rewrite [LEGACY SERVICE] from [OLD LANGUAGE] to [NEW LANGUAGE]. Acceptance: the black-box harness in [HARNESS PATH] must pass against your implementation with byte-level parity on golden files (non-deterministic fields already masked). Constraints: - Treat the legacy code as a behaviour reference, not a line-by-line port to preserve. - Read [BOUNDARY INVENTORY]: every queue, table and cache listed there must be used; do not invent a simplified local topology. - Configuration must come only from static environment variables (no runtime derivation). - Emit metrics for [KEY OPERATIONS] so operators can triage under load. - Do not change public message contracts. When unsure, add a harness case before coding. Stop when `npm test` / harness CI is green and summarise remaining gaps.
Original template written by our AI agent for AgentRecipes, not copied from the source. Replace the [BRACKETS] and {{variables}} with your own values and test before relying on it.
What the builder reported
Checkly rewrote Results Daemon (about 92 million messages per day) from Node.js to Go with Claude Code. After fixing an early harness gap on retry queues, the rollout finished with zero incidents; they report about 70% fewer running pods, roughly 15 vCPU and 45GB memory freed, about 60% fewer average active database sessions and about 15% lower database CPU. Customer issues during migration were minor edge cases closed in about an hour via harness-first TDD.
These are the source author's own claims. AgentRecipes has not run this recipe itself.
Watch out for
- If the harness models a simplified local topology, the agent will build retry and routing logic around it and you will discover the gap only on real traffic (Checkly's first deploy failed retries for exactly this reason).
- Code coverage is a starting metric, not proof of behaviour; edge cases still slip through and should be added to the harness via TDD when found.
- Human review is still needed for anti-patterns the agent copies from the legacy code (runtime config derivation, weak observability).
- Keep both implementations behind CI until cutover finishes, or fixes will drift.
- Stage migration by customer cohort with a feature flag; do not flip all production traffic at once.
Source
Original write-up: Checkly (2026-09-01) ↗
Found via Checkly Blog: “We Let AI Agents Rewrite a 92M-Message-a-Day Service in Go”. This recipe summarises the source in words written by our AI agent; read the original for the full details. Link last checked 2026-10-19.
More engineering & security recipes
New agent recipes in your inbox
A short email with the newest automation recipes, each linked to its real-world source. No spam. Every email has a one-click unsubscribe link.