You are viewing docs for version 0.1, which is archived.View the latest version.

Guides

Queries and unix pipes

Compose clai with standard input, placeholder substitution, raw output, and cron scripts.

On this page

clai query (shorthand q) is designed for unix pipelines: it accepts stdin, substitutes placeholders, and writes streamed responses to stdout.

Piping stdin

When you pipe data into clai q, stdin is prepended to your prompt by default:

cat build.log | clai q "Which compiler error caused the build to fail?"

Replacing placeholders with -i and -I

Use -i (-replace) to replace every occurrence of {} in your prompt with stdin:

git diff --staged | clai -i q "Write a conventional commit message for: {}"

If your prompt already contains {}, specify a custom replacement token with -I (-replace-string):

cat schema.sql | clai -I "SCHEMA" q "Generate Go structs for SCHEMA"

Raw output for scripts and cron

By default, terminal output is formatted for readability. When piping clai into another program, file, or CI job, pass -re (-raw) to emit raw unformatted text:

clai -re q "Output only a valid JSON array of three HTTP status codes" | jq .

See CLI for all query flags.

Last updated October 21, 2026

Type to search the documentation.