Claude Code Skills That Replace php artisan make
Introduction
Until 2026-09-03, line 41 of the Codyssey backend's CLAUDE.md told the agent how to create files:
php artisan make:* --no-interaction # Create filesIt came from Laravel Boost, which installs guidance for AI agents into a Laravel project, and it was written for an app this repo is not. The decision record that removed it says so: "That guidance is written for a default Laravel skeleton: an app/ directory, tests/Feature, host PHP, php artisan make:* generators". Commit 2a095c86 replaced the line with this one:
# Scaffold with /new-slice, /new-module, /admin; never php artisan make:* (ADR-021)If your app has moved away from the default layout (modules, vertical slices, domain folders) and your agent still reaches for make:controller, this piece is about that gap. It covers how the Codyssey backend's project skills replace the generators, one real slice they produced, the place where a skill did not fit, the package skills Boost installs and how they were replaced the same way, and the traps that show up when implementation fans out to parallel agents. It is part 5 of the series that starts with My Claude Code Workflow for Laravel, From Idea to Merged PR.
Why generators write the wrong shape
php artisan make:controller knows one layout: the default one. ADR-021 describes the one Codyssey has instead: "This repository is not that skeleton. There is no app/ directory; code lives in vertical slices under Codyssey/, AdminPanel/ and Framework/, tests live in each module's Tests/ folder". A vertical slice is the set of files for one action (the command, its handler, the controller, the tests), kept together in one folder instead of spread across type folders like Controllers/ and Requests/.
A generator run in that repo writes a controller into a folder that should not exist, without the final readonly shape the rules require. The code works but matches nothing around it, and every file like it is one more example the agent will copy next time.
The generic guidance also contradicted the project in quieter ways. ADR-021 found that where Boost's testing guidance loaded, "it told agents to use make:test and to ask before running the whole suite, which /preflight (the pre-PR check chain) makes mandatory." The vendor text was reasonable for a generic app and wrong for this one, and the agent had no way to tell which instruction won.
A skill is a procedure that reads the rules first
A Claude Code skill is a folder in .claude/skills/ with a SKILL.md file: a description that tells Claude when to use it, and the steps to follow. A rule says what the finished code must look like. A skill says what to do, in what order, to get there.
/new-slice builds "the command/query, handler, controller, request, resource, event, and tests for one action". The skill lists the files it creates for a write operation:
Codyssey/{Module}/{ActionName}/
├── {Action}Command.php # final readonly, promoted props
├── {Action}CommandHandler.php # final readonly, orchestrator only
├── {Action}Controller.php # final readonly, single-action __invoke()
├── {Action}Request.php # array-based validation rules
├── {Action}Resource.php # API response transformation
├── {Action}Event.php # Past tense naming (e.g., MemberSignedUp)
└── Tests/
└── {Action}ControllerTest.phpBefore it writes any of them, it sends the agent to the rules: "The full rule and the DI replacement table live in .ai/rules/orchestrators-di.md; the naming-suffix table lives in .ai/rules/models-naming.md. Read both before writing the slice." After the files exist, it walks the steps a generator never knew about: add the route, map the command to its handler in the module's service provider with Bus::map(), register any event listeners, run Pint, write the tests, run the suite.
The skill summarizes the shape and points at the rule files for the full text, so a changed rule is edited in one place and the skill picks it up.
A real slice: preparing a broadcast's media
The social broadcasting module turns a published lesson or article into posts on X, LinkedIn and other platforms. Before an admin reviews a broadcast, a queued job attaches each platform's media: a rendered card, or a carousel of slides for platforms that support one. Until PR #715, that job held the whole loop over the platform targets, which broke the rule that a job only orchestrates. The fix moved the loop into a command handler. It was merged as c33bd877, and the slice is four small files in SocialPublishing/Prepare/.
The command carries what the handler needs. SocialPublishing/Prepare/PrepareBroadcastMediaCommand.php:
<?php
declare(strict_types=1);
namespace SocialPublishing\Prepare;
final readonly class PrepareBroadcastMediaCommand
{
public function __construct(
public int $broadcastId,
public bool $mayWaitForSlides,
) {}
}The job needs an answer back: did the pass finish, or is a carousel still rendering, so it should try again later? One rule decides how the handler gives that answer: "Handlers return a typed Result DTO, never an associative array." The result is SocialPublishing/Prepare/MediaPreparation.php:
<?php
declare(strict_types=1);
namespace SocialPublishing\Prepare;
/**
* How a media preparation pass ended: finished, or stopped because a carousel
* deck is still rendering and the caller should try again later.
*/
final readonly class MediaPreparation
{
private function __construct(private bool $waitingForSlides) {}
public static function finished(): self
{
return new self(false);
}
public static function waitingForSlides(): self
{
return new self(true);
}
public function isWaitingForSlides(): bool
{
return $this->waitingForSlides;
}
}The handler, SocialPublishing/Prepare/PrepareBroadcastMediaCommandHandler.php, runs the loop. It looks media up through two interfaces, RenderedCards and RenderedSlideDecks, so the handler never touches storage directly, and it leaves the decision about each target to the SocialBroadcast model:
<?php
declare(strict_types=1);
namespace SocialPublishing\Prepare;
use SocialPublishing\Broadcast\SocialBroadcast;
use SocialPublishing\Card\RenderedCards;
use SocialPublishing\Slides\Rendering\RenderedSlideDecks;
use SocialPublishing\SocialPublishingConfig;
/**
* Settles the media of every queued target of a draft, then marks the
* broadcast media ready. A partial carousel is a broken post, so an unfinished
* deck stops the pass and the result says to wait, unless the command says
* waiting is no longer allowed.
*/
final readonly class PrepareBroadcastMediaCommandHandler
{
public function __construct(
private RenderedCards $cards,
private RenderedSlideDecks $slideDecks,
private SocialPublishingConfig $config,
) {}
public function handle(PrepareBroadcastMediaCommand $command): MediaPreparation
{
$broadcast = SocialBroadcast::query()->find($command->broadcastId);
if (! $broadcast || ! $broadcast->isPendingReview()) {
return MediaPreparation::finished();
}
foreach ($broadcast->queuedTargets() as $target) {
$channelId = $target->platform->postsToChannel() ? $this->config->discordChannelId() : null;
$copy = $target->toPlatformCopy($channelId);
$card = $this->cards->forEntry($broadcast->entry_id, $copy->platform);
if ($card) {
$copy = $copy->withMedia([$card]);
}
if ($copy->platform->supportsCarousel()) {
$deck = $this->slideDecks->forEntry($broadcast->entry_id, $broadcast->collection, $copy->platform);
if ($deck) {
$copy = $copy->withMedia($deck);
} elseif ($command->mayWaitForSlides) {
return MediaPreparation::waitingForSlides();
}
}
$broadcast->settleTargetMedia($target, $copy);
}
$broadcast->markMediaReady();
return MediaPreparation::finished();
}
}The job is left with queue concerns only: dispatch the command, and release itself for another attempt when the result says to wait. SocialPublishing/Prepare/PrepareBroadcastMediaJob.php:
<?php
declare(strict_types=1);
namespace SocialPublishing\Prepare;
use Framework\Enums\QueueName;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Bus\Dispatcher as BusDispatcher;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use SocialPublishing\Broadcast\SocialBroadcast;
/**
* Settles every target's media for a freshly drafted broadcast. An unfinished
* carousel deck releases the job for another attempt within the tries budget;
* on the last attempt the target falls back to its cover image instead.
*/
final class PrepareBroadcastMediaJob implements ShouldQueue
{
use InteractsWithQueue;
use Queueable;
public int $tries = 5;
private const SLIDE_RENDER_RETRY_SECONDS = 15;
public function __construct(private readonly int $broadcastId)
{
$this->queue = QueueName::DEFAULT->queue();
}
public function handle(BusDispatcher $bus): void
{
$result = $bus->dispatch(new PrepareBroadcastMediaCommand(
broadcastId: $this->broadcastId,
mayWaitForSlides: $this->attempts() < $this->tries,
));
if ($result->isWaitingForSlides()) {
$this->release(self::SLIDE_RENDER_RETRY_SECONDS);
}
}
/** @return list<string> */
public function tags(): array
{
return ['module:social-publishing', 'type:prepare', 'broadcast:'.$this->broadcastId];
}
/**
* A crash here must not leave Publish permanently blocked: whatever media
* already landed on the rows before the failure is what the admin sees.
*/
public function failed(\Throwable $exception): void
{
SocialBroadcast::query()->find($this->broadcastId)?->markMediaReady();
}
}The job went from 126 lines to 70. The only slide logic left in it is the retry decision, and retrying is the queue's job. The docblocks above are shortened from the source; the code is as merged.
Where the skill did not fit
This slice has no controller, no request and no resource. No HTTP route reaches it: a queued job dispatches the command. The SocialPublishing review slices (PublishBroadcast, DismissBroadcast, EditTargetCopy, RegenerateBroadcast) have the same shape, because staff act through the admin panel, which dispatches the context's command. The /admin skill covers that side: the admin resource reads the context's own aggregate directly, "and every action mutates it by dispatching the context's own command".
/new-slice only described the HTTP shape. The agent that built the slice above was told to follow it and reported at the end of its task that the skill "is only a template for Controller/Request/Resource endpoint slices and does not cover this queue-job case." The rule file had the same gap: .ai/rules/vertical-slices.md counted a controller, a request and a resource as part of every complete slice, so the reviewer would have flagged these slices as incomplete.
PR #725 fixes both. /new-slice gets a section for slices with no HTTP surface, and the rule file defines an internal slice: "Command + CommandHandler + Tests + the Bus::map() entry", plus an event when state changes. A skill encodes the common case. When an agent says the procedure does not fit the code it is building, that is the moment to update the skill and the rule together, so the next agent does not have to improvise.
New contexts get a checklist, not a template
/new-module creates a new bounded context: the module folder, its service provider and its wiring. It will not start without a plan: "This skill requires /domain-design output as input: the namespace kind, the context placement, the slice list, and the DOMAIN.md delta." Part 2 of the series covers that design step.
For a context that lives at the top level of the repo, like SocialPublishing/, the skill carries a tooling checklist. In the skill's order:
composer psr-4 and
composer dump-autoloada
<testsuite>per root inphpunit.xmlphpstan.neonpaths,excludePathsanddatabaseMigrationsPathbootstrap/providers.phpthe context's own config file
the
phparkitect.phpclass setrector.phpwithPathsthe coverage scope in
phpunit.xmlevery rule file's
paths:frontmatter, then a regenerated.ai/rules/index.md
Each item is a place where a forgotten line makes a tool skip the new code without saying so. A context missing from phpstan.neon is never analysed. A context missing from the rule files' paths: never loads its rules. Nothing fails, and the gates report green on code they never looked at.
Replace the package skills too
Boost also installs a skill for each package it detects, written for a generic app. ADR-026 records how that went wrong: "The installed Scout skill told an agent to put Searchable on App\Models\Post and to pick an engine, when the only searchable model is Framework\Models\Entry and the only engine is Typesense." The Filament skill said "to always scaffold with php artisan make:filament-*", the exact generator ADR-021 had removed.
Boost has a way out, which it calls overriding skills: a skill under .ai/skills/ with the same name as a built-in one is used instead. Codyssey has 14 package skills this way: 11 replace a skill Boost installed, and 3 add a project version of one Boost excluded or never installed. Of the replacements, ADR-026 says, "Every replacement opens with a blockquote naming the vendor file it replaced and this ADR, so a Boost or package upgrade can be diffed against it." The replacements live outside .claude/skills/ for a practical reason: "Vendor skills are never edited in .claude/skills/; boost:update overwrites that directory."
Part 4 covers the other half of this: Boost's guidelines, curated the same way.
The procedure skills
Next to the scaffolding skills sit procedures for tasks that come up again and again:
Skill | Use it to |
|---|---|
| add a cached decorator around a query handler, with its cache keys and invalidation |
| add a domain exception with the right HTTP status and reporting choice |
| handle a payment provider webhook idempotently, with retries |
| write a queue job, a queued mailable or a scheduled job |
| record a state change as a history row |
| build a transactional email from an MJML template |
| add the API documentation attributes every controller needs |
Several of them, caching, email and exceptions among them, started as Claude Code slash commands and became skills in ae1051b9 ("Convert commands to skills; one home for procedures").
Parallel agents break the environment, not the code
For a feature with an OpenSpec plan (a written plan with a task list), /openspec-apply-change works through the task list. Fan-out to subagents is a separate rule, from CLAUDE.md: "Parallel implementation subtasks in this repo use the codyssey-implementer agent". Independent tasks run in parallel, each agent in its own git worktree. In my setup, Opus plans and reviews, Sonnet implements, and effort is always set to high. The model is my choice at launch; the agent definition does not set one.
That agent definition, .claude/agents/codyssey-implementer.md, describes two kinds of worktree. The first two traps below belong to what it calls "A bare worktree with a symlinked vendor (the legacy setup)". The third is its rule for running tests in the main checkout. Each one cost a real run:
"Worktrees spawn stale (sometimes 1000+ commits behind, missing whole modules)."
Running
composer installinside a worktree "rewrites the SHARED autoloader's$baseDirto the worktree path, breaking the main checkout and every other concurrent agent with phantom class-not-found errors."Parallel test runs collide on database names: "paratest worker DB names (
codyssey_testing_test_1...) are deterministic, so two agents'migrate:freshrace on the same worker DB." Each agent creates its own test database and drops it afterwards.
The last rule is about honesty: "Passing phpstan is NOT proof your change works; prior agents passed phpstan while breaking runtime behavior three times." An agent reports what it verified and how, and says so when a check could not run.
PR #715's run added one more trap. That agent worked in a prepared worktree, the variant with its own vendor/ directory instead of a link to the shared one. Setup runs composer install once, and the agent file says not to run composer after that. The setup install failed with HTTP 401 from Filament's package server until the agent copied the git-ignored auth.json across from the main checkout.
Where to start
Pick one task your agent gets wrong in the same way every time. Do it by hand once, write down the order you did it in, and save that as a skill that names the rule files to read before writing anything. Then delete the make:* line from your CLAUDE.md. Part 6 covers what happens after the code is written: the gates, the review, and the rounds of fixes.
Related Links
- My Claude Code Workflow for Laravel, From Idea to Merged PRpart 1, the whole process followed through one feature, with links to every other part
- Claude Code skillshow skills are defined, named and loaded
- Laravel Boostthe package behind the vendor guidelines and the package skills
- Claude Code subagentshow agent definitions like codyssey-implementer work