Prompt Improver
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.
Project: Prompt Improver (The Orchestrator)
Source: 3-prompt/
Model: gemma4:26b
Type: Bash script
What It Does
This is the master controller — the script that ties everything together. It supports two modes:
- Regular mode: runs a prompt through Ollama and saves the output
- Rerun mode: combines the original prompt, test output, and generated code, then feeds everything back for improvement
After either mode, it runs the code extractor and any test file.
The Prompt
Create a bash script with a shebang on the top that takes in a directory name
and optional a --rerun flag with a message
if its regular it runs
cat directory/prompt.md | ollama run gemma4:26b --nowordwrap | tee directory/ollama-output.md
if its a rerun it does
./1-combind/code \
-m rerunmessage \
directory/prompt.md directory/test-output.md directory/code | \
ollama run gemma4:26b --nowordwrap | \
tee directory/ollama-output.md
after either of those passes, it then runs
./2-extract/code directory
then it checks for a directory/test file, and if it's there it
chmod +x directory/test
directory/test 2>&1 | tee test-output.md
output only the code
The Code
#!/bin/bash
DIR=$1
MODE="regular"
MESSAGE=""
if [ -z "$DIR" ]; then
echo "Usage: $0 <directory> [--rerun <message>]"
exit 1
fi
if [ "$2" == "--rerun" ]; then
MODE="rerun"
MESSAGE="$3"
fi
if [ "$MODE" == "rerun" ]; then
./1-combind/code \
-m "$MESSAGE" \
"$DIR/prompt.md" "$DIR/test-output.md" "$DIR/code" | \
ollama run gemma4:26b --nowordwrap | \
tee "$DIR/ollama-output.md"
else
cat "$DIR/prompt.md" | ollama run gemma4:26b --nowordwrap | tee "$DIR/ollama-output.md"
fi
./2-extract/code "$DIR"
if [ -f "$DIR/test" ]; then
chmod +x "$DIR/test"
"$DIR/test" 2>&1 | tee test-output.md
fi
Note: The original generated script had a typo in the rerun branch —
--nowordlamwrapinstead of--nowordwrap. This is why testing is essential! The code above has been corrected.
Usage
Regular Mode (First Run)
# Create a prompt directory
mkdir -p my-project
echo "Write a bash script that prints 'Hello World'" > my-project/prompt.md
# Run the prompt
./3-prompt/code my-project
This runs the prompt through Ollama, saves the output, extracts any code, and makes it executable.
Rerun Mode (Improvement Loop)
# After the first run reveals bugs, feed back the error
./3-prompt/code my-project --rerun "The script has a syntax error on line 5: missing semicolon"
This packs the original prompt, test output, and code together, sends it to Ollama with your feedback, and produces an improved version.
The Full Workflow
mkdir my-project
echo "prompt goes here" > my-project/prompt.md
# Step 1: Generate
./3-prompt/code my-project
# Step 2: Test (if you have a test file)
# The runner does this automatically
# Step 3: Evaluate
cat my-project/test-output.md
# Step 4: Rerun with feedback
./3-prompt/code my-project --rerun "the output formatting is wrong"
# Repeat steps 2-4 until it works
Key Lessons
- This is the orchestration layer. It coordinates the combiner, Ollama, extractor, and test runner.
- Two modes = two phases. Regular mode for initial generation, rerun mode for iterative improvement.
- Bash is enough. The entire pipeline runs in bash — no Python, no frameworks, no build steps.
- The rerun message is a human-in-the-loop channel. The AI gets the files, but you provide the intent.
Next: Ollama REPL →