nima.hejazi
← Back to projects

ask: Terminal LLM Assistant

Go CLI LLM Terminal
Visit GitHub repo

A case study on ask, a small Go command line tool that puts an LLM in the terminal. It answers questions with streamed output, returns a single bare shell command you can paste or run, and only reaches for the web when the model is actually unsure.

Overview

ask started from a simple need: ask a quick question without leaving the shell. The design keeps the surface tiny and the behavior predictable:

  • Streamed answers for normal questions, with piped input for context.
  • A -c mode that returns one bare command, copied to the clipboard, and a -r mode that runs it after a y/N confirmation.
  • A web_search tool the model can call on its own, so lookups happen only when needed.
  • A provider setup wizard covering local (Ollama, LM Studio) and cloud (Anthropic, OpenAI) endpoints, plus any OpenAI-compatible custom base URL.

Architecture

The binary is plain Go with no framework. main.go wires the CLI flags and the provider selection, and the internal/ packages hold the provider clients, the chat loop, and the web-search backend. Configuration resolves from ~/.ask/config.yaml and is overridden by environment variables, with ask config printing the resolved settings while never echoing secrets.

stdin / args ──► ask ──► provider (local or cloud)
                       └──► web_search (model-gated, DuckDuckGo or Brave)

Build and release are handled by GoReleaser, with Homebrew, prebuilt archives, and go install as the three install paths. Tests run with go test ./....

The search tool is gated by the model rather than forced on every call. The default backend is keyless DuckDuckGo, and setting BRAVE_API_KEY switches to Brave. --no-web keeps queries entirely local when you want that.

Installation

brew install nima/tap/ask
# or
go install github.com/nimahejazi/ask@latest

Run ask init to configure a provider, then ask "how do I revert a file in git" to get going.