Skip to content

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]

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.

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.

knosh prompt --agentId my-agent "Summarize the changes in the last commit."
File (--promptFile)

Read the prompt from a file. Pass - to read from stdin explicitly.

knosh prompt --agentId my-agent --promptFile prompt.txt
cat prompt.txt | knosh prompt --agentId my-agent --promptFile -
Piped stdin

Pipe text directly into knosh prompt without any flag.

git diff HEAD~1 | knosh prompt --agentId my-agent

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> (required)
The agent to use. Must match an agent filename (without .md) in the agents directory.
--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.log file.
--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:

knosh prompt --agentId my-agent "What model is this, and what can you do for me?"

Summarize a file:

knosh prompt --agentId my-agent --promptFile analysis.txt

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:

knosh prompt --agentId my-agent --log-dir logs --log-level DEBUG "Explain this error."