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

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

Visit Laravel Cloud
Lucky Media logo

Lucky Media

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

Lucky Media
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
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
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
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Tinkerwell logo

Tinkerwell

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

Tinkerwell
PhpStorm logo

PhpStorm

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

PhpStorm
Shift logo

Shift

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

Shift
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises

The latest

View all →
Clonio CLI: Clone Production Databases With Anonymized Data image

Clonio CLI: Clone Production Databases With Anonymized Data

Read article
Ship AI with Laravel: Test Your AI System with Zero API Calls image

Ship AI with Laravel: Test Your AI System with Zero API Calls

Read article
Laravel WhatsApp: Two Backends Behind One Facade image

Laravel WhatsApp: Two Backends Behind One Facade

Read article
Turn PHP Attributes Into Docs With Signal image

Turn PHP Attributes Into Docs With Signal

Read article
USAIGE: Track Token Usage and Costs for Laravel AI SDK Requests image

USAIGE: Track Token Usage and Costs for Laravel AI SDK Requests

Read article
Help make Filament faster! image

Help make Filament faster!

Read article