
Write an AI brief for a PHP feature you can verify
Turn a broad request into one route, two inputs and a checkable response. Use a tiny display helper as the first feature.
Start with an observable result
Suppose a directory shows each program with an optional version. A request to “make the page better” leaves the intended result open. A narrower brief says that the program name appears on every card, with a version suffix only when a version is present.
Give the assistant these constraints
Keep the existing route and templates. Add one pure function that accepts two strings and returns a string. Trim both inputs, append a single space between the name and version, and leave a name without a version intact. Existing cards already escape values in the template.
<?php
function programLabel(string $name, string $version): string
{
$name = trim($name);
$version = trim($version);
return $version === '' ? $name : $name . ' ' . $version;
}
Write the acceptance checks
A name of Atlas and a version of 2.0 should produce Atlas 2.0. A blank version should produce Atlas. A version containing only spaces should behave like a blank version. Ask for those three examples in the patch.
Review the change in context
Check that the helper returns plain text and the view escapes it once. Open a real card with and without a version. If the existing database already stores version labels, reuse that field and avoid adding a schema migration for this display change.
Method & sample
Original worked example, informed by the linked reference.
Discussion
Sign in to participate.
