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.

Maintainers

Package info

github.com/lvlup-dev/laravel-agent-editable-prompts

Homepage

Type:laravel-package

pkg:composer/lvlup-dev/laravel-agent-editable-prompts

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2026-03-29 21:01 UTC

This package is auto-updated.

Last update: 2026-03-29 21:01:45 UTC


README

Latest Version on Packagist MIT Licensed

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.jsonextra.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 UI
  • content — prompt body (your app may treat it as Blade, Markdown, etc.)
  • priority — integer; lower values sort first when priority_sort_direction is asc

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.index
  • agent-editable-prompts.create
  • agent-editable-prompts.store
  • agent-editable-prompts.edit
  • agent-editable-prompts.update
  • agent-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.