Skip to main content
Version: v1 (Current)

Dev Hub Prompt Commands

The developer hub exposes a global, slash-prefixed command prompt at the bottom of the screen (open with Cmd/Ctrl + K). Commands are first-class: each one is a small definition file that the registry auto-discovers, and commands can return a descriptor for inspection in a shared modal, or return null for a separate side effect. This prompt is distinct from AI App editing.

Use this guide alongside the current registry, command definition and backend route. Client discovery and argument parsing do not establish server authorization or successful execution.

At a glance​

  • Open the terminal: Cmd/Ctrl + K from anywhere in DevHub.
  • List commands: an empty prompt shows up to seven available top-level suggestions; type / and a few characters to filter.
  • Navigate suggestions: arrow keys; Tab autocompletes the highlighted entry without running it; Enter runs.
  • Bare command (/balance) opens that command's landing modal — for most commands this is a help/subcommand list, but a command can define a custom open() instead.
  • With arguments (/balance topup ai_credits_usd 50) runs the matching subcommand and renders its result in the global modal.

File map​

ConcernPath
Registry composableresources/js/Developer/Composables/useDevPrompt.js
Shared active result stateresources/js/Developer/Composables/useDevPromptResult.js
Result modal mountresources/js/Developer/Components/UI/DPromptResultModal.vue (singleton in Developer/app.js)
Terminal dock UIresources/js/Developer/Layouts/Partials/DevTerminalDock.vue
Default help rendererresources/js/Developer/Prompt/components/DPromptCommandHelp.vue
Command definitionsresources/js/Developer/Prompt/commands/*.js
Command UI componentsresources/js/Developer/Prompt/components/*.vue
Backend controllersapp/Http/Controllers/Developer/Prompt/*Controller.php
Backend routesroutes/developer.php under prompt.*

Architecture​

The dock owns no per-command logic. It calls useDevPrompt().getSuggestions(input) to power the type-ahead list and useDevPrompt().executeCommand(input) to dispatch. The result (if any) is handed to useDevPromptResult().showResult(...), which a singleton <DPromptResultModal /> mounted in Developer/app.js renders inside a shared DModal.

Commands live as one file each under resources/js/Developer/Prompt/commands/. The registry auto-imports them with a Vite glob (import.meta.glob('../Prompt/commands/*.js', { eager: true })), filters by permission via usePermissions(), and exposes the result as availableCommands. Adding a command never requires editing the dock, the registry, or the result modal — drop in a new file, optionally a controller + routes, and it appears.

Adding a new command — checklist​

  1. Define it. Create resources/js/Developer/Prompt/commands/<name>.js exporting a CommandDefinition (schema below).
  2. (Optional) Modal panels. Put result/landing Vue components under resources/js/Developer/Prompt/components/. Each receives an @close event it can emit to dismiss the modal.
  3. (Optional) Backend endpoints. Add app/Http/Controllers/Developer/Prompt/<Name>Controller.php and register routes under developer.prompt.<name>.* inside the existing /{team}/developer group in routes/developer.php. Guard mutation endpoints with the superAdmin middleware unless you have a permission-string check.
  4. That's it — Cmd/Ctrl + K and the new command appears.

CommandDefinition schema​

export default {
// Required. The slash slug users type.
slug: "balance",

// Required. One-line description shown in type-ahead and help modals.
description: "Manage consumable balances for the current team",

// Optional. Controls visibility in the type-ahead and gates `executeCommand`.
// null — visible to anyone authenticated in DevHub
// 'super_admin' — visible only when isSuperAdmin() is true
// 'some.string' — visible only when userCan('some.string') is true
permission: null,

// Optional. Handler for the bare `/balance` invocation. Receives a `ctx`
// (see "Command context" below) and returns a ResultDescriptor, a
// Promise<ResultDescriptor>, or `null` to suppress the result modal.
// When omitted, a built-in help renderer lists the visible subcommands.
open: ({ ctx }) => ({
title: "Consumable Balances",
component: BalancePanel,
props: { teamSlug: ctx.teamSlug },
size: "lg",
}),

// Optional. Subcommands invoked as `/balance <slug> [args...]`.
subcommands: [
{
slug: "topup",
description: "Add credit to a direct bucket",
permission: "super_admin", // optional, same semantics as top-level
args: [
// Positional order matches array order. Required args fail parsing
// when absent. `type` controls coercion: 'string' | 'number' | 'boolean'.
{ name: "slug", type: "string", required: true },
{ name: "amount", type: "number", required: true },
{ name: "reason", type: "string", required: false },
],
run: async ({ args, ctx }) => {
const res = await axios.post(
route("developer.prompt.balance.top-up", { team: ctx.teamSlug }),
args,
)
return {
title: "Top-up complete",
component: BalanceTransactionResult,
props: { result: res.data, action: "topup" },
size: "md",
}
},
},
],
}

ResultDescriptor​

What open() / run() should return (or resolve to):

FieldRequiredNotes
componentfor non-error UI resultsVue component rendered inside DModal. Receives the listed props plus an @close emit.
propsnoObject spread onto the component.
titlenoModal title. Defaults to empty string.
sizenoOne of 'sm' | 'md' | 'lg' | 'xl'. Defaults to 'lg'.
errornoIf set, the modal renders this error message instead of component.

The result state is one active descriptor, not a FIFO queue: a new result replaces the previous one. Closing a modal clears that display state; it does not cancel a pending request or reverse a mutation. executeCommand catches execution errors and returns their response/message as an error descriptor; callers still need to verify the operation outcome.

Return null (or undefined) to opt out of the result modal entirely — useful for side-effect-only commands like /flappy, which just toggles a shared composable state to open its own modal.

Command context​

open() and run() receive { ctx } (and run also receives args). ctx is built from the current Inertia page and exposes:

KeyTypeSource
teamSlugstring | undefinedusePage().props.currentTeam?.slug
teamobject | undefinedusePage().props.currentTeam
isSuperAdminbooleanusePermissions().isSuperAdmin()

Add to this set by editing buildContext() in useDevPrompt.js — only when the command needs a well-defined additional context. teamSlug/team can be undefined if currentTeam props are absent; they are not guaranteed by this object construction. Resolve and verify the intended team before invoking a team-scoped endpoint.

Argument parsing​

The parser accepts both shapes — pick whichever feels right for the command. Positional comes first, named flags override.

InputResolved args
/balance topup ai_credits_usd 50{ amount: 50, slug: "ai_credits_usd" } (positional, in args order)
/balance topup --amount=50 --slug=ai_credits_usdsame
/balance topup --amount 50 --slug ai_credits_usdsame (space-separated also works)
/balance topup ai_credits_usd 50 --reason "manual top-up"separate flag value preserves the quoted phrase

Rules of thumb:

  • Order positional args by frequency / obviousness — required ones first. Frequent users will reach for positional, occasional users will rely on --name= for self-documentation.
  • Reserve --flags for booleans, optional fields, or things that don't have an obvious positional slot.
  • Coercion is done from the type field on each args entry — finite numbers parse via Number(); a non-finite/unparseable value is returned unchanged. Boolean strings true|false|1|0 are recognized, but other values use JavaScript truthiness. Strings use String(value).

Parser limits to account for​

The tokenizer groups a double-quoted segment when the quote starts the token. Use --reason "manual top-up", not --reason="manual top-up": the latter can split at the space and retain quote fragments. Single quotes and shell escape syntax are not a supported shell parser. A shell command copied into this prompt is not executed as a shell command.

Named flags override their matching positional slot; remaining positionals are not shifted to fill a different schema slot. Unknown named flags and surplus positionals are not returned as declared arguments. Required checks detect missing values, not all invalid values. A bare flag becomes true; invalid numeric text can survive parsing; a nonempty unknown Boolean string can become true. Backend validation must enforce domain types, ranges and allowed values.

registerCommand(def) can register/replace a matching slug for late binding/tests; eager file discovery is not the only registration path. Do not rely on frontend registry entries as a privilege boundary.

Permissions​

Permission checks happen in two places and both must hold:

  1. Frontend filters out commands and subcommands the user can't run so they never appear in suggestions or execute via executeCommand.
  2. Backend enforces it again on the route — either by wrapping the route in the superAdmin middleware or by adding a policy / userCan check in the controller. The frontend filter is UX, not security.

When a subcommand mutates data, prefer:

Route::middleware(['superAdmin'])->group(function () {
Route::post('/top-up', [PromptBalanceController::class, 'topUp'])
->name('top-up');
});

inside the intended authenticated/team-scoped route group. Verify backend policy/middleware for read operations too; a null frontend permission is not public API access. The balance routes inherit authenticated, verified and team-scope middleware. Their request authorize methods return true and rely on route-level mutation restrictions, so copying only a request class does not copy that protection.

Reference: /balance​

The shipped command demonstrates every piece:

FileRole
resources/js/Developer/Prompt/commands/balance.jsDefinition: open panel + stats, ledger, topup, adjust subs
resources/js/Developer/Prompt/components/BalancePanel.vueInteractive landing modal — read for everyone, top-up + adjust forms shown to super admins
resources/js/Developer/Prompt/components/BalanceTransactionResult.vueRenders single-tx outcomes of topup / adjust
resources/js/Developer/Prompt/components/BalanceLedgerResult.vueTable view for /balance ledger [slug]
app/Http/Controllers/Developer/Prompt/BalanceController.phpindex, topUp, adjust, transactions; delegates mutations to TeamConsumableService
routes/developer.php (prompt.balance.*)4 routes; mutations wrapped in inner superAdmin middleware

Example syntax (top-up/adjust are privileged durable mutations, not test commands):

/balance
/balance stats
/balance ledger ai_credits_usd
/balance topup ai_credits_usd 50
/balance topup --slug=ai_credits_usd --amount=50 --reason "manual top-up"
/balance adjust --slug=ai_credits_usd --amount=-10 --reason "manual correction"

Bare balance and stats open panels; ledger reads filtered entries. Top-up positionals are slug, amount, optional reason. Adjustment positionals are slug, amount, required reason, optional source, optional source_ref; named flags make that intent explicit. Do not append shell-style comments to prompt input.

Migrating a side-effect command​

If your command doesn't open a result modal (e.g. it toggles some existing UI state), follow the /flappy pattern:

  1. Create a tiny useX() composable that owns the shared ref.
  2. Have the existing UI consumer (sidebar, layout, etc.) bind to that composable's open ref.
  3. The command file calls useX().show() (or whatever) inside open() and returns null to suppress the result modal.

Example: resources/js/Developer/Prompt/commands/flappy.js paired with resources/js/Developer/Composables/useFlappy.js.

Anti-patterns​

  • Don't import command definitions from outside the registry — use the registry. Direct imports skip permission filtering.
  • Don't put modal state into a command file. Returning a ResultDescriptor is how a command opens UI; everything else routes through a shared composable.
  • Don't rely on the frontend permission filter for security. Always guard the route or controller too.
  • Don't make args optional when the backend requires them — the parser surfaces a Missing required argument(s) error if you declare them required: true, which is a better UX than a 422 from the API.

Verify and troubleshoot​

Use a synthetic local command when testing parsing and result presentation. Balance top-up/adjust examples describe privileged durable mutations; they are not a harmless smoke test. The current dock does not establish a general one-execution-at-a-time or idempotency guarantee. Repeated Enter presses can require explicit command-side protection; inspect transaction/result state before retrying.

For /balance, top-up requires a configured consumable slug and positive numeric amount. Adjustment requires a nonzero signed amount, supported source and reason; the command defaults source to direct when omitted. The backend obtains currentTeam from request attributes and delegates to TeamConsumableService. A frontend context value, success title or closed modal is not proof the intended bucket/ledger changed.

SymptomCheck
Command absentDefault export, slug, eager glob, effective frontend permission and seven-suggestion cap
Missing/incorrect argumentDeclared positional order, named override, token boundaries and coercion limits
Quoted reason splitsUse separate --reason "two words"; avoid quoted equals syntax
Frontend allows, endpoint deniesAuthenticated/verified/team context, super-admin middleware and actual request validation
Result disappears or changesSingleton active-result replacement and close behavior
Duplicate mutation concernPending requests and ledger/result identity before retry; no generic exactly-once guarantee

Validate a new command's allowed and denied principals, argument failures, context changes, repeated invocation, response errors and close behavior. No live balance mutation is required to verify parser behavior. Detailed financial/operational remediation belongs in separate runbooks.