Using LLM in the shebang line of a script

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

A workable pattern for turning any text file into an executable LLM prompt with tool calls, usable today with Simon Willison's free open-source LLM CLI.

Read this as

Simon Willison describes how to put an AI prompt in the 'shebang' line of a file, the special first line that tells Unix systems which program should run the file. Using his free command-line tool called LLM, a text file whose first line invokes the tool becomes a runnable AI script. One example generates an SVG drawing of a pelican on a bicycle; another uses a time-reading tool so the AI can write a haiku mentioning the exact current time.

Willison's LLM CLI now supports a low-friction pattern where an entire script is just a prompt: the shebang line invokes the model, and options like '-T' attach tools. Tool calls even work inline, a demo calculator script ran multiply(2344, 5252) and add() correctly, returning 12,310,822. This is a developer conveniences, not a platform shift; no cost or enterprise implications are discussed.

The pattern uses '#!/usr/bin/env -S llm -f' so the file body is passed as a fragment prompt. Tool calling works via '-T name_of_tool', and YAML templates invoked with '-t' can define extra tools as inline Python functions plus a system prompt; a calc.sh example using model gpt-5.4-mini decomposed 2344 × 5252 + 134 into multiply and add tool calls, logging them with the --td debug flag. A fuller TIL example queries the Datasette SQL API over Willison's blog content.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

LLM Simon Willison Kim_Bruning Hacker News Datasette gpt-5.4-mini

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading