{"by":"chr15m","descendants":49,"id":46069556,"kids":[46073308,46079569,46070483,46070340,46071023,46071028,46072520,46070843,46073747,46074367,46070427,46071612,46071506,46071325,46072487,46070622,46070838],"score":134,"text":"I built a single-file Python script that lets you run LLM prompts from the command line with templating, structured outputs, and the ability to chain prompts together.<p>When I discovered Google&#x27;s Dotprompt format (frontmatter + Handlebars templates), I realized it was perfect for something I&#x27;d been wanting: treating prompts as first-class programs you can pipe together Unix-style. Google uses Dotprompt in Firebase Genkit and I wanted something simpler - just run a .prompt file directly on the command line.<p>Here&#x27;s what it looks like:<p>---\nmodel: anthropic&#x2F;claude-sonnet-4-20250514\noutput:\n  format: json\n  schema:\n    sentiment: string, positive&#x2F;negative&#x2F;neutral\n    confidence: number, 0-1 score\n---\nAnalyze the sentiment of: {{STDIN}}<p>Running it:<p>cat reviews.txt | .&#x2F;runprompt sentiment.prompt | jq &#x27;.sentiment&#x27;<p>The things I think are interesting:<p>* Structured output schemas: Define JSON schemas in the frontmatter using a simple `field: type, description` syntax. The LLM reliably returns valid JSON you can pipe to other tools.<p>* Prompt chaining: Pipe JSON output from one prompt as template variables into the next. This makes it easy to build multi-step agentic workflows as simple shell pipelines.<p>* Zero dependencies: It&#x27;s a single Python file that uses only stdlib. Just curl it down and run it.<p>* Provider agnostic: Works with Anthropic, OpenAI, Google AI, and OpenRouter (which gives you access to dozens of models through one API key).<p>You can use it to automate things like extracting structured data from unstructured text, generating reports from logs, and building small agentic workflows without spinning up a whole framework.<p>Would love your feedback, and PRs are most welcome!","time":1764253595,"title":"Show HN: Runprompt – run .prompt files from the command line","type":"story","url":"https://github.com/chr15m/runprompt"}