$git clone https://github.com/promptphp/deckDeck, formerly Prompt Deck, provides AI prompt management for Laravel and PHP.
| 1 | <p align="center"><img src="/docs/logo/banner.svg" alt="Prompt Deck Logo"></p> |
| 2 | |
| 3 | <p align="center"> |
| 4 | <a href="https://packagist.org/packages/promptphp/deck"><img src="https://img.shields.io/packagist/v/promptphp/deck?style=flat-square" alt="Latest Version on Packagist"></a> |
| 5 | <a href="https://packagist.org/packages/promptphp/deck"><img src="https://img.shields.io/packagist/php-v/promptphp/deck?style=flat-square" alt="PHP from Packagist"></a> |
| 6 | <a href="https://github.com/promptphp/deck/blob/master/LICENSE"><img src="https://img.shields.io/github/license/promptphp/deck?style=flat-square" alt="GitHub license"></a> |
| 7 | <a href="https://packagist.org/packages/promptphp/deck"><img src="https://img.shields.io/packagist/dt/veeqtoh/prompt-deck?style=flat-square" alt="Total Downloads on Packagist"></a> |
| 8 | <a href="https://laravel-news.com/prompt-deck-manage-ai-prompts-as-versioned-files-in-laravel/"><img src="https://img.shields.io/badge/Featured%20in%20Laravel%20News-F9322C?style=flat-square&logo=laravel&logoColor=white" alt="Featured in Laravel News"></a> |
| 9 | </p> |
| 10 | |
| 11 | ## Introduction |
| 12 | |
| 13 | Deck, formerly Prompt Deck, provides AI prompt management for Laravel and PHP. |
| 14 | |
| 15 | Organise your AI agent instructions as versioned files, compare prompt performance, and activate the right version across your app with variable interpolation, tracking, A/B testing, and Laravel AI SDK integration. |
| 16 | |
| 17 | > [!IMPORTANT] |
| 18 | > Prompt Deck is now **Deck by PromptPHP**. |
| 19 | > |
| 20 | > From `v0.4.0`, the package moved from `veeqtoh/prompt-deck` to `promptphp/deck`, and the namespace changed from `Veeqtoh\PromptDeck` to `PromptPHP\Deck`. |
| 21 | > |
| 22 | > Upgrading from `v0.3.x`? See the [upgrade guide](UPGRADE.md). |
| 23 | |
| 24 | ## Quick Start |
| 25 | |
| 26 | ### Installation |
| 27 | |
| 28 | ```bash |
| 29 | composer require promptphp/deck |
| 30 | ``` |
| 31 | |
| 32 | Publish the config and migrations |
| 33 | |
| 34 | ```bash |
| 35 | php artisan vendor:publish --provider="PromptPHP\Deck\Providers\DeckServiceProvider" |
| 36 | |
| 37 | # Run migrations. |
| 38 | php artisan migrate |
| 39 | ``` |
| 40 | |
| 41 | ### Creating a Prompt |
| 42 | |
| 43 | Use the Artisan command to create a versioned prompt |
| 44 | |
| 45 | ```bash |
| 46 | php artisan make:prompt order-summary |
| 47 | ``` |
| 48 | |
| 49 | This creates the following structure |
| 50 | |
| 51 | ```txt |
| 52 | resources/prompts/order-summary/ |
| 53 | ├── metadata.json |
| 54 | ├── v1/ |
| 55 | │ ├── system.md |
| 56 | │ └── user.md |
| 57 | └── v2/ |
| 58 | ├── system.md |
| 59 | └── user.md |
| 60 | ``` |
| 61 | |
| 62 | Edit `resources/prompts/order-summary/v1/system.md` with your prompt content. Use `{{ $variable }}` syntax for dynamic values: |
| 63 | |
| 64 | ```markdown |
| 65 | You are a {{ $tone }} customer service agent. |
| 66 | Summarise the following order for the customer: {{ $order }}. |
| 67 | ``` |
| 68 | |
| 69 | ### Using a Prompt |
| 70 | |
| 71 | Load and render prompts with the `Deck` facade |
| 72 | |
| 73 | ```php |
| 74 | use PromptPHP\Deck\Facades\Deck; |
| 75 | |
| 76 | // Load the active version of a prompt. |
| 77 | $prompt = Deck::get('order-summary'); |
| 78 | |
| 79 | // Render a role with variables. |
| 80 | $prompt->system(['tone' => 'friendly', 'order' => $orderDetails]); |
| 81 | // "You are a friendly customer service agent. Summarise the following order..." |
| 82 | |
| 83 | // Build a messages array ready for any chat-completion API. |
| 84 | $messages = $prompt->toMessages(['tone' => 'friendly', 'order' => $orderDetails]); |
| 85 | // [['role' => 'system', 'content' => '...']] |
| 86 | ``` |
| 87 | |
| 88 | ### Versioning |
| 89 | |
| 90 | Create a new version of an existing prompt |
| 91 | |
| 92 | ```bash |
| 93 | php artisan make:prompt order-summary |
| 94 | # Automatically creates v2, v3, etc. |
| 95 | ``` |
| 96 | |
| 97 | Activate a specific version |
| 98 | |
| 99 | ```bash |
| 100 | php artisan prompt:activate order-summary v2 |
| 101 | |
| 102 | # or |
| 103 | |
| 104 | php artisan prompt:activate order-summary 2 |
| 105 | ``` |
| 106 | |
| 107 | Or load a specific version programmatically |
| 108 | |
| 109 | ```php |
| 110 | $prompt = Deck::get('order-summary', 'v2'); |
| 111 | ``` |
| 112 | |
| 113 | ### Laravel AI SDK Integration |
| 114 | |
| 115 | If you use the [Laravel AI SDK](https://laravel.com/docs/ai-sdk), add the `HasPromptTemplate` trait to your agents. This way, you do not need to define the `instructions()` method as it is provided automatically. |
| 116 | |
| 117 | ```php |
| 118 | use PromptPHP\Deck\Concerns\HasPromptTemplate; |
| 119 | |
| 120 | class OrderAgent extends Agent |
| 121 | { |
| 122 | use HasPromptTemplate; |
| 123 | |
| 124 | // instructions() and promptMessages() are provided automatically. |
| 125 | } |
| 126 | ``` |
| 127 | |
| 128 | Running `make:agent` will also auto-scaffold a matching prompt directory. |
| 129 | |
| 130 | For the complete guide, see the [full documentation |