Fluxio
← Back to the blog

A Refactoring Day with Gemini CLI, Claude Code and SSE

Coding agents, liveEN

§1 The refactoring target: a streaming chat endpoint

A useful coding-agent comparison needs a stubborn piece of software, not a clever prompt. This field test centers on a TypeScript chat endpoint that mixes provider requests, server-sent events (SSE), cancellation, and usage accounting in one handler. The goal is to separate those responsibilities without changing what clients receive.

This is a scenario-based field test, not a report of measured tool runs. The day below defines realistic assignments, acceptance checks, and workflow verdicts. It does not invent timings, benchmark scores, or successful commits.

The working contract is deliberately narrow: preserve event ordering, stop upstream generation when a client disconnects, and record usage once. Both agents should receive the same repository instructions and test commands. Model selection, permissions, and repository context must be recorded because tool names alone do not explain results.

§2 Morning with Gemini CLI: map the token stream first

Give Gemini CLI the discovery shift. Ask it to trace a request from route entry through provider selection, stream parsing, client delivery, and cleanup. Require file references and a proposed dependency boundary before allowing edits.

This assignment makes broad investigation auditable. A convincing answer identifies where cancellation signals travel, whether the parser handles events split across transport chunks, and which component owns final usage accounting. A polished architecture summary without those details should fail review.

Next, authorize one limited extraction: move event serialization into a small module while leaving provider behavior untouched. Review the patch before expanding scope. The point is to test whether repository exploration produces a safe change, not whether the agent can generate a large diff.

Gemini CLI verdict: assign it the mapping shift provisionally, then demand evidence. Keep that assignment only if its repository references are accurate and its extraction preserves the wire contract. This is a workflow recommendation, not a claim that it universally understands repositories better.

§3 Afternoon with Claude Code: extract cancellation ownership

Hand Claude Code the reviewed map, the accepted patch, and a fresh task: isolate stream lifecycle management. Explicitly forbid unrelated renaming, dependency upgrades, and formatting changes. The handoff should contain decisions and unresolved risks, not an entire morning transcript.

Ask for a short implementation plan followed by a minimal patch. Review where abort controllers are created, which cleanup paths remove listeners, and whether errors after headers are sent remain valid stream events rather than attempted JSON responses.

Claude Code verdict: assign it the constrained implementation shift, with tests as the gate. Accept the work only when the lifecycle boundary is clearer and regression checks pass. Reject a more elegant abstraction if it changes cancellation behavior or hides accounting inside cleanup callbacks.

§4 The SSE checks that decide whether either patch ships

Neither agent wins because its explanation arrives quickly. The refactor succeeds only if the client-visible stream remains correct under awkward conditions. Use the same checks for both patches.

  • – A client disconnect aborts the upstream request and releases listeners.
  • – An event split across network chunks is reconstructed without losing text.
  • – A provider error after streaming starts produces the documented terminal behavior.
  • – Usage accounting runs once on every applicable completion path.
  • – A slow client does not cause unbounded buffering in the relay.

Record test results, review effort, and unnecessary changed lines separately. Time to first token measures responsiveness; it does not establish patch quality or total task completion time.

§5 Where Fluxio fits the live-reply workflow

Fluxio fits when the product needs streaming model access without maintaining separate billing and credentials for every provider. It is a streaming-first, pay-per-token AI API relay with one key and token-by-token replies. Claude Sonnet 5.5 and Gemini 3.1 Pro are two example model choices; routing through a relay does not make their behavior interchangeable.

Fluxio works with Claude Code, Codex, Gemini CLI, and OpenAI SDK clients. Its API base is https://api.fluxioapi.com; OpenAI-style clients add /v1. Use the documented configuration for each coding tool rather than assuming an OpenAI-compatible URL is a universal native-tool setting. Keep credentials out of source control and test cancellation through the actual relay path.

§6 The split-day verdict: investigate broadly, merge narrowly

The strongest division of labor is a provisional one: Gemini CLI maps the streaming path, and Claude Code implements a bounded lifecycle extraction. Keep either assignment only while the evidence supports it. The real winner is the workflow that produces smaller reviewed changes without breaking live replies.

Sign up for Fluxio.

Create a Fluxio account →

More from the current