craig0990
PING waiting for reply...
unset THEME
commit 0675f0ce Author: Craig Roberts <hello@craig0990.co.uk> Date:

Microtools with LLMs

Working with curl on the command line for one-shot requests is usually a pleasant enough experience: curl example.com, curl -v for a bit more info, and curl --help | less if something more is needed.

Interacting with multiple APIs that need to be chained in sequence to execute a user journey is when I often reach for Postman: environments, variables, collections that can be shared between a team.

After watching Understanding is the new bottleneck — Geoffrey Litt, Notion recently, and encountering this problem (again) in a new codebase at $DAYJOB, I figured I could try a different approach:

Build me a TUI REPL that takes slash commands to interact with the API, display JSON responses in light grey, and extract the data from each response payload to display as a main command response

(Not the exact prompt, but the idea is there)

javascript
import repl from 'node:repl';

repl.start({
  prompt: 'you > ',
  ignoreUndefined: true,
  eval: (line, _ctx, _file, done) => {
    const [name, ...args] = line.trim().split(/\s+/);
    if (name.startsWith('/')) {
      handleCommand(name.slice(1), args);
    } else {
      console.log(`Unknown command: ${line.trim()}`);
    }
    done(null);
  },
});
AI-generated code. It is here to explain or showcase an idea, not to claim authorship, and not as a finished or supported piece of software. Provided as is, without warranty of any kind. Check it before you rely on it.

This won't be as useful as a real integration test, or a real round of testing. But it is useful to work with a limited subset of APIs that need awkward setup, data payloads, and sequencing.

It's always tempting to keep adding to it ☺️ Environment switching! JSON presets! CLI themes and a nested JSON tree viewer!

It filled a quick need and took a few minutes to produce, but I might build a slightly more permanent CLI for my own day to day workflows.