Urgent.News

What's breaking now, across thousands of outlets.

Culture

Your Half-Typed Prompt Lives Inside the Agent, Not the Terminal. Injected Commands Hit It

Book: Prompt Engineering Pocket Guide The series: Pocket Guides for Developers — 8 short books on agents, RAG, prompts, observability, events, databases and system design — the whole series My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub You are halfway through a sentence in Claude Code : fix the flaky login…

In the world of prompt engineering, a half-typed prompt actually resides inside a full-screen agent, not the terminal. When you're halfway through a sentence in Claude Code, like "fix the flaky login test but don't touch", the command you type, including "/compact", doesn't actually run as a command. This is because the agent owns the terminal and processes the input differently than a normal shell.

The source material explains that in a normal shell, input is processed line by line, with line editing enabled. However, full-screen agents, such as Claude Code, switch this off. By using libraries like Ink, Node's setRawMode, and crossterm, the agent reads keys character-by-character, without line buffering or line editing. This means every keystroke goes straight to the agent, which keeps the draft in its own memory and decides how to handle backspace or enter keystrokes.

To demonstrate this, the source provides two small Python scripts. The first, "toy_agent.py", switches its terminal to raw mode and keeps its own draft. The second, "inject.py", starts the toy agent in a pseudo-terminal, then simulates typing half of a prompt and then "/help" command. This shows how the agent processes the input, regardless of what is typed in the terminal.

The key takeaway is that in modern prompt engineering tools, the half-typed prompt lives inside the agent, not the terminal. The terminal is just a display for the agent's output. Understanding this can help developers deal with commands that are injected into running agents, and avoid unexpected behavior.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Culture

More from Saturday 31 October →