All posts

Ask Tarsk one question from the terminal

Run npx tarsk -p with a prompt. Tarsk answers in the project for your current folder, prints the answer to stdout and exits.

Some questions do not need a chat window. You are in a terminal, you have a diff in front of you, and you want a review of it. The new -p flag runs one prompt through the Tarsk agent without the interface, prints the answer and exits.

One prompt, one answer

From any project folder:

npx tarsk -p "explain src/index.ts"

Tarsk starts in the background with no browser window. It opens the project for the folder you are in, adds it as a project if Tarsk does not know it yet, and starts a new chat in that project’s workspace. The agent runs with the same tools it has in the app, so it can read files, search the code and run commands. The answer streams to your terminal as the agent writes it. When the run ends, Tarsk shuts down.

The long form is --prompt, and --prompt="..." works too.

Pipe text in

With a pipe, Tarsk adds what you send on stdin below your prompt:

git diff | npx tarsk -p "review this"

This works for any text: a failing test log, a stack trace, a CSV you want summarised. Leave the prompt text out and Tarsk uses stdin as the whole prompt:

cat question.md | npx tarsk -p

Pick the model

By default the run uses the model you set as Default in Settings > Default Models. If you have not set one, Tarsk tells you to. Pass --model to pick another one, and add --provider when the same model is available from more than one provider:

npx tarsk -p "summarise this log" --model <model-id> --provider <provider>

Use it in scripts

The flag keeps the output clean for other tools. Only the answer goes to stdout. Status lines, such as which port Tarsk started on, go to stderr, so npx tarsk -p "..." > review.md writes just the answer to the file.

The exit code tells a script what happened:

  • 0 when the agent finished
  • 1 when the run failed; the error goes to stderr
  • 2 when there was no prompt, from the flag or from stdin

Approvals still apply

A headless run follows the same permission rules as the app. If the agent wants to run a command that needs your approval, it waits, and Tarsk prints a line to stderr with the address where you can approve it. For unattended scripts, ask for read-only work such as reviews and explanations, or set your approval rules first in the app.

Try it

  • cd into a project and run npx tarsk -p "what does this repo do?".
  • Pipe a diff in with git diff | npx tarsk -p "review this".
  • Redirect stdout to a file to keep the answer.

Install Tarsk from tarsk.io.