Documentation Index
Fetch the complete documentation index at: https://vu-ddaf4ff3.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Prompt Deck provides a clean, expressive API for loading, rendering, and managing versioned AI prompts in your Laravel application. Prompts are stored as plain files on disk and organised by name, version, and role. They are accessed through thePromptDeck facade, which feels like any other first-party Laravel service.
A prompt can contain multiple roles (system, user, assistant, developer, tool, or any custom role you define). Each role’s content supports {{ $variable }} interpolation, and the entire prompt can be converted into a messages array ready to send to OpenAI, Anthropic, or any chat-completion API.
Retrieving prompts
The PromptDeck facade
ThePromptDeck facade is the primary entry point for loading prompts. It delegates to the PromptManager singleton registered by the service provider:
get method returns a PromptTemplate instance. If no version is specified, the active version is resolved automatically.
Dependency injection
You can also inject thePromptManager directly via Laravel’s service container:
PromptManager is registered as a singleton, so the same instance is reused throughout the request lifecycle.
Active version
Use theactive method to explicitly load the active version:
get() without a version number.
Specific version
Pass a version number as the second argument toget to load a specific version, regardless of which version is currently active:
InvalidVersionException is thrown.
Rendering roles
Once you have aPromptTemplate instance, you can render any role’s content with variable interpolation.
Dynamic role methods
The most expressive way to render a role is to call it as a method directly on the prompt instance. This uses PHP’s__call magic method and works for any role — not just system and user:
The role method
If the role name is dynamic or stored in a variable, use the explicit role method:
Raw content
To retrieve a role’s content without variable interpolation, use theraw method:
Inspecting prompts
Available roles
Theroles method returns an array of all role names defined in the prompt:
.md) becomes a role — the filename (without extension) is the role name.
Checking for a role
Use thehas method to check whether a specific role exists before attempting to render it:
Metadata
Each prompt version can carry metadata (stored inmetadata.json at the version level). Access it via the metadata method:
metadata.json exists in the version directory, an empty array is returned.
Name and version
Building messages for AI APIs
All roles
ThetoMessages method builds a messages array compatible with OpenAI, Anthropic, and other chat-completion APIs. It renders every role with the given variables and returns them in definition order:
Filtering roles
Pass a second argument to limit which roles are included and in what order:Variable interpolation
Syntax
Prompt Deck supports two placeholder syntaxes within prompt files:| Syntax | Example |
|---|---|
| Spaced (recommended) | {{ $tone }} |
| Compact | {{tone}} |
Supported value types
Values are cast to strings via PHP’s(string) cast, so you can pass any scalar or stringable value:
Missing variables
Placeholders that are not matched by the provided variables are left intact. This lets you render in stages or identify unfilled variables:Versioning
Directory structure
Prompts are versioned using directory-based versioning. Each version lives in its own sub-directory (v1/, v2/, etc.) inside the prompt folder:
- Any number of role files (e.g.
system.md,user.md,assistant.md) - An optional
metadata.jsonfor version-level metadata
Listing versions
Retrieve all versions for a prompt programmatically:metadata.json.
Or use the Artisan command:
Activating a version
Set a specific version as the active version:prompt_versions table — setting is_active = false on all versions of that prompt, then is_active = true on the specified version.
When tracking is disabled, it writes the active_version key to the prompt’s root metadata.json file.
Or use the Artisan command:
Version resolution order
When you callPromptDeck::get('name') without a version, the active version is resolved in this priority order:
- Database — If tracking is enabled, looks for a version marked
is_active = truein theprompt_versionstable for that prompt name. - metadata.json — Reads the
active_versionkey from the prompt’s rootmetadata.jsonfile. - Highest version — Falls back to the highest version number found on disk (e.g. if
v1/andv3/exist, version 3 is used).
InvalidVersionException is thrown.
Caching
When caching is enabled, loaded prompts are stored in your configured cache store to avoid repeated filesystem reads:{prefix}{name}.v{version}. Prompts are cached on first load and served from cache on subsequent requests until the TTL expires.
Caching is automatically disabled when APP_DEBUG=true to ensure file changes are picked up immediately during development.
See Configuration — Cache for the full reference.
Execution tracking
When database tracking is enabled, you can log prompt executions for performance monitoring, A/B testing, and audit trails:prompt_executions table. If tracking is disabled, the track method is a safe no-op.
See Tracking & Performance for comprehensive documentation on the tracking system, database schema, and Eloquent models.
Serialisation
ThePromptTemplate class implements Laravel’s Arrayable contract. Call toArray() to get a serialisable representation: