Skip to main content
Handbook/Amplify/Page 51 · Prompt Files

Managed Like Code, Stored Like Docs

Share

Share this page

Pass it to someone who needs it.

Star on GitHub

Key takeaway: Keep prompts in files, never in code

You are calling a model now, and somewhere in that code is a long string of instructions. It will be the most edited thing in your product and the least reviewed, and right now it is buried in a function where nobody can see it change. This chapter pulls it out.

6.2.1A prompt is content, not code

A prompt buried in a source file is invisible. You cannot skim it, your agent edits it without you noticing, and a change to two words of instruction looks exactly like a change to the code around it.

So keep it out. Prompts live in their own files, in plain text or markdown. The code loads them by name:

prompts/ support-reply/ system.md the role and the hard rules tone.md how it should sound examples.md two or three worked examples

Now the instruction is readable by you, editable without touching code, and every change to it shows up as a change to a document rather than a change to a program.

6.2.2Build it from pieces, not one wall

One enormous prompt is a single blast radius. Ask your agent to soften the tone and it rewrites the whole thing, and the safety rule you spent an afternoon on quietly disappears in the middle.

Split it. The role and the non-negotiable rules in one file, the tone in another, the examples in a third, and the code assembles them at call time. Now an edit to tone touches the tone file and nothing else, and you can see that at a glance.

The shared pieces follow the same habit as your settings: one copy, loaded by everything that needs it, never pasted twice.

6.2.3Version them like anything else you ship

A prompt change is a product change. Yesterday's answers came from yesterday's instructions, and if you cannot say which version produced a result, you cannot tell a model problem from a prompt problem.

Give each prompt a version and stamp it on the calls it makes:

# prompts/support-reply/system.md version: 4 updated: 2026-07-30 change: refuse refund promises, escalate instead

Your repo already keeps the full history, so version four is one command away from version three. That matters most on the day quality drops and nobody remembers touching anything.

6.2.4Treat an edit like a deploy, because it is

A two-word prompt edit ships with none of the protection a code change gets. Nothing type-checks it, nothing compiles it, and it looks completely harmless in a diff.

It is not. Changing "be concise" to "be brief" has flipped output quality in production systems. So a prompt change goes through the same gate as any other. You review it, then run it against the set of examples you use to judge model quality before it reaches users.

Watch out: never let an agent edit a prompt as a side effect of some other task. Prompt files are content it will happily tidy. Make prompt edits their own change, always.

6.2.5Pull your prompts out of the code

Ready prompt
Act as a senior engineer reorganizing the prompts in my product. Find every prompt string currently living in my source code and list them first, before changing anything. Move each into its own folder under a prompts directory, split into separate files: the role and hard rules, the tone, and the examples. The code loads and assembles them by name. Do not reword a single instruction while moving it; this change must be behaviour-neutral and I want to diff it. Give each prompt a version number and a one-line note saying what last changed, and stamp that version onto the calls it produces so I can trace an answer back to the instructions that made it. Finally, add one command that lists every prompt, its version, and where in the code it is used. If you need the full reasoning behind this step, read https://zalt.me/guides/vibe-coding/amplify/managing-prompts My product, and where its model calls live:

Do this now: paste the prompt and get every instruction string out of your code and into a file you can actually read.

Mahmoud Zalt

Mahmoud Zalt

Software engineer, 16+ yrs · built Sistava.com in 3 months, idea to production, using these methods

Resources
Star on GitHubContribute
Donate

Support my work

A small tip keeps the free work coming.

© 2026 Mahmoud Zalt. Free to read, not to republish.
Copyright & license