Why Git for Prompts: One Line Change Can Double Quality or Break Everything
Prompts are the easiest part of an AI app to break: one changed word alters the output. Without version control you cannot say which version was better, who changed it, or how to roll back. Here are the directory layout, four commands, four rules and an eval set.
📜 Table of Contents
📖 Keep reading
Why Prompts Need Git: One Changed Line Decides Output Quality
Prompts share one property with code: a single line can change everything. The difference is that broken code throws an error, while a broken prompt just feels worse. By the time you notice, you cannot recall what the good version looked like.
One prompt, one file
Keep prompts under a prompts/ directory, one file each, with {{var}} placeholders rendered by code. A registry.json records the production version, owner and last eval pass rate. Put the version in the filename or a git tag - pick one, not both. Prompts buried in backend strings hide their changes in a 500-line diff.
Four commands
git log -p shows what changed in each revision, git diff makes reviews meaningful, git tag anchors production releases, and git checkout rolls back in a minute. git bisect can locate a prompt-caused regression if commits are granular enough.
Four rules
Commit messages must state what changed, why, and the eval result. Tag every production version. Attach eval results to any change. Keep prompts in the same repo and the same PR as code, or the two drift until production no longer matches the repository.
Eval set
Twenty to fifty real inputs with expected outputs in jsonl. Run it on every change and record the pass rate in the commit. Watch the overall rate and whether any critical case regressed - one safety case failing outweighs ten formatting improvements. Automate what you can: exact match, JSON field checks, regex.
Platform or git
A single developer with fewer than twenty prompts needs only git. Teams where non-engineers edit prompts, or that need A/B rollout and audit trails, benefit from Langfuse or PromptLayer. Many teams keep source in git and publish through a platform.
Anti-patterns
Names like final_v2_really_final, keeping only the latest version, shipping without evals, business logic written as prose, and language variants that drift apart.
FAQ
Keep source in git and load at runtime; a database should only store which version is live. Use semantic versions - structure changes bump major, wording changes bump minor. Store system.zh.md and system.en.md side by side and commit them together. Log the prompt version on every request so bad output can be traced.
Platform features and pricing vary; check each vendor's site.
Written by our editorial team; tools listed here are tested or verified against public sources. Links point to official sites or GitHub repos for reference only — no paid placements.