Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/advanced/tracking.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Deck by PromptPHP includes an optional database tracking system that logs prompt
Tracking is entirely optional and **off by default**. Deck works fully without it.

<Note>
Prompt rendering never depends on tracking. If you enable it without running the migrations, or the database becomes unreachable, Deck falls back to `metadata.json` and logs a warning once rather than failing. `Deck::track()` never throws under any circumstances — it runs after a completed, paid-for AI call.
Prompt rendering never depends on tracking. If you enable it without running the migrations, or the database becomes unreachable, Deck falls back to `metadata.json` and logs a warning once rather than failing. `Deck::track()` never throws under any circumstances, because it runs after a completed, paid-for AI call.
</Note>

## Setup
Expand Down Expand Up @@ -141,11 +141,11 @@ Deck::track('order-summary', 2, [
]);
```

If tracking is disabled in configuration, the `track()` method is a safe no-op — you can call it without checking configuration first.
If tracking is disabled in configuration, the `track()` method is a safe no-op. You can call it without checking configuration first.

### Automatic tracking via middleware

When using the [Laravel AI SDK integration](/integrations/ai-sdk), the `TrackPromptMiddleware` handles tracking automatically. See [AI SDK — Performance Tracking Middleware](/integrations/ai-sdk#performance-tracking-middleware) for setup details.
When using the [Laravel AI SDK integration](/integrations/ai-sdk), the `TrackPromptMiddleware` handles tracking automatically. See [Performance tracking middleware](/integrations/ai-sdk#performance-tracking-middleware) for setup details.

### Tracked fields

Expand Down Expand Up @@ -387,12 +387,12 @@ When tracking is enabled, `Deck::activate()` and `prompt:activate` record the ac

Once a version has been activated with tracking enabled, **the database wins**. `metadata.json` is consulted only when the table holds no record for that prompt.

The practical consequence: editing `active_version` in `metadata.json`, committing it, and deploying **will not change which version is served**. Activation is environment state — it is how you promote a version in staging without touching production, and how you roll back without a deploy. The file is the bootstrap default, used until the first activation in that environment.
The practical consequence: editing `active_version` in `metadata.json`, committing it, and deploying **will not change which version is served**. Activation is environment state. It is how you promote a version in staging without touching production, and how you roll back without a deploy. The file is the bootstrap default, used until the first activation in that environment.

To go back to file-based control for a prompt, delete its rows from `prompt_versions`.

<Note>
The table only ever holds versions that have been **activated**. It is not a mirror of your prompt library — a version you have created but never activated has no row. The `system_prompt` and `user_prompt` columns are nullable and are written as `NULL`: Deck is file-based, and content lives on disk.
The table only ever holds versions that have been **activated**. It is not a mirror of your prompt library. A version you have created but never activated has no row. The `system_prompt` and `user_prompt` columns are nullable, and Deck writes them as `NULL` because content lives on disk.
</Note>

```php
Expand Down
14 changes: 7 additions & 7 deletions docs/core/commands.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ What would you like to do?

With `--force`, the latest version is overwritten without prompting.

See [Creating Prompts](/core/make-prompt) for comprehensive documentation.
See [Creating prompts](/core/make-prompt) for comprehensive documentation.

## prompt:list

Expand Down Expand Up @@ -140,8 +140,8 @@ Output:

### Notes

- If the prompts directory does not exist, a warning is displayed.
- If no prompts are found, an informational message is shown.
- If the prompts directory does not exist, the command displays a warning.
- If the command finds no prompts, it shows an informational message.
- Descriptions come from the prompt's root `metadata.json`, and a version may override the shared description in its own `metadata.json`.

## prompt:activate
Expand Down Expand Up @@ -177,12 +177,12 @@ Version 2 of prompt [order-summary] activated.

### How it works

- **With database tracking enabled**: Updates the `prompt_versions` table — sets `is_active = false` on all versions for that prompt, then `is_active = true` on the specified version.
- **With database tracking enabled**: Updates the `prompt_versions` table. It sets `is_active = false` on all versions for that prompt, then `is_active = true` on the specified version.
- **Without tracking**: Writes the `active_version` key to the prompt's root `metadata.json` file.

### Error handling

If the prompt or version does not exist, an error message is displayed:
If the prompt or version does not exist, the command displays an error message:

```
Version 5 for prompt [order-summary] does not exist.
Expand Down Expand Up @@ -335,6 +335,6 @@ php artisan prompt:test order-summary --input="Order #5678 with 3 items"
### Notes

- The `--variables` option expects valid JSON. Invalid JSON produces an error: `Invalid JSON for --variables`.
- Expected variables (from `metadata.json`) are displayed as a hint, if available.
- Both the rendered system and user prompts are displayed.
- The command displays expected variables (from `metadata.json`) as a hint, if available.
- The command displays both the rendered system and user prompts.
- Unmatched variables remain as placeholders in the output, making it easy to spot missing values.
28 changes: 14 additions & 14 deletions docs/core/make-prompt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resources/prompts/
└── system.md
```

A **system prompt** file is always created. Two `metadata.json` files are written: one at the prompt root recording the prompt's name, description, roles, and creation timestamp, and one inside the version directory recording that version alone.
The command always creates a **system prompt** file. It also writes two `metadata.json` files. The one at the prompt root records the prompt's name, description, roles, and creation timestamp. The one inside the version directory records that version alone.

### Interactive mode

Expand All @@ -38,16 +38,16 @@ Run the command without any arguments to enter a fully interactive flow:
php artisan make:prompt
```

You will be guided through a series of questions:
The command guides you through a series of questions:

1. **What should the prompt be named?** — Provide a name (automatically converted to kebab-case).
2. **Briefly describe this prompt (press Enter to skip)** — An optional description stored in `metadata.json`.
3. **Would you also like to create a user prompt file?** — Confirm to scaffold a `user.md` alongside `system.md`.
4. **Would you like to create prompt files for additional roles?** — Confirm, then enter comma-separated role names (e.g. `assistant, developer`).

<Note>
The interactive description and user-prompt questions are only asked when
the name argument is omitted. When passing a name directly, use the
The command only asks the interactive description and user-prompt questions
when you omit the name argument. When passing a name directly, use the
`--desc`, `--user`, and `--interactive` options instead.
</Note>

Expand Down Expand Up @@ -122,7 +122,7 @@ The command writes two metadata files: one at the prompt root describing the pro
| `variables` | Reserved for future use (template variable extraction). Never reset once you populate it. |
| `created_at` | ISO 8601 timestamp of when the **prompt** was first created. |

Any other keys you add by hand are preserved — including `active_version`, so **scaffolding a new version never changes which version your application serves**. When another version is active, the command tells you how to promote the one you just created:
The command preserves any other keys you add by hand, including `active_version`. **Scaffolding a new version never changes which version your application serves**. When another version is active, the command tells you how to promote the one you just created:

```
Version 2 of the [order-summary] prompt has been created successfully with the following roles: system.
Expand All @@ -143,13 +143,13 @@ Run `php artisan prompt:activate order-summary v2` to make v2 live.
}
```

Add your own keys here to override prompt-level metadata for a single version — see [Metadata](/core/prompts#metadata) for how the two files merge.
Add your own keys here to override prompt-level metadata for a single version. See [Metadata](/core/prompts#metadata) for how the two files merge.

## Roles

### System role (default)

A `system.md` file is **always** created. This is the primary prompt file and represents the system-level instructions for your AI agent. No flag is needed:
The command **always** creates a `system.md` file. This is the primary prompt file and represents the system-level instructions for your AI agent. No flag is needed:

```bash
php artisan make:prompt code-reviewer
Expand All @@ -176,7 +176,7 @@ php artisan make:prompt code-reviewer --user
# Creates: system.md + user.md
```

In the interactive flow (name omitted), you are asked whether to create a user prompt via a confirmation question.
In the interactive flow (name omitted), the command asks whether to create a user prompt.

The default user prompt stub contains:

Expand Down Expand Up @@ -218,8 +218,8 @@ php artisan make:prompt code-reviewer -i
```

<Note>
When `--role` values are provided explicitly, the interactive role prompt is
skipped — explicit values always take precedence.
When you provide `--role` values explicitly, the command skips the
interactive role prompt. Explicit values always take precedence.
</Note>

All scaffolded roles (including `system` and optionally `user`) are recorded in the `roles` array of `metadata.json`.
Expand All @@ -230,7 +230,7 @@ Deck uses directory-based versioning. Each version lives in its own sub-director

### Auto-increment

When you run the command for a prompt that already has one or more versions, you are presented with a choice:
When you run the command for a prompt that already has one or more versions, the command presents a choice:

```bash
php artisan make:prompt code-reviewer
Expand All @@ -257,7 +257,7 @@ In non-interactive environments (CI pipelines, scripts), use `--force` (or `-f`)
php artisan make:prompt code-reviewer --force
```

If version 2 exists, `--force` overwrites `v2/` directly. It will **never** create a new version automatically — its purpose is to regenerate the latest version.
If version 2 exists, `--force` overwrites `v2/` directly. It **never** creates a new version automatically. Its purpose is to regenerate the latest version.

For brand-new prompts, `--force` has no special effect; `v1/` is created as normal.

Expand Down Expand Up @@ -288,7 +288,7 @@ your-app/
└── role-prompt.stub
```

Published stubs **always take precedence** over the package defaults. You only need to publish the stubs you want to override — any missing stubs fall back to the package defaults.
Published stubs **always take precedence** over the package defaults. You only need to publish the stubs you want to override. Any missing stubs fall back to the package defaults.

### Using a one-off template

Expand Down Expand Up @@ -346,7 +346,7 @@ php artisan make:prompt email-drafter --user
php artisan make:prompt email-drafter --role=assistant --role=reviewer
```

**Create a prompt with everything — user, roles, and a description:**
**Create a prompt with everything (user, roles, and a description):**

```bash
php artisan make:prompt email-drafter -u --role=assistant --desc="Drafts professional emails"
Expand Down
Loading
Loading