Skip to content

Claude Code Found 14 Rule Breaks in Merged Laravel Code

Insights•
October 19, 2026

Introduction

On 2026-10-05 I ran a standards review over the social broadcasting code in the Codyssey backend, a Laravel 13 and Statamic v6 app. The code turns a published lesson or article into posts on X, LinkedIn and other platforms. It was merged, its tests passed, and PHPStan was clean at its strictest level. The review found 14 violations of the project's own written rules: 7 medium, 7 low, none high.

Two of them show what "works but violates" means. A console command called the social media vendor's API (Zernio) directly, when the rules say vendor calls go through a dedicated service. The admin panel pulled a configuration class out of another module, when the rules say the admin panel reaches that module only through its commands, queries, read models, enums, exceptions and fact events. Neither one broke anything.

This piece walks through the gates the code passes before review, what each one can and cannot see, and the review that caught the 14. Then it tells the fix in full: three review rounds in PR #715, with the failed test runs and the disagreement between two rule files left in. It is part 6 of the series that starts with My Claude Code Workflow for Laravel, From Idea to Merged PR.

Tools check what they can see

Four tools run on every change (the wider toolset is in 7 PHP Code Quality Tools That Pay Off Years Later). Pint formats the code. PHPArkitect checks architecture rules, such as which namespaces may import which and which classes must be final. PHPStan runs at level max, its strictest. PHPUnit runs the suite. Each one covers a slice of the rules, and the PHPArkitect config says where its slice ends:

NOT covered (function calls / file directives the tool cannot see): global helpers (now(), app(), DB::, Auth::), declare(strict_types=1). Those remain with Rector / PHPStan / Pint and the /codyssey-reviewer agent.

A rule like "controllers are single-action and must be final" is easy for a tool, because it is a fact about a class. A rule like "a console command does not call a vendor API itself" is harder: the tool would have to know which classes are vendor clients and which calls count. Most of the 14 findings were the second kind.

/preflight runs the gates in order

/preflight is a Claude Code skill that runs the gates before a pull request. Its central instruction:

Run the gates below in order and stop at the first failure. Report the failure with its output, propose the fix, and only continue the chain once that gate passes. Do not skip ahead: a later gate passing means nothing while an earlier one fails.

The first four gates are these commands. Spin runs them inside the app's Docker container, since host PHP cannot boot this app:

BASH
vendor/bin/pint --dirty \ && spin run php composer arkitect \ && spin run php composer phpstan \ && spin run php composer test

Two of the skill's rules stop an agent from getting to green the cheap way. The PHPArkitect baseline holds 192 old violations so the tool could be adopted on existing code, and "Never 'fix' a failure by adding to the baseline; fix the code." For PHPStan: "No new @phpstan-ignore without a stated reason." CI then runs the same four tools on every pull request, with the suite in parallel, so a skipped local run still gets caught before merge.

The reviewer checks what the tools cannot

The fifth gate is /codyssey-reviewer. It reads the diff and checks it against the rule files in .ai/rules/. The skill describes itself as "the standards reviewer, distinct from /code-review": it looks for rule violations, not bugs.

It splits the rules into 10 families (orchestration and dependency injection, naming, module isolation, tests, and so on) and gives each family its own auditor, a subagent that receives that family's rule file word for word. The skill gives the reason: a single reviewer holding every rule "skims and anchors on whatever it noticed first", while one auditor per family gives every family full attention and checks "the actual rule rather than a half-remembered paraphrase."

Every auditor gets the same contract. Four of its lines:

MARKDOWN
- Cite a specific rule for every finding. No rule, no finding. - Be conservative about false positives: if you can't point to the exact rule and the exact line, don't report it. - Stay in your lane: report standards violations, not correctness bugs, not style preferences that no rule states, not pre-existing issues on lines this diff didn't touch. - Severity: high = breaks an isolation/security/data rule or a strictly-enforced pattern (orchestrator, no-FQCN-in-DB, AdminPanel isolation); med = a clear rule violation with limited blast radius; low = a real but minor deviation.

When the auditors report back, nothing gets filtered by confidence. A finding the reviewer doubts stays in the report, marked "(verify)" with one line on the doubt, instead of being dropped. Part 3 of the series covers why one auditor per rule family works.

Round 1: 14 findings in working code

The 2026-10-05 review covered main at 260a1d6a. Nine families ran; the paid-content family did not apply. The authorization and routes auditors came back clean. The rest found these:

Severity

Finding

med

SubscribeWebhooksCommand calls the vendor from a console command

med

SocialPublishingConfig reads the vendor's API key

med

SocialPlatform, a domain enum, holds the vendor's platform names

med (verify)

The admin panel resolves SocialPublishingConfig from the container in two files

med (verify)

The admin panel imports the MediaItem value object in three files

med

SocialBroadcastCarouselOutcome is not a domain term

med

Three tests compare against now() without freezing time

low

RenderSlideDeckJob compares raw attributes

low

PrepareBroadcastMediaJob loops over targets itself

low

Classes named *Resolver instead of domain terms

low

AdminActivityLog/Listeners/ is a folder named after a type

low

The Zernio exceptions have no shared base class

low

Four test methods are missing the it_ prefix

low

SocialBroadcastResource has no $navigationSort

Both "(verify)" findings held up. The review also caught one documentation drift outside the count: docs/MODULES.md listed a Regenerate/ folder that does not exist.

Fixing: one commit per fix, rule quoted

An agent fixed the findings on a branch, one commit per fix, each commit body opening with the rule it fixes. The first finding is the console command. Its commit, 52fb0ad2, starts:

orchestrators-di.md: flag an orchestrator that "Calls an external service (HTTP, filesystem, PDF) directly instead of via a dedicated infrastructure/service class" or "interpret[s] external/vendor data vocabularies". SubscribeWebhooksCommand sent the list and create-or-update requests itself and read the vendor responses.

This is the command before the fix, Zernio/Webhooks/SubscribeWebhooksCommand.php at 260a1d6a:

PHP
<?php declare(strict_types=1); namespace Zernio\Webhooks; use Illuminate\Console\Command; use Illuminate\Contracts\Config\Repository; use Saloon\Exceptions\Request\FatalRequestException; use Saloon\Exceptions\Request\RequestException; use Zernio\ZernioConnector; final class SubscribeWebhooksCommand extends Command { protected $signature = 'zernio:subscribe-webhooks'; protected $description = 'Subscribe to the social publishing vendor status webhook events.'; private const NAME = 'Codyssey Social Publishing'; /** @var list<string> */ private const EVENTS = [ 'post.platform.published', 'post.platform.failed', 'post.published', 'post.failed', 'post.partial', 'post.cancelled', ]; public function __construct( private readonly ZernioConnector $connector, private readonly Repository $config, ) { parent::__construct(); } public function handle(): int { $webhookUrl = $this->webhookUrl(); $secret = $this->webhookSecret(); if (! $secret) { $this->error('Refusing to subscribe: zernio.webhook_secret is not configured. Zernio would sign deliveries with a key VerifyWebhookSignature never validates, and every inbound webhook would be rejected.'); return self::FAILURE; } $existingId = null; try { $existingId = WebhookList::fromResponse( $this->connector->send(new ListWebhooksRequest) )->idForUrl($webhookUrl); $response = SubscribeWebhookResponse::fromResponse($this->connector->send($existingId ? new UpdateWebhookRequest($existingId, self::NAME, $webhookUrl, $secret, self::EVENTS) : new SubscribeWebhooksRequest(self::NAME, $webhookUrl, $secret, self::EVENTS))); } catch (RequestException|FatalRequestException $exception) { $this->error('Failed to subscribe to vendor webhook events: '.$exception->getMessage()); return self::FAILURE; } if (! $response->successful()) { $this->error('Failed to subscribe to vendor webhook events: '.$response->errorMessage()); return self::FAILURE; } $this->info($existingId ? 'Updated the existing vendor webhook subscription.' : 'Subscribed to vendor webhook events.'); return self::SUCCESS; } private function webhookUrl(): string { $value = $this->config->get('zernio.webhook_url', ''); return is_string($value) ? $value : ''; } private function webhookSecret(): ?string { $value = $this->config->get('zernio.webhook_secret'); return is_string($value) && $value !== '' ? $value : null; } }

The command reads config, sends three kinds of vendor request, and interprets the vendor's answers. After the fix, a new WebhookSubscriber service does all of that and returns a result object, and the command prints it. The same file at c33bd877:

PHP
<?php declare(strict_types=1); namespace Zernio\Webhooks; use Illuminate\Console\Command; final class SubscribeWebhooksCommand extends Command { protected $signature = 'zernio:subscribe-webhooks'; protected $description = 'Subscribe to the social publishing vendor status webhook events.'; public function __construct(private readonly WebhookSubscriber $subscriber) { parent::__construct(); } public function handle(): int { $result = $this->subscriber->subscribe(); if (! $result->successful()) { $this->error($result->message()); return self::FAILURE; } $this->info($result->message()); return self::SUCCESS; } }

The output and exit codes did not change, and the existing command test kept passing. The subscription logic can now be called from somewhere other than a console command, and it can be tested without one.

The other 13 fixes did not all go cleanly. Three runs failed on the way:

  • 8 admin panel tests failed with "A notification was expected but none were sent". The new check for whether the vendor is configured read the API key from the vendor's connector, and the connector is built once, before the tests set the key. The fix was a small class that reads config on every call.

  • A new test helper named setup() caused a fatal error, because PHPUnit's TestCase already has setUp(), and PHP method names ignore case. It was renamed.

  • Pint reordered imports in two files after classes were renamed.

Round 1 ended with 14 commits: 13 for the findings, since 4ee38ddf fixed two, and one for the docs/MODULES.md drift. The full suite of 5,648 tests passed, along with Pint, PHPStan and PHPArkitect.

Round 2: the fixes made new findings

The second review ran over the fix branch, one auditor per family again, each given the 14 findings to check against its own rules. All 14 came back resolved. Four new findings came back with them, all low:

  • ZernioApiException did not override statusCode(), which the exceptions rule requires of every concrete exception, so it would render as a 500. It now returns 502, because a vendor's 401 or 429 must never reach our own client as if it were our status.

  • The class rename from round 1 missed two method names and a label: carouselOutcomeLabel(), carouselOutcomeColor() and "Carousel Outcome".

  • Round 1 added two new terms, "publishing setup" and a name for the media step, without adding them to the project glossary in docs/DOMAIN.md.

  • The loop that round 1 moved out of the queue job had landed on the SocialBroadcast model, and a different rule objected.

The last one is the case worth knowing about. Round 1 cited orchestrators-di.md, which flags a job or handler that loops over child records "instead of a single aggregate/model method", so the loop moved onto the model (f5293362). Round 2 cited models-naming.md: "complex / multi-aggregate business logic belongs in a handler". The model method now took two storage lookups as arguments, decided when the job should retry, and marked targets as failed.

Each rule was right about part of it, so I made the call: the loop went into a command handler, and the model kept one method that settles a single target from plain values. That shape satisfies both rules. The commit that did it, bf1a1ec7, says what it reversed: "This reverses the model placement chosen in f5293362." Its first PHPStan run failed too, on an instanceof check PHPStan could prove was always true, and the check was removed. Part 5 of the series shows the handler and its result class in full.

Round 3: clean, apart from one word

The third review ran three auditors over the four commits since round 2. No violations. One advisory note: round 2's glossary entry called the step "media settling", while the code calls it Prepare and MediaPreparation. The fixes had introduced a vocabulary mismatch of their own. 03bb0690 renamed the glossary term to "media preparation".

The whole loop:

Round

Review

Findings

Commits

Tests passing

1

9 families over main

14 (7 medium, 7 low)

14

5,648

2

8 families over the branch

4 new, all low

4

5,651

3

3 families over the last 4 commits

0, plus 1 advisory

1

5,651 (carried over from round 2, not rerun)

PR #715 merged on 2026-10-08 as c33bd877, with 19 fix commits and all six CI checks green. The PHPUnit check alone took 25 minutes 57 seconds.

What the gates do not catch

The reviewer checks standards, and the tests check the behavior someone thought to test. Neither one knows what the feature is for. In August 2026, the copy generator read each post's image from a field called og_image. The proposal that fixed it (openspec/changes/archive/2026-09-03-fix-social-broadcast-media-source) says the handle is "declared in no blueprint anywhere" in the codebase, so every post would have gone out with no image. The tests did not catch it. It was found by reading the code while planning the next change, before the feature's pull request merged.

That is why bugs have their own checks in this process. I read the full diff of every pull request. The tests and PHPStan run in CI. Before each release, /smoke-test walks the staging site in a browser, and "zero new issues is the pass bar".

Done includes the docs and what the session learned

CLAUDE.md puts the finish line past the green checks:

A change that leaves docs describing the old behavior, or a learned rule that dies with the session, is not finished.

PR #715 also updated docs/MODULES.md, docs/DOMAIN.md, docs/SOCIAL_PUBLISHING.md, docs/MCP.md, docs/integrations/ZERNIO_API.md and one line of ADR-016, because the renames had made them wrong. When a session learns something durable, Claude records it in .ai/rules/ with Laravel Boost's record-rule tool, and I review the new rule in the pull request like any other change.

My own definition of done, which is not written in CLAUDE.md, has four parts: no MUST rule violated, no reviewer findings at any severity, the four CI gates green, and the docs, rules and skills matching the change.

Where to start

Run one reviewer per rule family over code you already merged, and fix what it finds. You need written rules first; if all you have is a long CLAUDE.md, split it by topic and give each topic its own auditor. The first round shows which of your rules were written down and never enforced. Expect the fixes to produce findings of their own, and budget for a second round.