knosh prompt¶
Run a prompt through a named agent and print the response to stdout.
Synopsis¶
knosh prompt [--agentId <id>] [options] [PROMPT...]
knosh prompt [--agentId <id>] --promptFile <path> [options]
echo "..." | knosh prompt [--agentId <id>] [options]
Because prompt is the default command, the prompt keyword can be omitted:
Description¶
prompt sends a prompt to the specified agent and streams the response to standard output. The agent is identified by its filename (without the .md extension) in the agents directory; use list-agents to see what is available.
prompt is the default command: when the first argument is not a recognized subcommand name or a root-level flag (--help, --version), Knosh automatically routes the invocation to prompt. Running knosh with no arguments still prints root help.
Supplying the prompt¶
The prompt text can come from three sources — use whichever fits your workflow:
- Trailing argument
-
Pass the prompt directly on the command line. Multiple words are joined with spaces.
- File (
--promptFile) -
Read the prompt from a file. Pass
-to read from stdin explicitly. - Piped stdin
-
Pipe text directly into
knosh promptwithout any flag.When stdin is a terminal (not a pipe), Knosh prints a hint explaining how to signal end-of-input.
Warning
--promptFile and a trailing prompt argument cannot be combined. Knosh exits with an error if both are supplied.
Options¶
--agentId <id>- The agent to use. Must match an agent filename (without
.md) in the agents directory. Optional whendefaultAgentIdis set inknosh.json; required otherwise. --promptFile <path>- Path to a file to use as the prompt, or
-to read from stdin.
Execution¶
--max-iterations <n>- Maximum number of LLM API calls allowed per run. Default:
50. --temperature <value>- Sampling temperature in
[0.0, 1.0]. Overrides the agent's configured value.
Retries¶
--max-retries <n>- Number of times to retry after a transient failure. Default:
0. --retry-delay-ms <ms>- Milliseconds to wait before each retry. Default:
0. --exponential-backoff- Double the retry delay on each attempt.
Logging¶
--log-dir <path>- Directory to write log files. Each run appends to a
YYYY-MM-DD.logfile. --log-level <level>- Minimum log severity:
TRACE,DEBUG,INFO,WARN,ERROR. Default:WARN. --log-format <format>- Log line format:
compact(default),default,json,pretty. --log-full-prompts- Log prompt input and response in full instead of replacing long text with a character count.
--log-full-tool-calls- Log tool call arguments and results in full.
Examples¶
Ask a quick question:
Summarize a file:
Pipe output from another command:
git log --oneline -20 | knosh prompt --agentId my-agent "Write a release summary for these commits."
Enable debug logging to a directory:
Live status and benchmarking¶
When stderr is an interactive terminal, prompt shows a live status line while the agent runs — a
Braille spinner that cycles through starting…, calling model…, and running tool: <name> as the
run progresses. The status line is written to stderr and erased when the response is ready, so it
never interferes with the response on stdout (which remains safe to pipe or redirect).
Add --benchmark to print a metrics summary to stderr after the run completes:
The summary is printed only when --benchmark is set and stderr is an interactive terminal.
Token counts are omitted when the model provider does not report usage metadata.