# Forking subagents in an AI coding session with tmux

DevFeed: [Forking subagents in an AI coding session with tmux](<https://devfeed.tech/articles/forking-subagents-in-an-ai-coding-session-with-tmux-25208.md>)

Original publisher: [Read original article](<https://kau.sh/blog/agent-forking/>)

Author: Kaushik Gopal

Published: 2025-12-29T08:00:00Z

Content type: tutorial

Language: en

Sources: [Kaushik Gopal's Site](<https://devfeed.tech/sources/kaushik-gopal-s-site.md>)

Topics: [agentic-coding](<https://devfeed.tech/topics/agentic-coding.md>), [coding](<https://devfeed.tech/topics/coding.md>), [Claude Code](<https://devfeed.tech/topics/claude-code.md>), [codex](<https://devfeed.tech/topics/codex.md>), [Command-line interface](<https://devfeed.tech/topics/cli.md>), [Shell](<https://devfeed.tech/topics/shell.md>), [Model Context Protocol](<https://devfeed.tech/topics/model-context-protocol.md>)

Tags: [agentic-coding](<https://devfeed.tech/tags/agentic-coding.md>), [bash](<https://devfeed.tech/tags/bash.md>), [claude-code](<https://devfeed.tech/tags/claude-code.md>), [cli](<https://devfeed.tech/tags/cli.md>), [code](<https://devfeed.tech/tags/code.md>), [codex](<https://devfeed.tech/tags/codex.md>), [mcp](<https://devfeed.tech/tags/mcp.md>)

## AI overview

The article describes a thin Bash script using tmux to fork interactive AI coding sessions while preserving context. It emphasizes tool-agnostic workflows across Claude Code, Codex CLI, and Gemini, with separate sessions for exploration or parallel work.

## Source excerpt

With agentic coding becoming the primary paradigm for coding, many have tried to come up with a smooth subagent workflow.1 Many of these solutions are reasonable, but none match the simplicity of what I actually want: Spin up another agent instance with the exact same context I've painstakingly built. Pursue a tangential thought interactively in a separate session. Sometimes that's exploratory (understand a subsystem, ask follow-ups). Sometimes it's parallel work (write tests while context is fresh, draft docs, spike an alternative). That's it. Open a new tab, resume the session, take a different path. Sounds straightforward, but tack on a few more requirements and it becomes hard to find a satisfying solution. I've been using a thin shell script for this and it's worked well.2 You can find the source here. My requirements # Super thin glue layer ## I'm deliberately not trying to build on top of existing agents. I use claude code, codex cli & gemini daily, and they change fast enough that anything with a thick layer (like a UI) will lag behind on features. So: a Bash script and tmux. That's it. Available on virtually any computer. Tool-agnostic forks ## I want to start the main session in one tool and fork into another, keeping the same context. So I might start a planning session with codex. After I have a decent plan, I might want to fork into claude code (with all the context I've built) and start a coding session. I might want to fork another subagent from gemini and, using something like the nanobanana MCP, build a before/after flow diagram. Interactive, not one-shot ## When I fork a subagent, I want a real session I can keep interacting with. It's rare that I can one-shot a request and get exactly what I want. Based on the initial response, I might want to go down the rabbit hole and explore more. Many existing solutions are headless or try to merge results back automatically. In practice, I just copy-paste what I need from the fork back into the main session