Automate real Claude Code and Codex sessions in headless PTYs.
Write scripts that control normal interactive Claude Code and Codex sessions, which use your regular subscription.
HEADLESSINTERACTIVEAGENTSESSIONS
What Elwood does
Real Claude Code and Codex sessions, automated.
Elwood starts the actual agent CLI in a hidden terminal and types into it the way you would. The agent keeps its tools, hooks, configuration and login. Your script sends a prompt and gets the reply back as a string, a stream of typed events, or JSON. Because it is the normal interactive session, it runs on the subscription you already pay for, not on a metered API key.
Install
npm install -g @with-logic/elwoodFor the library, npm install @with-logic/elwood in your project.
The library
From TypeScript
Create a session, send a prompt, read the reply. Stream typed events when you want to watch the agent work.
import { ClaudeSession } from "@with-logic/elwood";
const session = new ClaudeSession({
cwd: "/path/to/project",
});
try {
console.log(await session.send(
"Explain this project."
));
} finally {
await session.close();
}Use CodexSession for Codex, or session.stream() for typed activity as it happens.
The CLI
From your shell
Pipe in a diff, a document or a build log. Get back text, JSON or a stream of events that the next command can use.
git diff | elwood "Review this diff for correctness."
elwood --output json "Which module owns auth?"
elwood --agent codex "Summarize the failing tests."If no agent is specified, we try Claude Code first and then Codex if Claude isn't found.