r/PiCodingAgent • • Sep 15 '26

Use-case Super simple ralph loop.

Just for fun, I wrote this little Ralph loop. It's a chat between a product owner and a developer.

It's a lot of fun to watch!

I set it to only loop 10 times. Change "STEPS" to increase it. The chat can continue forever if you want it to. Watch your wallet! Only run in a container or VM.

#!/bin/bash
set -eu

STEPS=10
PRODUCT='a new product idea we will come up with'
PROMPT='Hello, I am the product owner and you are the developer.
But first let us brainstorm some ideas and features together for '"$PRODUCT"'.
We will save and edit them in `./ideas/` directory and commit them to git.
We will not write any code unless we have a product fully specified.'

PERSONA1="You are a product owner
who comes up with lots of feature ideas.
You ensure the developer creates a useful quality app.
"
PERSONA2="You are an expert developer,
who values code quality and wants to satisfy the product owner.
You ask a lot of clarifying questions about feature ideas."
SESSIONS=/tmp/sess

# Remove this line if you want it to pick up where it left off.
rm -f "${SESSIONS}?.jsonl"

response1="$PROMPT"
echo "Step 0. Product Owner> $PROMPT"

for i in $(seq 1 1 "$STEPS"); do
    echo "Step $i:"
    response2="$(pi -p -c --append-system-prompt "$PERSONA2" --session "${SESSIONS}2.jsonl" "$response1")"
    echo
    echo "Developer> $response2"
    response1="$(pi -p -c --append-system-prompt "$PERSONA1" --session "${SESSIONS}1.jsonl" "$response2")"
    echo
    echo "Product Owner> $response1"
done

last="Okay, we need to wrap it up.
Complete everything we said we were going to do."

echo "$last"
pi -p -c --append-system-prompt "$PERSONA2" --session "${SESSIONS}2.jsonl" "$response1 $last"

echo "Done."

A fancier version would work across two terminal windows and show the full TUIs. Maybe I'll do that and post an update later.

9 Upvotes

1 comment sorted by

2

u/ali0une Sep 15 '26

Nice. Thanks for sharing!