Prompt Runner
TUTOR WITH THEFOCUS.AI
Copy this prompt into Claude, ChatGPT, or any external AI assistant. It points the assistant to the course instructions and links it to your student profile to track your progress and customize observations.
You are not enrolled yet. Enroll to generate a Student ID to track lesson completions and store learning notes.
06 — The Prompt Runner
What We’re Building
The prompt runner is the simplest tool in our toolkit: take a prompt.txt from a directory, feed it to Ollama, save the output.
But even this simple tool introduces an important pattern: each prompt lives in its own directory with everything it produces. This keeps your work organized and reproducible.
The Script
This is the run_prompt.sh generated by our one-shot prompt (plan1.md). Copy and save it:
#!/bin/bash
# Prompt Runner — feeds prompt.txt to Ollama and saves output
# Check for directory argument
if [ -z "$1" ]; then
echo "Usage: $0 <directory>"
echo "Example: $0 ./my-prompt"
exit 1
fi
DIR="$1"
PROMPT_FILE="$DIR/prompt.txt"
OUTPUT_FILE="$DIR/output.txt"
MODEL="gemma4:26b"
# Check that prompt.txt exists
if [ ! -f "$PROMPT_FILE" ]; then
echo "Error: $PROMPT_FILE not found."
echo "Create a prompt.txt file in $DIR"
exit 1
fi
# Run the prompt through Ollama and save output
echo "Running prompt in $DIR using $MODEL..."
cat "$PROMPT_FILE" | ollama run "$MODEL" --nowordwrap > "$OUTPUT_FILE"
echo "Done! Output saved to $OUTPUT_FILE"
Setup
# Save the script
nano run_prompt.sh
# (paste the code above, save and exit)
# Make it executable
chmod +x run_prompt.sh
Usage
Create a directory with a prompt.txt file:
mkdir -p my-first-prompt
echo "Write a haiku about programming" > my-first-prompt/prompt.txt
Run it:
./run_prompt.sh my-first-prompt
Output:
Running prompt in my-first-prompt using gemma4:26b...
Done! Output saved to my-first-prompt/output.txt
Check what the model wrote:
cat my-first-prompt/output.txt
Key Design Decisions
Why this approach?
- Bash, not Python — zero dependencies. Works on any Mac out of the box.
- One directory per prompt — keeps inputs and outputs together
- Overwrite, don’t version — (simple! YAGNI!) — we want the latest output, not a collection of old ones
- Error handling — checks that the directory and prompt file exist before running
The --nowordwrap Flag
You’ll notice ollama run model --nowordwrap. Without this flag, Ollama may wrap the model’s output at a fixed width, which can break code formatting. The --nowordwrap flag preserves the model’s original formatting.
What You’ve Learned
- A simple bash script can run prompts through Ollama
- Keeping each prompt in its own directory organizes your work
- Error handling prevents confusing failures
--nowordwrappreserves code formatting
Next: 07 — Self-Improving →