AgentRecipes
Recipes › Engineering & security

How to rewrite a critical production service with Claude Code behind a black-box test harness

Engineering & securityClaude Code✓ Confirmed by source

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

Step-by-step recipe

  1. 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).
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. Use the rewrite as a chance for human-supervised cleanups the agent will not invent on its own (static configuration, richer observability).

Copyable prompt

Prompt template
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

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

Review agent-written pull requests with layered AI review and risk-based human approvalOnce coding agents open pull requests, there are far more changes than people can read line by line, but skipping review lets bugs and…Claude Code✓ Confirmed by sourceShip vendor recipe prompts so coding agents integrate your API the way you wouldDevelopers ask coding agents to add a vendor feature from public docs alone; the agent often picks the wrong product surface, burns…Claude Code✓ Confirmed by sourceLet scheduled Claude Code routines maintain an old SaaS with one PR per change and reviewed, batched deploysA founder no longer has time for a 17-year-old Rails side project, so small bugs, missing tests, stale support docs and SEO fixes pile…Claude Code✓ Confirmed by source

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.