DEV Community

Cover image for How I keep context when switching between Claude Code, Codex and DeepSeek
Mahmoud Rabea
Mahmoud Rabea

Posted on

How I keep context when switching between Claude Code, Codex and DeepSeek

Every AI coding session I run ends in one of three ways: the usage limit hits, the session crashes, or I want to try the same task in another agent. All three lose the same thing: the agent's understanding of what's done, what's next, and what must not be touched.

So the next session starts with me re-explaining the project. Or worse, with "continue where you left off" pointing at code that changed an hour ago.

I built tagteam to make that handoff explicit, structured and checked against git. Here's the workflow, and the three design decisions that made it reliable.

tagteam demo

The workflow in 30 seconds

npm i -g tagteam-ai
tagteam profile add claude      # Claude Code with your normal login
tagteam profile add deepseek    # Claude Code on DeepSeek's API
tagteam chain claude,deepseek
tagteam                          # instead of `claude`
Enter fullscreen mode Exit fullscreen mode

Claude Code starts with the saved context. When it exits (for any reason), tagteam makes sure a handoff exists and asks: Continue with "deepseek"? [Enter]. Press Enter and the next agent starts with the task, the completed steps, the exact next action and your constraints.

It works with Claude Code (your login, or any Anthropic-compatible API), Codex (your login, or any Responses API), any other command, and as an MCP server.

Decision 1: a handoff is data, not prose

Most "memory" tools store a summary paragraph. A paragraph is easy to write and hard to act on. A tagteam handoff is a small JSON document:

  • task: title, goal, acceptance criteria
  • completed and in_progress
  • next_action: one concrete step a new agent can start without reading the transcript
  • known_issues, tests (command and pass/fail)
  • decisions and constraints, which outlive the handoff

The single next_action matters most. "Continue the billing work" makes the next agent explore; "add the retry wrapper around gateway.charge() in renew() in src/billing.js" makes it work.

Decision 2: trust, but verify against git

Every handoff records the branch, HEAD, the uncommitted files and a hash of the diff. When the next session starts, tagteam compares that with the repo and puts a warning at the top of the context:

## ⚠ Drift since handoff — verify before trusting it
- 2 new commit(s) since the handoff, touching 3 file(s): src/billing.js, ...
- Uncommitted changes differ from the handoff. Newly modified: src/gateway.js.
Enter fullscreen mode Exit fullscreen mode

Constraints can be bound to paths:

tagteam constraint "Do not change the payment gateway interface" --paths "src/payments/gateway.*"
Enter fullscreen mode Exit fullscreen mode

Every agent sees the rule at session start, and tagteam status exits with code 2 when your diff touches a protected path, so the same rule works as a pre-commit hook or a CI step.

Decision 3: a handoff even when the agent can't write one

The best handoff is written by the agent itself (Claude Code gets a /handoff command and every agent gets an MCP save_handoff tool). But the moment you most need a handoff is when the agent stopped unexpectedly, and then it can't write anything.

So when an agent exits without saving one, tagteam asks a cheap model from one of your other profiles to write it from the transcript and the diff. A summarizer call on Claude Haiku costs about $0.0004 in my tests. If that provider is down, it tries the next one. If every provider fails, it still saves the git state and your last messages.

Everything sent to a summarizer is redacted first: API keys, tokens, passwords in URLs, KEY=value secrets, private keys.

What testing taught me

  • Fake agents beat mocks. The run loop is tested against fake claude and codex binaries that run the real hooks and talk to the real MCP server. That caught bugs no unit test would.
  • A redaction corpus finds real leaks. I collected about 30 real-world secret formats. The first run caught 13 that my patterns missed, including the key formats of two providers I use every day.
  • Record your own demo. Recording the GIF exposed a summarizer that saved one of its own instructions as a permanent project constraint. That's fixed in 0.1.3.
  • Ship with provenance. Releases go from a git tag to npm through GitHub Actions trusted publishing: no npm token anywhere, and every version is signed.

What's next

Automatic switching when an agent hits its limit, a VS Code status bar, cost per task, and shared team handoffs.

tagteam is Apache-2.0: github.com/MHRabea/tagteam. If you switch between AI coding agents, I'd love to hear what your handoff needs to contain.

Top comments (0)