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
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit 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
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
PhpStorm logo

PhpStorm

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

PhpStorm
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
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
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

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

Shift
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
Lucky Media logo

Lucky Media

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

Lucky Media
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
MongoDB logo

MongoDB

Enhance your PHP applications with the powerful integration of MongoDB and Laravel, empowering developers to build applications with ease and efficiency. Support transactional, search, analytics and mobile use cases while using the familiar Eloquent APIs. Discover how MongoDB's flexible, modern database can transform your Laravel applications.

MongoDB

The latest

View all →
Drop in comments for Filament with Commentions image

Drop in comments for Filament with Commentions

Read article
Laravel Starter Kits Now Include Toast Notifications image

Laravel Starter Kits Now Include Toast Notifications

Read article
Ship AI with Laravel: Stop Your AI Agent from Guessing image

Ship AI with Laravel: Stop Your AI Agent from Guessing

Read article
Making Laravel MongoDB Operations Idempotent: Safe Retries for Financial Transactions image

Making Laravel MongoDB Operations Idempotent: Safe Retries for Financial Transactions

Read article
FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0 image

FormRequest Strict Mode and Queue Job Inspection in Laravel 13.4.0

Read article
Pretty PHP Info: A Modern Replacement for `phpinfo()` image

Pretty PHP Info: A Modern Replacement for `phpinfo()`

Read article