From 2709ccefcddc616e89a70962f017bcbbca1f17bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Barreiro?= <52393857+BarreiroT@users.noreply.github.com> Date: Fri, 27 Jun 2025 00:43:58 +0200 Subject: [PATCH] fix: ENAMETOOLONG on Claude Code - write to stdin instead of including the messages in the prompt (#4494) * Write to stdin instead of including the messages in the prompt * Add changeset --- .changeset/chilled-paws-remain.md | 5 +++++ src/integrations/claude-code/run.ts | 10 +++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 .changeset/chilled-paws-remain.md diff --git a/.changeset/chilled-paws-remain.md b/.changeset/chilled-paws-remain.md new file mode 100644 index 00000000..856222e0 --- /dev/null +++ b/.changeset/chilled-paws-remain.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Fix ENAMETOOLONG when calling Claude Code diff --git a/src/integrations/claude-code/run.ts b/src/integrations/claude-code/run.ts index b97fa93f..94d2766a 100644 --- a/src/integrations/claude-code/run.ts +++ b/src/integrations/claude-code/run.ts @@ -112,7 +112,6 @@ function runProcess({ systemPrompt, messages, path, modelId }: ClaudeCodeOptions const args = [ "-p", - JSON.stringify(messages), "--system-prompt", systemPrompt, "--verbose", @@ -129,8 +128,8 @@ function runProcess({ systemPrompt, messages, path, modelId }: ClaudeCodeOptions args.push("--model", modelId) } - return execa(claudePath, args, { - stdin: "ignore", + const claudeCodeProcess = execa(claudePath, args, { + stdin: "pipe", stdout: "pipe", stderr: "pipe", env: { @@ -142,6 +141,11 @@ function runProcess({ systemPrompt, messages, path, modelId }: ClaudeCodeOptions maxBuffer: 1024 * 1024 * 1000, timeout: CLAUDE_CODE_TIMEOUT, }) + + claudeCodeProcess.stdin.write(JSON.stringify(messages)) + claudeCodeProcess.stdin.end() + + return claudeCodeProcess } function parseChunk(data: string, processState: ProcessState) {