Skip to content

My Claude Code Workflow for Laravel, From Idea to Merged PR

Insights•
October 19, 2026

Introduction

Few weeks ago, I ran a standards review over the social broadcasting code in the Codyssey backend. That code turns a published lesson or article into posts on X, LinkedIn and other platforms. It was merged, and its tests passed. The review still found 14 violations of the project's own written rules: 7 medium, 7 low, none high. A console command called the vendor's API directly. The admin panel pulled a configuration class out of another module. Nothing was broken, and the code still did not match how the rest of the codebase is built.

That kind of drift is what a coding agent produces when a long CLAUDE.md is the only thing steering it. Before I settled on the process in this piece, I saw it constantly: features built in slightly different shapes, imports leaking between modules, instructions skipped once the file got long, and decisions made in a chat that the next session never saw.

The Codyssey backend is a Laravel 13 and Statamic v6 app, and its CLAUDE.md is 63 lines. Its main instruction about standards is one sentence: "Do not restate rules elsewhere; edit the rule file." Everything else lives in files the agent reads at the stage where it needs them. This piece walks through those stages in order, with the social broadcasting feature as the example from the first idea to the merged fix.

Start with a sentence, then let the agent read the codebase

The idea started as one sentence: published content should go out to social media automatically, managed from the admin panel. I gave that sentence to /openspec-explore. OpenSpec is a set of commands that keeps a feature's plan as files in the repo, and explore mode is the step before any of those files exist. OpenSpec describes it as "a thinking partner for exploring ideas, investigating problems, and clarifying requirements."

In explore mode, Claude reads the codebase and the docs before it suggests anything. We compared social media APIs there (Zernio, Postiz, Mixpost and Ayrshare), and I cut scope before a plan was written: AI-generated copy and YouTube were both deferred. Very little of that conversation reaches the repo. Only its outcome lands in the plan, in lines like this one from the design: "The user accepted Zernio knowingly; this design contains that risk behind a gateway contract."

The goal that came out of exploring:

The goal is that publishing content is the only action a human takes, and the social fan-out happens on its own.

The plan kept only a read-only admin dashboard. The human approval step was missing: the first design was "fully automated, no human approval gate", and that is what got built. It came back later, as the last stage shows.

Write the plan into the repo

/openspec-propose turns the explored idea into a change: a folder with a proposal (what and why), a design (how), a spec (what must stay true), and a task list. This is the broadcast change after it was archived, with a README.md that Codyssey adds:

TEXT
openspec/changes/archive/2026-09-03-broadcast-content-to-social/ ├── README.md ├── proposal.md ├── design.md ├── specs/social-publishing/spec.md └── tasks.md

openspec/config.yaml adds rules every new plan must follow. One of them: "Under Impact, name the owning bounded context and the top-level namespace kind." A bounded context is the part of the domain a piece of code belongs to, with its own vocabulary, and social publishing is one. That rule arrived after the broadcast plan, and the broadcast plan is part of why it exists: it put the module inside the member-facing application, which a later decision had to undo.

When a change adds a context or moves code between contexts, CLAUDE.md requires one more step: "Run /domain-design before /new-module, /new-slice or /admin when a change adds a context, an aggregate, a cross-context interaction, or moves a capability". Once the plan exists, I read and edit the files by hand, ask Claude to revise them, and run /domain-design review, which questions the plan one point at a time. A small change, like a bug fix or a single vertical slice (the set of files for one action) with no new terms, skips all of this. Part 2 covers planning.

Rules say what the code looks like, skills say how to build it

Two kinds of files steer the agent while it writes code. A rule states what the code must look like, and it loads by file path. A skill is a procedure for a recurring task, and it loads by task, either on its own or when I type its name.

The rules live in .ai/rules/: 21 files and an index. Each rule file lists the paths it covers in paths: frontmatter, and Claude Code loads it when the agent reads, edits or writes a matching file. The index repeats those globs in one table and is the fallback: CLAUDE.md says to "consult it before editing anything if rules did not auto-load". Two of its rows match the social publishing code:

  • .ai/rules/orchestrators-di.md applies to Codyssey/**, AdminPanel/**, Framework/**, ContentPublishing/** and SocialPublishing/**.

  • .ai/rules/vertical-slices.md applies to Codyssey/**, ContentPublishing/** and SocialPublishing/**.

Editing a file under SocialPublishing/ loads those two and the other files whose globs match. The rules for Filament admin resources and for paid-content access stay unread. The project's skills live in .claude/skills/.

For my other Laravel projects I keep a second pair that is not tied to any codebase: Kanon, a rulebook written with MUST and SHOULD, and the Kanon audit, which checks code against it. Kanon is written to "deliberately IGNORE the host project's own conventions", so it travels from project to project unchanged. The Codyssey repo uses neither; it has its own rules and its own reviewer. Part 3 covers Kanon and its audit, and part 4 covers how the Codyssey rule files are written.

Scaffold with project skills, never with make:*

CLAUDE.md has one line on how new code starts:

BASH
# Scaffold with /new-slice, /new-module, /admin; never php artisan make:* (ADR-021)

The artisan generators write files for the default Laravel skeleton, with an app/ directory this repo does not have. A slice's files are kept together in one folder, and /new-slice builds "the command/query, handler, controller, request, resource, event, and tests for one action" in the folder and shape the rules expect.

For a feature with an OpenSpec change, /openspec-apply-change works through tasks.md. The main session plans and reviews, and independent tasks go to parallel subagents (separate agent sessions the main one hands a task to), each in its own git worktree (a second checkout of the repo on its own branch), defined in .claude/agents/codyssey-implementer.md. In my setup, the subagents make every edit, Opus plans and reviews, Sonnet implements, and effort is always set to high. Before framework or package work, the agent checks the version-specific docs with the search-docs tool from Laravel Boost, an MCP server for Laravel projects. Part 5 covers implementation.

Run the gates in order and stop at the first failure

/preflight runs the checks in a fixed order: "Pint (dirty), PHPArkitect, PHPStan (level max), the parallel PHPUnit suite, then the codyssey-reviewer standards audit on the branch diff." It stops at the first failure, because a later gate passing means nothing while an earlier one fails. The first four are the commands CLAUDE.md lists:

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

Spin runs the commands inside the app's Docker container. CLAUDE.md says PHPStan "must run in the container, host PHP cannot boot the app". PHPArkitect checks architecture rules, such as which namespaces may import which; 7 PHP Code Quality Tools That Pay Off Years Later covers it and the other tools. CI runs the same four tools on every pull request, so a skipped local run still gets caught before merge. Before each release, /smoke-test walks the staging or preview environment site in a browser.

Review against your own rules, one auditor per family

The last gate, /codyssey-reviewer, checks the diff against .ai/rules/. 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 gets 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". Every finding must cite a rule: "No rule, no finding."

That reviewer produced the 14 findings from the introduction. Four of them:

Severity

Finding

med

A console command called the vendor's API directly

med

The admin panel pulled SocialPublishingConfig out of the container

med

Three tests compared against now() without freezing time

low

The Zernio exceptions had no shared base class

The reviewer checks standards only, and it says so: "This is the standards reviewer, distinct from /code-review". Bugs get caught by me reading the full diff and by the tests and PHPStan.

Fix, re-run, and repeat until nothing is left

Fixing the 14 findings took three review rounds, all in PR #715:

Round

What the review found

What happened

1

14 violations in code that worked

14 commits, each quoting its rule: 13 for the findings and one for docs drift. 8 tests failed along the way and were fixed.

2

All 14 resolved, plus 4 new low findings from the fixes

Two rule files disagreed about where one loop belonged. I chose, and 4 more commits followed.

3

No violations, one advisory note

A glossary term the fixes had added did not match the code. Fixed.

The PR merged with 19 fix commits and 5,651 tests passing locally. The disagreement in round 2 is the part I would not hand to the agent. One rule moved a loop out of a queue job and onto the model. The next review cited a different rule to move it off the model, and no rule said which one wins. I put it in a handler.

The gates have limits too. Early in the feature, the code read each post's image from a field called og_image, which 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 pull request merged.

Done means more than green checks. From CLAUDE.md: "A change that leaves docs describing the old behavior, or a learned rule that dies with the session, is not finished." When a session learns something durable, Claude records it in .ai/rules/ with Boost's record-rule tool, and I review the new rule in the pull request. Part 6 tells the three rounds in full.

Write down the decisions that outlive the change

When the work is done, /openspec-archive-change moves the change folder into openspec/changes/archive/ and offers to sync its spec into openspec/specs/, the record of what the system does now. A decision that outlives the change gets an ADR, an architecture decision record in docs/decisions/, written in the same change. The test in CLAUDE.md is whether "why not the obvious alternative" needed explaining during planning or review. Claude writes the ADR in full, and I approve it in the pull request.

ADRs are "never edited retroactively". When a decision changes, a new ADR carries the reasoning and the old one gets a single pointer line. Both mistakes in the original broadcast plan were corrected with new ADRs. ADR-023 put the human back in: every post is now reviewed in the admin panel before it goes out. A day later, ADR-025 moved the module out of the member-facing application, because "Two modules inside Codyssey/, the member-facing application, had no member actor at all." ADR-025 also replaced one part of ADR-023. ADR-023's decision text stayed as written, and its header gained one line:

MARKDOWN
# ADR-023: Social broadcast review gate **Status:** Accepted **Date:** 2026-09-03 Superseded in part by ADR-025: decision (b), the vendor call reached through `Framework\Events\SocialBroadcastPublishRequested` / `SocialBroadcastRegenerationRequested`, is replaced by commands dispatched directly against the context's own write model.

Where to start

Pick a rule the agent breaks often. Move it out of your CLAUDE.md into its own file in .claude/rules/, list the folders it governs in paths: frontmatter, and delete the line from CLAUDE.md.

Kanon and its audit are in the kanon/ folder of the skills repo. Its general/ folder has skills that work in any Laravel project, including a standards review for codebases that have their own conventions. Part 2, on planning, is the next read.