Show HN: Clai – AI for the command line (stdin → LLM → stdout)

github.com

4 points by maxrodrigo 4 days ago

Since ChatGPT launched I've been trying to integrate LLMs into my workflows; emails, commits PRSs, or even long chat threads. My instinct was to code a small automation platform, but I found myself limited once again by its own constraints. Went back to zero, twice, and went back to the tools I've been using for years: UNIX pipelines. I started using llm and later mods (now deprecated) and they're great tools, but I wanted something leaner and that would compose better with other tools.

Clai does one thing: takes stdin, sends it to a model of your choice and prints the result. No REPL, no state. When it's done it just exits.

  git diff | clai commit
  cat article.txt | clai summarize | glow
  pbpaste | clai tldr
  curl -s example.com/article.html | clai -e "Extract the three main concepts"

It ships with a set of named prompts but you can override, add or extend as needed, they're just files with frontmatter. There's also strategies (chain-of-draft, chain-of-thought, tree-of-thought, and self-refine) to change the reasoning depending on your needs.

Works with major providers and I'll keep adding more. It can also be pointed to a local model so nothing leaves your machine.

Install with:

  brew install maxrodrigo/tap/clai

This is v0.3.0 and it's a few weeks old. It's early and rough around the edges. I'd appreciate feedback on what's missing and if you find it useful. Contributions welcome.