prinia "where does a unix pipe buffer its data?"On a terminal the answer streams as it is generated.
stdin is data and the argument is the instruction. With only stdin, the input itself is the prompt.
cat error.log | prinia "extract the 500 status codes" | jq .
git diff | prinia "write a one-line commit message" | pbcopy
journalctl -u app | prinia "output a JSON array of distinct error messages" | jq -r '.[]'Whenever stdin or stdout is not a terminal, prinia behaves as a filter: a system prompt asks for plain text with no greeting or commentary, a single wrapping code fence is stripped, diagnostics go to stderr, and the output is written once, when the answer is complete. A reader that exits early (| head -n 1) is fine.
Things to know when chaining:
- prinia reads all of stdin before calling the model.
tail -f log | priniawaits for the stream to end. - Model output is not deterministic. When another tool parses the result, name the format in the instruction ("output a JSON array of ...").
- If the answer is cut off at the output limit, prinia says so on stderr; raise
max_tokens. - The exit code is
0on success and1on any failure (network, provider error, a refused request, configuration).
| Flag | Tier | Anthropic default |
|---|---|---|
-f, --fast |
fast | claude-haiku-5-5, effort low |
| (none) | regular | claude-sonnet-5-5, effort medium |
-d, --deep |
deep | claude-opus-5-5, effort high |
-m NAME, --model NAME |
an exact model name |
Other providers have no built-in models: set model (and optionally fast_model and deep_model) for the provider. A provider with only model set uses it for every tier. See Configuration.
Without a flag, the regular tier is used. To choose by the size of the call instead, set fast_under (calls with fewer characters than this use the fast tier) and deep_over (calls with more use the deep tier). -f, -d and -m always win. The rule counts the instruction plus the piped input, so a short question about a large file goes to the regular or deep tier.
A call identical to one already in your history is answered from the history, with no network request and no cost. "Identical" means the same provider, model, system prompt, instruction, input, effort and token limit. Entries expire after cache_ttl (default 7 days).
By default the cache is used for piped calls (cache = "pipe"), where repeating a script should repeat its result. Interactive questions always go to the model, since you usually ask again to get a fresh answer. Set cache = "always" to use it everywhere or "off" to never. --no-cache skips it for one call.
A call can only be served from history if it was recorded, so record = false and --no-record calls never become cache entries.
Models have no memory between calls. -c (--context) sends the most recent turns from your history in this directory along with the new question, so a follow-up knows what came before:
prinia "what does SIGPIPE do?"
prinia -c "and how do I ignore it in Rust?"The context comes from your own history, not a provider's session, so it works with any provider and survives a switch of model. Only turns from the current directory are used, oldest first, and long turns are cut. Turns made with a provider tagged private are never sent to one that is not (see Tags and private mode). Calls made with --no-record are not in the history, so they never appear in a context.
Set context = 5 (a number of turns) to include context on every call, and --no-context to leave it out once. context_chars (default 16000) caps its size; the oldest turns are dropped first.
Older turns are not simply dropped. The context has four tiers:
- Recent turns, word for word: the newest
contextturns. - Relevant older turns, in full: up to
context_relevantturns (default 3;0turns it off) from further back that match the words of your new question (prompt matches count most; a word that is in most of your turns is ignored). They use up to half ofcontext_chars. Only the newest 300 turns of the directory are searched. This is what letsprinia -c "why did the payments API time out again?"find the exchange from three weeks ago. - Older questions, one line each: the next
context_olderturns (default 30;0turns it off), cut to 160 characters, so the model knows what you were working on. - Summaries (opt-in,
context_summary = true): older turns are grouped into blocks of about 25 history entries, and each finished block is summarized once by the fast tier of the same provider as the call, soprivateandtagrules hold. Only the newestcontext_blocksblocks (default 4) are included. A summary is stored encrypted next to the history and is derived from it: any delete (history rm, size or age limits) drops all stored summaries, and they are rebuilt from what is left. Summaries are lossy; the model can be wrong about details it never saw in full.
prinia context [QUESTION] prints exactly what -c would send for this directory; give it the question to see which older turns it would pull in. prinia context --summarize builds and stores the summaries (tier 4) now instead of at the first -c call that needs them.
A call with context is cached separately from the same question without it.
Models have a context limit. Set max_input (characters, 0 = off, which is the default) and prinia handles longer stdin in two steps: it runs your instruction on each part separately (in parallel, -j at a time, cut at line ends), then asks once more to combine the partial answers.
prinia init # sets max_input = 48000 for a local model
cat huge.log | PRINIA_MAX_INPUT=40000 prinia "what went wrong, in 5 bullets?"This works for summaries and extraction. It does not work for questions that need the whole text at once, such as counting across parts or comparing the first line with the last: each part is answered blind to the others, and a small model's combined answer to those can be wrong. max_input is a project setting too.
cat urls.txt | prinia --each "one-line summary of the page at this URL"
git ls-files '*.py' | prinia --each -j 8 "does this file name suggest a test? answer yes or no"--each makes a separate call for every non-empty stdin line, -j N at a time (default 4), and prints the answers in input order, one per line. Each call is cached and recorded like any other, so rerunning a half-finished batch only asks for what is missing. A failed line prints an empty answer, reports the reason on stderr, and the exit code is non-zero. Ask for one-line answers; a multi-line answer breaks the one-answer-per-line pairing.
Save an instruction you reuse as a file, then call it by name:
mkdir -p .prinia/templates
echo "Write a one-line conventional commit message for this diff." > .prinia/templates/commit
git diff | prinia -t commit | pbcopy
git diff | prinia -t commit "mention the ticket ABC-12" # extra words are added after the templateprinia -t NAME looks for .prinia/templates/NAME in the current directory and its parents (so a repository can ship its own), then templates/NAME next to your global config. A template is plain text; it is the instruction, nothing more, so it cannot change settings.
eval "$(prinia shell zsh)" # add to ~/.zshrcType what you want in plain words and press ctrl-g. It is bound in emacs mode and in both vi modes. Set PRINIA_WIDGET_KEY before the eval line to change it, or to use several keys: export PRINIA_WIDGET_KEY='^x^p ^n' (zsh key notation; ^g is ctrl-g). To free ctrl-g again, rebind it after the eval: bindkey '^g' list-expand. The line is replaced by one shell command, which you can edit; nothing runs until you press enter. The model is told your shell and OS and which of rg, fd, jq and yq are installed. prinia --cmd "..." does the same without the widget. Answers from small local models can be wrong, so read the command before running it.
Models sometimes return something a script cannot use. Two flags make a call refuse bad answers:
journalctl -u app | prinia --json "list the distinct errors as a JSON array" | jq -r '.[]'
prinia --check 'python3 -m py_compile /dev/stdin' "write a python function that parses ISO dates" > dates.py--json requires the answer to be one valid JSON value (and tells the model so). --check COMMAND requires the command to accept the answer on stdin and exit 0, so any validator works: jq -e ., xmllint --noout -, a linter. If the answer fails, prinia asks again, up to check_retries more times (default 2). If every attempt fails it prints nothing, exits non-zero and saves nothing, so a bad answer never reaches the next command in your pipeline or the cache. Checking waits for the complete answer, so a terminal does not stream while a check is on. Failed attempts are not counted in stats.
A cached answer that fails --check is ignored and replaced by the fresh one, which also repairs an entry that was cached before you started checking. --json adds an instruction to the prompt, so its answers are cached separately.
Answers cut off at the output limit are kept in the history but are never reused as a cache hit.
Every successful call is saved to the history after its output has been written. --no-record skips it for one call; record = false (or PRINIA_RECORD=0) turns it off for a directory or everywhere, and --record overrides that for one call.
-p NAME (--provider) selects a provider for one call. Without it, prinia uses the provider setting, then whichever of ANTHROPIC_API_KEY and OPENAI_API_KEY is set. See Configuration.
| Flag | |
|---|---|
-p, --provider NAME |
Provider for this call |
-f, --fast / -d, --deep |
Tier |
-m, --model NAME |
Exact model |
-c, --context |
Include earlier turns from this directory |
--no-context |
Send no earlier turns, even if context is set |
--json |
Require the answer to be valid JSON; retry if not |
--check COMMAND |
Require the command to accept the answer on stdin; retry if not |
--no-cache |
Skip the history cache |
--record / --no-record |
Save or don't save this call |
-t, --template NAME |
Use a saved instruction (Templates) |
--each, -j N |
One call per stdin line, N at a time (One call per line) |
--cmd |
Answer with one shell command (what the zsh widget uses) |
-a, --agent / -x, --do |
Agent mode / agent mode that may run commands (Agent) |
--write, --run, -y, --no-agent |
Agent permissions, skip the command question, turn the agent setting off once |
| Command | |
|---|---|
prinia config |
Show every setting and where its value comes from |
prinia update [--check] |
Update prinia to the latest release (Install) |
prinia init |
Find Ollama, pick a model for this machine, write the config |
prinia trust |
Review and trust this project's .priniarc (Configuration) |
prinia context [QUESTION] |
Show what -c would send; --summarize builds summaries now |
prinia shell zsh |
The zsh widget, for eval in ~/.zshrc |
prinia history |
Browse, show, rm (History) |
prinia key |
show, import, rotate (History) |