The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

Prompt Deck: Manage AI Prompts as Versioned Files in Laravel

Last updated on by

Prompt Deck: Manage AI Prompts as Versioned Files in Laravel image

Prompt Deck by Victor Ukam gives Laravel applications a structured way to manage AI prompts — storing them as versioned markdown files on disk rather than embedding strings directly in application code.

The package requires PHP 8.2+ and Laravel 11+.

Key features:

  • Disk-based prompt files with directory-based versioning
  • Variable interpolation using {{ $variable }} syntax in markdown files
  • Artisan commands for creating, listing, testing, and activating prompt versions
  • A/B testing support to compare prompt versions by token usage, latency, and cost
  • Integration with laravel/ai via a HasPromptTemplate trait

Creating and Using Prompts

After installing the package, you can generate a new prompt with the provided make:prompt command:

php artisan make:prompt order-summary

This scaffolds a versioned directory structure under resources/prompts/ that might look like this given the above command:

resources/prompts/
└── order-summary/
├── v1/
│ └── system.md
└── metadata.json

You can then edit the system.md prompt file with {{ $variable }} placeholders for dynamic values:

You are a {{ $tone }} customer service agent.
Summarise the following order: {{ $order }}.

Here's an example of how you can load/render the prompt:

use Veeqtoh\PromptDeck\Facades\PromptDeck;
 
$prompt = PromptDeck::get('order-summary');
$messages = $prompt->toMessages(['tone' => 'friendly', 'order' => $orderDetails]);

The toMessages() method returns a message array compatible with OpenAI, Anthropic, and similar API formats.

To load a specific version:

$prompt = PromptDeck::get('order-summary', 'v2');

You can also activate a version via Artisan without touching code:

php artisan prompt:activate order-summary v2

Laravel AI SDK Integration

For applications using laravel/ai, the HasPromptTemplate trait automatically provides instructions() and promptMessages() on your agent class:

use Veeqtoh\PromptDeck\Concerns\HasPromptTemplate;
 
class OrderAgent extends Agent
{
use HasPromptTemplate;
}

When PROMPTDECK_SCAFFOLD_ON_MAKE_AGENT=true is set in .env, running php artisan make:agent will also scaffold a matching prompt directory automatically.

You can find Prompt Deck on GitHub and read the full documentation at the Prompt Deck docs.

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Filed in:
Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
SerpApi

The Web Search API for Your LLM and AI Applications

Visit SerpApi
SerpApi logo

SerpApi

Access real-time search engine results through a simple API—no more scraping headaches! Use it for AI applications, SEO tools, product research, travel information, and more

SerpApi
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Laravel Cloud logo

Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Laravel Cloud
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell

The latest

View all →
Manage Laravel Cloud Deployments Inside PhpStorm image

Manage Laravel Cloud Deployments Inside PhpStorm

Read article
Piper: Laravel-Style Array and String Helpers for PHP's Pipe Operator image

Piper: Laravel-Style Array and String Helpers for PHP's Pipe Operator

Read article
Storage Cache Store in Laravel 13.10.0 image

Storage Cache Store in Laravel 13.10.0

Read article
Laravel MongoDB Full-Text Search tutorial: The Art of the Relevancy image

Laravel MongoDB Full-Text Search tutorial: The Art of the Relevancy

Read article
Drag-and-Drop Sorting for Eloquent Models with Reorderable for Laravel image

Drag-and-Drop Sorting for Eloquent Models with Reorderable for Laravel

Read article
Ship AI with Laravel: Real-Time Streaming Chat UI with Livewire image

Ship AI with Laravel: Real-Time Streaming Chat UI with Livewire

Read article