Prompt management
Contents
Prompt management lets you create and update LLM prompts directly in PostHog. When you use prompts through the SDK, they're fetched at runtime with caching and fallback support—so you can iterate on prompts without deploying code.
Why use prompt management?
- Update prompts without code deploys – Change prompts instantly from the PostHog UI
- Non-engineers can iterate – Product and content teams can tweak prompts without touching code
- Track prompt usage – Link prompts to generations to see which prompts drive which outputs
- Versioning – Every change creates an immutable version you can view, compare, or restore
- Labels – Point a label like
productionat a version and fetch by label, so saving a prompt and releasing it are separate steps - Configuration – Store model parameters or any settings next to the prompt and change them without a deploy
- A/B testing – Compare prompt versions on cost, latency, and eval pass rate using PostHog Experiments
Creating prompts
- Navigate to Prompt management > Prompts
- Click New prompt
- Enter a name for your prompt
- Write your prompt content, using
{{variables}}for dynamic values - Click Create prompt
This creates version 1 of your prompt. Each subsequent edit creates a new immutable version.
Markdown preview
When viewing a prompt, markdown rendering is enabled by default, formatting your prompt text with headings, lists, bold, and other markdown elements. Click the markdown icon next to the Prompt label to toggle it off and view plain text. PostHog remembers your choice and applies it to every prompt you open. When editing a prompt, the view switches to plain text automatically.
Prompt naming rules
- Names are immutable after creation (cannot be changed)
- Only letters, numbers, hyphens, and underscores allowed (
^[a-zA-Z0-9_-]+$) - Names must be unique within your project
Managing prompts via MCP
You can also manage prompts through the PostHog MCP server using AI agents like Claude Code, Cursor, or any MCP-connected tool.
The MCP server provides seven prompt management tools:
| Tool | Description |
|---|---|
llma-prompt-list | List all team prompts with optional name filtering |
llma-prompt-get | Get a prompt by name, including full content, optionally by version or label |
llma-prompt-create | Create a new prompt with a unique name and content |
llma-prompt-update | Publish a new version of a prompt by name, optionally with a note describing the change |
llma-prompt-duplicate | Copy a prompt's latest version to a new prompt under a new name, for forking or renaming |
llma-prompt-label-set | Point a label at a version, creating the label or moving it from another version |
llma-prompt-label-delete | Remove a label from a prompt |
This enables teams to manage prompts programmatically from agent workflows without using the web UI.
Template variables
Use double curly braces to define variables in your prompts:
Variable names can include letters, numbers, underscores, hyphens, and dots.
Versioning
Every prompt change creates a new immutable version. Previous versions are preserved and accessible.
How versioning works
- The first save creates version 1
- Each subsequent publish increments the version number
- Previous versions are never modified
- By default, the SDK fetches the latest version
Publish a new version
- Open a prompt and click New version
- Make your changes
- Click Publish — the button shows the number the new version will get, for example Publish v4
- Review the diff of your changes, optionally add a note describing what changed, and confirm
The note appears alongside the version in the Version history sidebar, so you can scan past changes without opening diffs. It can also be set programmatically via the version_description field on the publish API and the MCP llma-prompt-update tool.
If someone else published a new version while you were editing, publishing fails with a warning. Your edits are preserved in the editor — review them against the new latest version and publish again.
Restore a previous version
- Open a prompt and select a version from the Version history sidebar
- Click New version — the editor is prefilled with that version's content
- Edit the prompt content if needed
- Click Publish and confirm in the review dialog
This publishes the old content as a new version. The original version remains unchanged.
Compare versions
Compare the content of two prompt versions side-by-side to see what changed. This is available for prompts with two or more versions.
To compare versions:
- Open a prompt and click Compare versions next to the Prompt label
- The diff view shows the current version against the previous version by default
- Use the version dropdown to change the comparison target
You can also click the compare icon on any version in the Version history sidebar to compare it with the currently selected version. The comparison target is highlighted with a Comparing tag in the sidebar.
Unchanged regions are automatically collapsed in the diff view. Click Compare versions again to exit the diff view.
Archive a prompt
Click Archive to remove a prompt from active use. This archives all versions of the prompt. Any code fetching the prompt by name stops resolving it. Archiving also removes the prompt's labels.
Restore an archived prompt
Archived prompts stay in your project. To see them, turn on Show archived on the prompts list. Each archived prompt appears once, at its most recent version.
Click Restore to bring a prompt back. All of its versions come back with the same numbers, so code that fetches by name or by version works again. Labels are not restored: set them again on the versions you want to release.
Restoring fails in these cases:
- An active prompt with the same name exists. Names are immutable, so the archived prompt can't be restored while the new one exists. Archiving the new one does not help: both would then share version numbers and neither could be restored. Keep the active prompt, or create a new prompt with the archived content.
- The name was archived more than once and the archived versions overlap. Create a new prompt instead.
- The latest archived version references a prompt that is still archived, or references a label that no longer exists. Restore the referenced prompt first, and if the reference follows a label, set that label again before restoring the referencing prompt.
With the API, list archived prompts with ?archived=true and restore one with a POST request:
Labels
A label is a movable pointer to exactly one version of a prompt. Fetching by a label like production returns whatever version the label points to right now.
Labels separate saving a prompt from releasing it. Without labels, code either fetches the latest version (so every save immediately changes what your app uses) or pins a version number (so every release needs a code change). With a label, you edit and publish versions freely, then move the label when a version is ready:
- Release a version by pointing
productionat it - Roll back by pointing
productionat an earlier version - Your code just fetches by label and never changes
One version can hold several labels (for example production and staging on the same version), but a label always points to exactly one version. Setting a label that already exists on another version moves it there.
Label naming rules
- Lowercase letters, numbers, dots, hyphens, and underscores; must start and end with a letter or number
- Maximum 128 characters
latestis reserved (it always means the newest version)- Numbers-only names are not allowed, to avoid confusion with version numbers
- Up to 50 labels per prompt
Managing labels
In the app
Each version in the version history shows the labels pointing at it.


To set a label:
- Open the prompt and find the version in the version history
- Click Add label on that version
- Pick an existing label, or type a name to create a new one
If the label is already on another version, PostHog asks you to confirm the move:


To remove a label, click the











