Handling of stdio and/or command sequences
Hi there!
I'm on the Coder team working on some of the tooling around running agents in workspaces. Currently we have a bit of a hack going on where we run claude-code (or whatever agent) on the workspace behind screen.
When we start claude-code, we're passing it a prompt with the stuff command like so:
# Extremely hacky way to send the prompt to the screen session
# This will be fixed in the future, but `claude` was not sending MCP
# tasks when an initial prompt is provided.
screen -S claude-code -X stuff "$CODER_MCP_CLAUDE_TASK_PROMPT"
sleep 5
screen -S claude-code -X stuff "^M"
The hacky implicit sleep there is because all the methods we tried to send the ^M (or equivalent) along with the prompt ended up simply appending the newline to the prompt rather than triggering the return keystroke.
There are a few things we want to fix here, and could use y'alls help and/or input :)
- Really hate the implicit sleep. If you know how we could send a prompt to claude running in a background session / behind screen etc and get it to do the equivalent of a
returnkeystroke without having to send these separately that would be awesome. Trying to talk to claude over stdio doesn't seem to be supported at all. - We're sending the initial prompt this way rather than simply as an argument at startup because for some reason passing the prompt at startup wouldn't trigger the mcp task we wanted it to. I would love to understand the difference there, or if that's a coincidence and we're doing something else wrong, would love to understand what.
I'm certain there are things you'll need clarification on with this issue, so please feel free to hit me with a load of follow ups haha 😎
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗