Lesson 1 of 6 in Agentic pipelines · 10m

Prompts and runbooks

After this lesson you know when a prompt is worth saving, how to turn the part that changes into a variable, and how to chain a good session into a runbook that loops until the work is done and then stops.

The third time, save it

Every agentic workflow has a handful of requests you make over and over: review the diff, explain this failure, write the commit message, run the tests and fix what breaks. The first time you type one, you are working out what to ask. The second time, you are remembering what worked. By the third time you are retyping a slightly worse version of the first, because you have forgotten the sentence that made it good.

That sentence is the valuable part. "Review the diff" gets a generic review. "Review the uncommitted diff. List anything that changes behaviour without a test, any error that is swallowed, and any name that no longer matches what the code does. Don't fix anything yet" gets the review you wanted. Once you have found the wording that works, save it, so every later run starts from your best version instead of your most hurried one.

A saved prompt is the smallest unit of a pipeline. Everything later in this course, schedules, plugins and Claude Code over MCP, ends up firing prompts you wrote once and trust.

Make the changing part a variable

A prompt you save should be the part that stays the same. The part that changes from run to run belongs in a variable, so you never edit the saved text by hand and never drift from the version that worked.

Compare two ways to save a release-notes request:

  • Saved as "Write release notes for 2.4 from the commits since 2.3." You edit the numbers every time, and sooner or later you forget one.

  • Saved as "Write release notes for {{version}} from the commits since {{previous}}. Group them as Added, Changed and Fixed, and leave out internal refactors." You fill in two fields and the instructions never change.

TRMNLY also fills some variables for you from the focused pane, such as {{branch}}, {{selection}} and {{cwd}}. Those are how a prompt picks up where you are. "Explain why this failed: {{selection}}" turns a terminal selection into a complete request.

A runbook is a loop with a stopping rule

A prompt is one request. A runbook is a sequence: several prompts in order, and optionally shell commands, waits, nested runbooks, repeats and loops. The point of a runbook isn't to save typing. It's to capture a loop that you know converges, with a condition that ends it.

The most useful runbook most projects have is some form of "make the tests pass":

  • Run the test command.

  • Ask the agent to fix the first failure it sees, and only that one.

  • Repeat until the agent says a marker phrase, such as ALL GREEN, or until a cap, say five rounds.

Each part of that matters. The command step keeps the agent honest: it fixes what actually failed, not what it guesses might fail. "Only the first failure" keeps each round small enough to review. The marker phrase gives the loop a clear way to finish, and the cap gives it a way to give up. A loop without a cap is how an agent spends an hour rewriting a test until it passes by accident.

Write the stop condition into the prompt itself: "When every test passes, say ALL GREEN and nothing else." The runbook's Loop until step watches for that phrase, so the agent's own words end the loop.

What belongs in a prompt and what in a runbook

Use a saved prompt when | Use a runbook when |

It's one request | It's several steps in a fixed order |

You read the answer and decide what's next | The next step doesn't depend on your judgement |

It changes with what's on screen | It has to run the same way every time |

If you find yourself sending three saved prompts one after another every time, that's a runbook.

Keep the good ones where your team can see them

A prompt that lives only in your app is a prompt your teammates and your other agents never get. Put the ones that encode project knowledge, such as how to review, how to release or how to write a migration, in a folder in the repository. They're reviewed like code, they change with the code, and a new checkout gets them for free.

Go further
  • Workflows and tab monitors — every step type and the runbook row's menu
  • Prompts — the TRMNLY prompt pack and the agent's prompt tools
  • Workflows — run logs, import and export, and trmnly://workflow/run/<id> links
  • Write a task brief — what makes a prompt worth saving in the first place
  • Schedules and unattended runs — fire these prompts on a timer

Keep going with Agentic pipelines

This is one of 6 lessons in the course. Enroll to get the rest of the course, with an AI tutor that knows the material, flashcards and a certificate when you finish.

Enroll for free

Next free lesson: Schedules and unattended runs

More free lessons from this course