claude-code - 💡(How to fix) Fix Feature request: External message injection API for active Claude Code sessions [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#53049Fetched 2026-04-25 06:13:44
View on GitHub
Comments
1
Participants
2
Timeline
4
Reactions
0
Timeline (top)
labeled ×3commented ×1

Add a mechanism to send a prompt to an already-running Claude Code session from an external process and receive the response — without requiring the user to type in the UI.

Root Cause

This is the missing piece for Claude Code to work as a true background agent. Right now external tools can:

  • ✅ Trigger new sessions
  • ✅ Read project files
  • ✅ Use --continue to resume history

But they can't:

  • ❌ Talk to the session the user has currently open
  • ❌ Inject a prompt into a running agentic loop
  • ❌ Get a response from a session without the user being at the keyboard

A simple IPC mechanism would unlock Claude Code as a true AI companion — reachable from mobile, from other processes, from voice assistants, from automation tools.

Fix Action

Fix / Workaround

Current workaround

RAW_BUFFERClick to expand / collapse

Summary

Add a mechanism to send a prompt to an already-running Claude Code session from an external process and receive the response — without requiring the user to type in the UI.

Use case

I'm building a WhatsApp companion bot (Hermes) that bridges my phone to my Claude Code sessions. When I'm away from my Mac, I want to send a message like "check the Saturno project for pending proposals" and have it run inside my actual active Saturno session — with its full conversation history and context — then receive the result back on WhatsApp.

Today I can run claude --print "task" --cwd /project/dir which correctly picks up CLAUDE.md and project files. But this creates a new session, losing the in-memory conversation history of the session currently open in the UI.

Proposed solution

Any of these would work:

  1. Named pipe / Unix socket per session: ~/.claude/sessions/<session-id>.sock — write a prompt, read the response.
  2. --session-id <uuid> flag for --print: run a task inside an existing session by ID, not just resume its history.
  3. Local HTTP endpoint per running session (e.g., localhost:PORT/prompt) — POST a message, GET the streaming response.
  4. --continue --print that actually injects into the latest session rather than creating a fork.

Why this matters

This is the missing piece for Claude Code to work as a true background agent. Right now external tools can:

  • ✅ Trigger new sessions
  • ✅ Read project files
  • ✅ Use --continue to resume history

But they can't:

  • ❌ Talk to the session the user has currently open
  • ❌ Inject a prompt into a running agentic loop
  • ❌ Get a response from a session without the user being at the keyboard

A simple IPC mechanism would unlock Claude Code as a true AI companion — reachable from mobile, from other processes, from voice assistants, from automation tools.

Current workaround

Running claude --print "task" --cwd /project/dir in the correct project directory. Works, but creates a parallel session without the active conversation context.

extent analysis

TL;DR

Implementing a named pipe, Unix socket, or local HTTP endpoint per session would allow external processes to send prompts to an already-running Claude Code session and receive responses.

Guidance

  • Investigate using a named pipe or Unix socket (~/.claude/sessions/<session-id>.sock) to enable communication between external processes and running Claude Code sessions.
  • Consider adding a --session-id <uuid> flag to the --print command to run tasks inside existing sessions by ID.
  • Evaluate the feasibility of creating a local HTTP endpoint per running session (e.g., localhost:PORT/prompt) for sending and receiving messages.
  • Assess the potential of modifying the --continue --print flags to inject prompts into the latest session instead of creating a new one.

Example

No code snippet is provided as the issue focuses on proposing solutions rather than implementing them.

Notes

The chosen solution should ensure that the conversation history and context of the active session are preserved and utilized when receiving prompts from external processes.

Recommendation

Apply a workaround using a named pipe or Unix socket, as it seems to be a straightforward and efficient way to establish communication between external processes and running Claude Code sessions, allowing for the preservation of conversation history and context.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Feature request: External message injection API for active Claude Code sessions [1 comments, 2 participants]