News for hackers. Stuff that matters.
Re:You might not need tmux by d4rkp4ttern on Friday August 01, 2025 @06:42AM (#44755086)
I learned about Tmux just a few weeks ago and found out that one of the nifty features is that it is scriptable, I.e allows programmatically sending keystrokes to a specific pane. Then, inspired by some Japanese forums I asked myself if I can leverage this to have Claude Code actually interact with an interactive CLI script — we know CC can launch a script via bash but if said script waits for user input then CC can’t (easily) interact with it. Turns out yes we can leverage Tmux for this!

So I used Claude Code to build a little el tool called Tmux-cli, which gives a convenient way to have CC (or any CLI coding agent for that matter) spawn a Tmux Pane, launch a script there, and actually interact with it.

So it’s like Playwright/Puppeteer for the terminal.

You can get it via

    uv tool install claude-code-tools
https://github.com/pchalasani/claude-code-tools

There are some interesting possibilities this enables:

Let CC autonomously test interactive CLI scripts, without me having to intervene and point out errors.

Have the CLI coding agent launch UI from another pane and then use Puppeteer MCP to test from a browser.

Let CC launch a cli script with a debugger enabled (e.g. Pdb) and set breakpoints etc — for token-efficient code understanding, debugging and explaining.

Let the CLI coding agent spawn and drive another instance of the same or other CLI coding agent, AND interact with it. Note this is way better than CC sub-agents which are “spawn and let go” black-boxes.

I wonder if the discussed Tmux alternatives enable building this type of tool.

Re:You might not need tmux by Sherveen on Friday August 01, 2025 @06:52AM (#44755159)
Yup, another fun thing to do w/ this: let Claude Code talk to and control Gemini CLI, OpenCode, other CC instances, etc. in interactive mode! A different flavor of subagent. :)
Re:You might not need tmux by d4rkp4ttern on Friday August 01, 2025 @07:20AM (#44755327)
Indeed, or vice versa where we leverage Gemini’s monster context length
Re:You might not need tmux by xrd on Friday August 01, 2025 @01:12PM (#44759549)
Make sure you use the pipe operator.

Very cool ideas in this thread.

Re:You might not need tmux by blueflow on Friday August 01, 2025 @07:19AM (#44755324)
> So it’s like Playwright/Puppeteer for the terminal

I mean, a tty is just a file descriptor... there have been script(1), expect(1) and chat(8) since the 80ies. tmux is not really necessary.

Re:You might not need tmux by epr on Friday August 01, 2025 @07:36AM (#44755419)
These are all great. If you need to do something more involved, pexpect is also worth mentioning. It's a reimplementation of expect in python that's easy to be productive with quickly.

I used it in a previous job to automate configuring thousands of network devices

Re:You might not need tmux by woleium on Friday August 01, 2025 @07:36AM (#44755417)
Re:You might not need tmux by AlecSchueler on Friday August 01, 2025 @07:55AM (#44755540)
Re:You might not need tmux by chrisweekly on Friday August 01, 2025 @08:02AM (#44755579)
er, the context in this subthread is tmux alternatives
Re:You might not need tmux by AlecSchueler on Friday August 01, 2025 @08:54AM (#44756065)
No, it wasn't, and I think you've missed the joke.
Re:You might not need tmux by 0x457 on Friday August 01, 2025 @12:20PM (#44758956)
The context is "you don't need an entire terminal multiplexer such as Tmux when all you need is pseudo-tty".

Bringing another terminal multiplexer isn't an alternative. In my agent, I use pseudo-tty without any tmuxes/screens.

Re:You might not need tmux by anuramat on Friday August 01, 2025 @09:48AM (#44756796)
"tmux capture-pane" strips escape sequences that break the terminal and sets all the right variables; try using expect with e.g. neovim
Re:You might not need tmux by barmic12 on Friday August 01, 2025 @10:39AM (#44757458)
You right, it's pseudo terminal needed. The module pty of python can do this
Re:You might not need tmux by anuramat on Wednesday August 06, 2025 @12:03PM (#44813824)
maybe I'm biased, but python feels like endless boilerplate for unixy stuff

also I'm mostly using it to prepare an interactive environment anyway, so I don't see alternatives for my usecase (maybe zellij, but they don't even support sending keystrokes to a specific pane)

Re:You might not need tmux by blueflow on Saturday August 02, 2025 @04:43AM (#44765811)
I did use a shell script and script(1) to automate vi. Don't see the issue?
Re:You might not need tmux by anuramat on Wednesday August 06, 2025 @11:50AM (#44813628)
I suppose things that cause most of the problems don't exist in vi, eg (24 bit) color, image protocols or $TERM dependent features
Re:You might not need tmux by franktankbank on Friday August 01, 2025 @06:55AM (#44755182)
Your scientists were so preoccupied with whether or not they could, they didn't stop to think if they should.
Re:You might not need tmux by d4rkp4ttern on Friday August 01, 2025 @07:26AM (#44755360)
Nice. Had to look it up, didn’t know it was a famous Jurassic Park quote, even though I did see it when it came out :)
Re:You might not need tmux by franktankbank on Friday August 01, 2025 @07:36AM (#44755413)
Right back at you. I think its a pretty interesting application.
Re:You might not need tmux by wild_egg on Friday August 01, 2025 @09:28AM (#44756504)
Do you find the tmux-cli wrapper to improve results?

I tell Claude to use the existing tmux CLI to send-keys, capture-pane, etc. and it works flawlessly. Literally just "never use the Bash tool, run all commands in tmux sessions" and it knows what to do from there.

Re:You might not need tmux by d4rkp4ttern on Friday August 01, 2025 @11:19AM (#44758136)
One other thing I found is that when it spawns another Claude in a pane, and sends it a message, the enter key doesn’t register if sent immediately, so the other Claude doesn’t act on it. So in Tmux-cli I added a delay after experimenting with various values. I guess with plain Tmux it might run into this issue.
Re:You might not need tmux by d4rkp4ttern on Friday August 01, 2025 @11:04AM (#44757873)
This is nice to know. I didn’t compare with plain Tmux but should. In Tmux-cli I set up some convenience functions and scaffolding to prevent accidentally killing itself etc. But yes if plain Tmux works well I would just use that; it’s one less context burden.
Re:You might not need tmux by Izkata on Friday August 01, 2025 @10:22AM (#44757238)
> and found out that one of the nifty features is that it is scriptable, I.e allows programmatically sending keystrokes to a specific pane

In case anyone was curious, screen can do this too with the command "stuff" (read it as the verb like "stuffing something into a box").

Re:You might not need tmux by benji-york on Friday August 01, 2025 @12:16PM (#44758916)
If you're interested in doing similar things but with a terminal, the Kitty remote control mechanism is pretty cool: https://sw.kovidgoyal.net/kitty/remote-control/
Re:You might not need tmux by xrd on Friday August 01, 2025 @01:28PM (#44759732)
I'm reviewing the docs and interested in the scripting. I like that it uses python to script.

Could I have kitty send each line it receives to an external tool, say via HTTP?

I want to make a custom frontend to claude code, or any other CLI tool, and an obvious easy frontend is a web tool that communicates over HTTP, so getting claude wrapped in a HTTP control system seems like a good starting point.

I'm interested in whether things like "tmux capture-pane" which strips characters come from Kitty as well? Do I need to be cautious of control characters?