Sub topic 12
Prompt Registries and Tooling Options
This chapter assumes you have read the earlier chapters. You should know how to render templates with validated variables and store them as files. You should also know how to version them, pin a version, run a regression suite, and log the version with each call. Here you will decide when files in Git are enough and when a prompt registry is worth adding.
What a registry is
A prompt registry is a service or library that stores prompt templates, their versions, and their metadata in one place. Applications fetch prompts from it by name and version or alias. You have already built a small registry by hand. The prompts/<name>/<version>.yaml layout, the load_prompt function, and the PINNED mapping together do the same three jobs a registry does:
- Store each version as an immutable record.
- Resolve a name plus a version (or alias) to one template.
- Keep metadata such as the changelog and the declared variables next to the template.
A hosted or self-run registry adds features on top of those jobs:
- A web interface so people who do not use Git can read and edit prompts.
- Access control and audit history of who changed what.
- Aliases such as
productionandstagingthat can be moved without a code deploy. - Built-in evaluation runs and comparison of outputs between versions.
- Usage data linked to each version, such as cost, latency, and error rate.
The file-based baseline
Before adopting a tool, look at what your file layout already gives you.
| Capability | Files in Git | Typical registry |
|---|---|---|
| Immutable versions | Yes, by convention and review | Yes, enforced by the service |
| Change history and review | Pull requests | Built-in history, sometimes approvals |
| Rollback | Change `PINNED` and deploy | Move an alias, often with no deploy |
| Editing by non-developers | Awkward | Usually a web editor |
| Offline and reproducible builds | Yes | Depends on caching |
| Extra infrastructure | None | A service, or a vendor dependency |
| Usage metrics per version | You build them (see the logging chapter) | Often included |
Files in Git are a sound choice for a small team, a few dozen prompts, and developers who own the prompts. The prompts ship with the code, so a given commit always means one exact combination of code and prompts. That property is hard to give up, and it is the main thing a registry can weaken.
When a registry starts to pay off
Consider a registry when one or more of these conditions hold:
- Prompt changes need a different release cadence than code. If a content specialist must fix a prompt within the hour and your code deploy takes a day, the prompt needs its own release path.
- Non-developers edit prompts. Product managers and domain experts can work in a web editor. Asking them to open pull requests in a YAML file often means they will not iterate.
- Many services share prompts. If five services copy the same
summarizefile, they drift apart. A central store gives them one source. - You need per-version analytics. Comparing cost and quality across versions is easier when the tool records them for you.
- Compliance requires an audit trail. Some environments need to prove who approved which prompt and when.
If none of these apply, a registry mostly adds a network dependency and another system to operate.
Tooling options
The market changes quickly, so treat the categories below as a guide to what to look for, and check each product's current documentation before you commit. The categories are more stable than the product names.
Option 1: Files plus a thin loader
This is what you built in this tutorial. You can strengthen it without buying anything:
- Validate each YAML file against a schema in continuous integration, so a missing
variablesfield fails the build. - Enforce immutability: a check that fails if a pull request edits an existing version file instead of adding a new one.
- Package the prompts directory with the application image.
The immutability check is small enough to show in full. It compares the current branch with main using Git and fails if any existing version file changed.
import subprocess
import sys
def changed_existing_prompt_files(base="origin/main"):
# --diff-filter=M lists only files that were Modified, not Added.
result = subprocess.run(
["git", "diff", "--name-only", "--diff-filter=M", base, "--", "prompts/"],
capture_output=True,
text=True,
check=True,
)
return [line for line in result.stdout.splitlines() if line.endswith(".yaml")]
if __name__ == "__main__":
modified = changed_existing_prompt_files()
if modified:
print("Published prompt versions must not be edited. Add a new version instead:")
for path in modified:
print(f" {path}")
sys.exit(1)Run it as a step in continuous integration. A new version arrives as a new file, so --diff-filter=M stays empty for a correct change. One limit: this rule also blocks fixing a typo in a version that was never released. If that is too strict, allow edits to versions that are not in PINNED or any alias.
Option 2: A shared Git repository of prompts
Move the prompts/ directory into its own repository, and have services install it as a dependency at a pinned tag. You keep Git review and immutability, and several services share one source. The cost is a two-step change: update the prompt repository, then bump the tag in each consuming service.
Option 3: Open-source or self-hosted registries
Some projects provide a prompt store, a web interface, and an API, and you run them yourself. You control the data, which matters when prompts contain business logic you do not want to send to a vendor. You pay with operations work: upgrades, backups, and availability.
Option 4: Hosted prompt management services
Hosted products bundle a registry with tracing and evaluation. Several large model providers and observability vendors offer one. They are quick to adopt and often link each logged call to the prompt version automatically. The trade-offs are vendor lock-in, data leaving your environment, and a runtime dependency on someone else's uptime.
Option 5: Framework-provided hubs
Some LLM application frameworks include a hub where you can push and pull prompt objects. These are convenient inside that framework. Check how the hub handles version identifiers and whether it supports the immutable, pinned workflow described in earlier chapters, because not every hub does.
Questions to ask before choosing a tool
The following checks apply to any option. They map directly to the practices in this tutorial.
- Are versions immutable? If a published version can be edited in place, pinning gives you no guarantee.
- Can you pin by exact version? An alias such as
latestis convenient, but production needs an exact identifier. - Where are aliases resolved? Resolution at deploy time is predictable. Resolution at every request means a moved alias changes behavior in running services immediately.
- Does the template syntax match yours? If the tool uses a different placeholder syntax from
string.Template, you must convert templates and keep your validation logic working. - Can you export everything? You should be able to leave. Check for a plain export of templates and metadata.
- What happens when the registry is down? Decide on a fallback before an outage, not during one.
- Does it record the version on each call? If not, your own logging from the previous chapter still has to carry it.
Failure modes with remote registries
Fetching prompts over the network introduces problems that files do not have.
- Availability. If every request fetches its prompt from a remote service, an outage there takes your feature down. Cache prompts in memory and on disk, and refuse to start with an empty cache only if that is the safer choice.
- Silent drift. If production resolves the alias
productionat runtime, a person moving that alias changes behavior without any code change, test run, or deploy record. Log the resolved exact version on every call so you can see it afterward. - Latency. A fetch on the request path adds a round trip. Fetch at startup or on a timer instead.
- Skipped tests. A web editor makes it easy to save an edit that never ran through your regression suite. Gate alias changes behind an automated run.
The loader below shows a safe pattern. It fetches by exact version, caches the result on disk, and falls back to the cached copy if the registry is unreachable. The fetch_remote function is a placeholder for your registry's client, so you supply it.
import json
from pathlib import Path
CACHE_DIR = Path(".prompt_cache")
def load_with_cache(name, version, fetch_remote):
"""Return the prompt dict for an exact version.
fetch_remote(name, version) must return a dict or raise an exception.
"""
CACHE_DIR.mkdir(exist_ok=True)
cache_file = CACHE_DIR / f"{name}-{version}.json"
try:
prompt = fetch_remote(name, version)
except Exception:
if cache_file.exists():
return json.loads(cache_file.read_text())
raise
cache_file.write_text(json.dumps(prompt))
return promptBecause the cache key includes the exact version, a cached copy is never stale. A version is immutable, so the same key always means the same text. That is one more reason to insist on immutability in whatever tool you pick.
How the pieces fit together
The diagram shows a setup that keeps Git as the source of truth while a registry serves the application. The release step is where the regression suite and review from earlier chapters gate the alias.
A decision path
Work through these questions in order and stop at the first one you answer yes.
- Do only developers edit prompts, and do prompts change at the same pace as code? Use files plus the thin loader (Option 1), with the CI checks above.
- Do several services share prompts, but developers still own them? Use a shared prompt repository (Option 2).
- Must non-developers edit prompts, or must prompts release on their own schedule, and data must stay in your environment? Use a self-hosted registry (Option 3).
- Do you want editing, tracing, and evaluation together with the least setup, and can you accept a vendor dependency? Use a hosted service (Option 4).
You can also move through these in order as the project grows. Because your prompts already have names, versions, declared variables, and change notes in plain files, migrating to a registry later is mostly an import job. That is a benefit of the file-based habits from earlier chapters.
Common mistakes
- Adopting a registry first. Teams often install a tool before they have a versioning convention. The tool then stores unlabeled, untested edits. Establish the scheme, metadata, and tests first.
- Treating the alias as the version. Logs that say
productiontell you nothing a week later. Always record the resolved exact version. - Two sources of truth. Keeping prompts both in Git and in a web editor, with edits flowing both ways, produces conflicts. Pick one as authoritative and sync in one direction.
- No exit plan. If you cannot export templates, metadata, and history, the tool owns your prompts.
Summary of decisions
| Situation | Reasonable choice |
|---|---|
| Small team, developers own prompts | Files in Git with CI checks |
| Several services share prompts | Shared prompt repository at a pinned tag |
| Non-developers edit, data must stay in-house | Self-hosted registry |
| Need tracing and evaluation quickly | Hosted prompt management service |
Exercise
Your team uses a hosted registry. Production code loads the prompt with the alias production. After a rollback, a service still returns output from the old prompt, and the logs only say prompt_version: production. Name two separate problems in this setup and one fix for each.
Show answer
First, the logs record the alias instead of the exact version, so you cannot tell which text produced an output. Fix: resolve the alias to an exact version at load time and log that version. Second, the service probably cached the prompt under the alias key, so it kept serving the old text after the alias moved. Fix: cache by exact version, which never goes stale because versions are immutable, and re-resolve the alias on a timer or at deploy time.
Exercise
A pull request edits prompts/summarize/1.2.0.yaml to fix wording, and the 1.2.0 version is already pinned in production. Which check from this chapter should fail, and what should the author do instead?
Show answer
The immutability check, which uses git diff --diff-filter=M on the prompts/ directory, should fail because an existing version file was modified. The author should add a new version file, such as 1.2.1.yaml, with a changelog entry, run the regression suite against it, and then update the pin or alias after review.