lvlup-dev / laravel-agent-editable-prompts
Store agent prompts in the database, resolve concatenated text by agent slug, and ship optional Inertia + Vue CRUD pages.
Package info
github.com/lvlup-dev/laravel-agent-editable-prompts
Type:laravel-package
pkg:composer/lvlup-dev/laravel-agent-editable-prompts
Requires
- php: ^8.2
- illuminate/contracts: ^10.0|^11.0|^12.0|^13.0
- illuminate/database: ^10.0|^11.0|^12.0|^13.0
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/routing: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- inertiajs/inertia-laravel: ^1.0|^2.0|^3.0
Requires (Dev)
- orchestra/testbench: ^9.0|^10.0
- pestphp/pest: ^2.34|^3.0
- pestphp/pest-plugin-laravel: ^2.4|^3.0
README
Store LLM / agent prompts in the database, group them by agent_slug, order them with priority, and resolve them at runtime as ordered segments or a single concatenated string. Optionally register an Inertia + Vue CRUD so non-developers can edit prompts without deploys.
Requires inertiajs/inertia-laravel (and a Vue/React frontend) if you use the bundled admin UI.
Quick example
use LvlupDev\AgentEditablePrompts\Services\AgentPromptService; // Single string: all rows for this slug, sorted by priority, joined with the configured separator $instructions = app(AgentPromptService::class)->resolve('my-agent'); // Ordered Eloquent models (e.g. Blade::render per row in your app) $chunks = app(AgentPromptService::class)->segments('my-agent');
Installation
1. Composer
composer require lvlup-dev/laravel-agent-editable-prompts
Laravel auto-discovers AgentEditablePromptsServiceProvider (see composer.json → extra.laravel.providers).
2. Migrations
The package loads its migration automatically. Create the table:
php artisan migrate
Default table name: agent_editable_prompts. Override with AGENT_EDITABLE_PROMPTS_TABLE (see below) if needed.
3. Configuration (recommended)
Publish the config file so you can tune behaviour and .env overrides in one place:
php artisan vendor:publish --tag=agent-editable-prompts-config
This copies config/agent-editable-prompts.php into your application. Until you publish, merged defaults from the package still apply.
4. Inertia / Vue pages (if you use the bundled CRUD)
The HTTP controllers render Inertia pages under Vendor/AgentPrompts/*. Those components must exist in your app (Vite only bundles your resources/js tree).
Publish the starter pages:
php artisan vendor:publish --tag=agent-prompts-vue
Then adapt them to your layout (e.g. wrap with your admin shell), run your frontend build, and ensure Wayfinder or your route helpers know the package routes if you link from the sidebar.
If you do not want the package routes at all, set AGENT_EDITABLE_PROMPTS_REGISTER_ROUTES=false and build your own controllers/UI while still using AgentPrompt + AgentPromptService.
5. Environment variables
All keys are optional; defaults match config/agent-editable-prompts.php.
| Variable | Default (if unset) | Role |
|---|---|---|
AGENT_EDITABLE_PROMPTS_TABLE |
agent_editable_prompts |
Database table name. |
AGENT_EDITABLE_PROMPTS_SEPARATOR |
\n\n |
Separator used by AgentPromptService::resolve(). |
AGENT_EDITABLE_PROMPTS_PRIORITY_SORT |
asc |
asc or desc — order of priority when resolving. |
AGENT_EDITABLE_PROMPTS_REGISTER_ROUTES |
true |
Set to false to disable the Inertia CRUD routes entirely. |
AGENT_EDITABLE_PROMPTS_MIDDLEWARE |
web |
Comma-separated middleware list for the CRUD routes. Include web when using Inertia (session, cookies, CSRF). Example: web,auth or web,auth,admin. |
AGENT_EDITABLE_PROMPTS_ROUTE_PREFIX |
(empty) | URL prefix (no leading slash required; it is trimmed). Example: admin → /admin/agent-editable-prompts. |
AGENT_EDITABLE_PROMPTS_ROUTE_NAME_PREFIX |
(empty) | Prepended to route names. Example: admin. → admin.agent-editable-prompts.index. |
Important: routes registered by the package are not defined in your routes/web.php; they only receive the middleware you list in AGENT_EDITABLE_PROMPTS_MIDDLEWARE. For a typical Inertia app, use at least web,auth (and your admin gate if you have one).
Usage
Model
LvlupDev\AgentEditablePrompts\Models\AgentPrompt uses the configured table and fillable fields:
agent_slug— logical agent (e.g.support-bot,onboarding)name— human label in the UIcontent— prompt body (your app may treat it as Blade, Markdown, etc.)priority— integer; lower values sort first whenpriority_sort_directionisasc
Service
AgentPromptService is registered as a singleton:
$service = app(\LvlupDev\AgentEditablePrompts\Services\AgentPromptService::class); $service->segments('my-agent'); // Collection of AgentPrompt models $service->resolve('my-agent'); // string
HTTP routes (when enabled)
Resource basename: agent-editable-prompts.
Route parameter name: agent_prompt.
Default route names (no AGENT_EDITABLE_PROMPTS_ROUTE_NAME_PREFIX):
agent-editable-prompts.indexagent-editable-prompts.createagent-editable-prompts.storeagent-editable-prompts.editagent-editable-prompts.updateagent-editable-prompts.destroy
AgentPromptService::routeName('index') respects the configured name prefix.
Scope and alternatives
This package is intentionally focused: one table, slug + priority, optional generic CRUD. It does not ship authorization policies, prompt versioning, A/B testing, or provider-specific prompt formats.
For richer CMS-style content or team workflows, consider integrating a headless CMS, a dedicated prompts product, or your own tables and UI on top of the same ideas.
Credits
laravel-agent-editable-prompts is built and maintained by LVLUP. We help businesses drive operational efficiency through strategic consulting, tailored software development, and advanced AI agent integrations.
License
The MIT License (MIT). Please see LICENSE for more information.