From 448e975dc18bbcfb85a994835c5aaa0eaecf711b Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 19 Jan 2026 16:35:20 +0100 Subject: [PATCH] docs: add Screen Input for Ink/Claude CLI pattern Document the critical finding that text and Enter key must be sent as separate screen -X stuff commands for Ink to process correctly. Co-Authored-By: Claude Opus 4.5 --- CLAUDE.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/CLAUDE.md b/CLAUDE.md index 8f006b84..26b08aec 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -125,6 +125,22 @@ pty.spawn('claude', ['-p', '--dangerously-skip-permissions', '--output-format', pty.spawn('claude', ['--dangerously-skip-permissions'], { ... }) ``` +### Screen Input for Ink/Claude CLI + +Claude CLI uses Ink (React for terminals) which has specific input handling. When sending programmatic input via `screen -X stuff`: + +**IMPORTANT**: Text and Enter key MUST be sent as separate commands: +```bash +# Correct - two separate commands +screen -S claudeman-xxx -p 0 -X stuff "hello world" +screen -S claudeman-xxx -p 0 -X stuff "$(printf '\015')" + +# Wrong - doesn't work with Ink +screen -S claudeman-xxx -p 0 -X stuff "$(printf 'hello world\015')" +``` + +The `\015` (octal) is carriage return (ASCII 13), which Ink interprets as `key.return` for submission. Use `writeViaScreen()` method for programmatic input that needs Enter key. + ### Idle Detection **RespawnController**: Primary `↵ send` indicator, fallback prompt chars (`❯`, `⏵`) + 10s timeout. Working patterns: `Thinking`, `Writing`, `Running`.