« All posts

q: A C CLI Tool That Merges Shell and LLM in the Terminal

q is an open-source C CLI that blends shell commands with LLM queries in one REPL, letting sysadmins get help without leaving the terminal.

q is a proof-of-concept CLI that interleaves everyday shell commands with LLM queries inside a single REPL session, so sysadmins can ask clarifying questions without switching to a browser. It targets typical ops tasks—viewing nginx logs, creating systemd timers, writing rsync commands—by sending prompts to a local OpenAI-compatible Responses API and streaming answers directly to stdout.

The tool tries to auto-detect whether input is a shell command or a natural-language query, with ! and ? available to force either mode. When LLM responses contain fenced code blocks, they're automatically numbered so users can execute them by typing the number. A built-in debugging flow lets users type ?? after a failed command to ask the LLM for the cause and a fix.

Beyond the core loop, q includes session recording/resuming, HTTP MCP server integration, context retention via --keep-context, tab completion that summarizes man pages via the LLM, and a set of slash commands for configuration—features that add up to a fairly mature REPL experience. Built as roughly 7,000 lines of 'vibe-coded' C using codex, it's already used daily by its author despite being explicitly unfinished, and was open-sourced for others to experiment with.

For engineers, the project is a concrete example of building lightweight, dependency-light LLM-augmented terminal workflows, highlighting how blending shell and AI assistance in one interface can cut context-switching overhead during sysadmin work.

» SourceHashnode #9