CodeNeter

Headless use

Run a single prompt from scripts or other tools with codeneter run, read text or JSON output, and control approvals.

codeneter run sends one prompt, lets the agent work until it's done, and exits without opening the interactive interface. Use it in scripts and other automation on a machine where you've signed in with codeneter login.

Run a prompt

Pass the prompt with --prompt, or -p:

codeneter run --mode ask --prompt "List the main modules in this project and what each one does"

Without --prompt, the CLI reads the prompt from standard input:

codeneter run < task.md

Saved commands work too, with any extra text after them:

codeneter run --prompt "/review-branch focus on the authentication changes"

--mode, --model, and --workspace work as they do in interactive sessions.

Output and exit codes

--output-format sets what the run prints to standard output:

FormatOutput
textThe agent's reply as plain text, streamed as it's written. This is the default.
jsonOne JSON object when the run finishes. --json does the same.
stream-jsonOne JSON event per line while the run is in progress

--json can't be combined with a different --output-format.

The json object includes:

FieldContents
oktrue if the run finished without an error or usage limit
responseThe agent's final reply
modelThe selected model, or auto when Auto is selected
errorError message, if the run failed
limitDetails of the usage limit, if one was reached
sessionIdID of the saved session, for --resume

The exit code is 0 when the run finishes and 1 when it fails or reaches a usage limit. With json and stream-json, a run that fails partway still prints its result, with ok set to false. With text, the error message goes to standard error.

Problems that stop a run before it starts, such as not being signed in, a missing prompt, or an unknown conversation ID, are printed to standard error with exit code 1. In that case json prints nothing to standard output. stream-json still prints a closing result event with ok set to false, unless the options themselves are invalid.

Stream events

With stream-json, each line of standard output is one JSON object with a type:

EventFieldsMeaning
initsessionId, resumed, workspaceRoot, model, modeThe run has started and the conversation is saved
assistant_deltatextPart of the reply, as it's written
assistant_messagetextA completed assistant message
tool_starttoolCallId, tool, argsThe agent called a tool
tool_resulttoolCallId, tool, ok, result, errorThe tool call finished. error is present when ok is false.
retry_resetNoneThe request is being retried
resultThe same fields as the json objectThe run is over. Always the last line.

An assistant_message can repeat text already received as deltas. Use deltas for live display or completed messages, rather than appending both. After retry_reset, discard the deltas received since the last assistant_message. Read the outcome from result, not from the events before it.

Continue a conversation

Headless runs save their conversation history. --resume <sessionId> sends the next prompt to a saved conversation, with its earlier messages as context. Replace SESSION_ID below with the sessionId from the first run's result:

codeneter run --json --prompt "Summarize the test coverage in this project"
codeneter run --resume "SESSION_ID" --prompt "Which gaps should I address first?"

The ID also appears in the init event of stream-json. Text output doesn't print it. Interactive sessions use the same saved conversations, so the ID also works with codeneter --resume.

A resumed run works in the conversation's saved folder, with its saved model and mode. --model and --mode override the saved values. --workspace isn't needed, and a run is refused if it points to a different folder. An unknown ID is an error, not a new conversation.

Run one prompt at a time on a conversation. Runs that write to the same conversation at once aren't coordinated.

Approvals

A headless run can't stop to ask for approval. Unless auto-approval is on, actions that need approval are refused, and the agent continues without them: terminal commands other than the few exempt inspection commands, file deletions, and MCP tool calls when confirmMcp is on. File edits don't need approval, so they go ahead in every mode. Ask and Plan guide the agent; they don't block changes.

--auto, or autoApprove: true in your configuration, approves these actions without asking. Resuming a conversation that had /yolo on doesn't turn auto-approval on. Plan mode still can't ask clarifying questions in a headless run.

With auto-approval on, the agent can run commands and delete files without asking. Keep a recoverable copy of your work. Commands can also affect files and services outside the project.

Trusted folders

Project rules, skills, and MCP servers load only in folders you've trusted. If a headless run should use them, open the folder once in an interactive session and trust it.