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

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
Tinkerwell

Enjoy coding and debugging in an editor designed for fast feedback and quick iterations. It's like a shell for your application – but with multi-line editing, code completion, and more.

Visit Tinkerwell
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

The latest

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

Prompt Deck: Manage AI Prompts as Versioned Files in Laravel

Read article
Laravel Prompts v0.3.15 Adds Streaming, Tasks, Autocomplete, and More image

Laravel Prompts v0.3.15 Adds Streaming, Tasks, Autocomplete, and More

Read article
Circuit Breaker for Laravel image

Circuit Breaker for Laravel

Read article
SlideWire: Build Presentations with Livewire and Blade image

SlideWire: Build Presentations with Livewire and Blade

Read article
Laravel 13 Released: PHP 8.3, Attributes, Laravel AI, and a Smoother Upgrade Path image

Laravel 13 Released: PHP 8.3, Attributes, Laravel AI, and a Smoother Upgrade Path

Read article
Lens for Laravel Brings WCAG Auditing to Your Local Dev Workflow image

Lens for Laravel Brings WCAG Auditing to Your Local Dev Workflow

Read article