CodeBrew

Architecture

Tech stack, entry points, and how a request flows through the CLI.

Tech stack

LayerTechnology
LanguageTypeScript (ES2022, NodeNext modules)
RuntimeNode.js 18+
AI SDK@anthropic-ai/claude-agent-sdk
CLI frameworkcommander
Interactive prompts@inquirer/prompts
Terminal UIchalk, boxen, figlet, ora
Process executionexeca
Configdotenv

How a command flows through the CLI

index.ts boots the program and parses argv. cli.ts maps each command to an action and validates flags like --mode. AI-facing commands pass through an environment guard that checks Node's version and your API key before doing anything else.

  • wakeup and chat build a streaming session (an input bridge feeding the SDK's AsyncGenerator mode), staying alive until you exit.
  • talk uses the single-shot path, passing a plain string prompt to the SDK and streaming the result.
  • Both paths share the same mode-to-permissions mapping and the same message renderer.

Message rendering

As the SDK streams different message types, a single renderer decides how each one is displayed: assistant text and tool calls in one color, tool results in another, and a final summary line with turn count and cost. It collects output for a turn before printing, so long tool-heavy turns don't produce a pile-up of empty status tags.

CodeBrew is both a learning project for the Claude Agent SDK and a foundation for a production-ready CLI assistant.