AI/TLDR

Simon Willison · 2026-05-11 · notable

Simon Willison — Using LLM in the Shebang Line of a Script

Three patterns for executable shebang scripts that route through Simon Willison's llm CLI: fragments via -f, named tools via -T, and full YAML templates that define custom Python tool functions in one file.

Simon Willison GitHub avatar

Simon Willison turns a one-line English description into an executable LLM script via the Unix shebang line.

What is it?

A short technique post showing how to build runnable shell scripts whose body is consumed by Simon Willison's `llm` CLI tool rather than a shell. Stdin pipes through the chosen model and the script's text becomes either a prompt fragment, a tool-augmented call, or a YAML template that bundles tools and parameters. The idea was sparked by a Hacker News comment suggesting you could put a shebang on an English text file.

How does it work?

Three escalating patterns. `#!/usr/bin/env -S llm -f` treats the file as a prompt fragment. Adding `-T <tool>` lets the model call named Python functions during the run. A YAML template defines model parameters, system prompts, and custom Python tool functions inline so the shebang launches a self-contained agent. The companion TIL walks through a Datasette SQL example end-to-end.

Why does it matter?

Turns ad-hoc LLM prompts into versionable, executable artifacts you can drop into `$PATH` alongside regular shell scripts and call from cron, git hooks, or other tools — without writing wrapper code or a custom CLI.

Who is it for?

Developers already using Simon's `llm` CLI; shell-heavy automators building one-off agentic pipelines.

Try it

uv tool install llm

Sources · 2 outlets

Tags

  • article
  • llm-cli
  • shell
  • scripting
  • tools
  • datasette
  • simonwillison

← All releases · Learn AI