/laravel-port-skills:port-laravel-to-gofrom laravel-port-skills
Ports Laravel PHP applications to Laravel for Go, mapping routes, models, controllers, jobs, migrations, and Inertia frontends to idiomatic Go equivalents.
Ships in laravel-port-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
Laravel for Go keeps Laravel's vocabulary (routes, handlers, models, migrations, queues, events, Inertia) but is idiomatic Go underneath:
func(r *web.Request) *web.Response, and r is also a context.Context.web.Fail(err), web.Abort(status)), not exceptions.config.From(ctx), services.From(ctx), auth.User[T](ctx)) and one plain
Services struct.Rules() with validation.For).So a port is a re-expression, not a transliteration. Carry the app's behaviour and
data across exactly; let the code take the Go framework's shape. A port that recreates
PHP patterns in Go fights the framework at every step. Typical signs: a global registry
standing in for the container, map[string]any everywhere instead of structs, panic
where PHP threw, or service locators instead of Services.
Never invent framework APIs. The framework is new and not in your training data.
references/concept-map.md is the verified mapping. When something isn't there, read
the installed docs and source (see "Finding the framework") before writing the call.
If it genuinely doesn't exist, record it as a gap; don't fake it.
Behaviour parity beats code parity. Same routes and URLs, same status codes, same JSON shapes, same validation messages, same database schema, same queue semantics. Users and API clients must not notice the swap.
Keep the database. Port migrations so the Go app produces the same schema, and confirm the Go models read the existing production data. Never plan a data rewrite unless the user asks.
Keep the frontend. The Inertia pages (React, Vue or Svelte) carry over, but:
<script data-page="app" type="application/json">). An app on @inertiajs/* v1 or v2 renders a blank page
while every Go test passes. Bump the client to ^3, adapt the pages to the v3 API,
and look at the rendered HTML (better: a browser) before calling the frontend done.head is rejected (the framework reserves it).Blade has to be ported to the framework's templates (see the concept map).
Explicit registration is a parity trap. An unregistered job fails at dispatch; an
unregistered listener is silently never called. After porting jobs, listeners,
commands or morph types, check each one appears in its slice wired in
bootstrap/app.go.
Work in vertical slices that build and pass tests, not a big-bang rewrite.
Two sources, in this order of authority:
.agents/skills/:
writing-laravel-go-apps, database-and-models, validation-and-input,
auth-and-authorization, queues-and-workflows, testing-laravel-go-apps and
inertia-frontend. It also ships a locator script,
.agents/skills/writing-laravel-go-apps/scripts/docs-path.sh
(go list -m -f '{{.Dir}}/docs' go.laravel.com). Read those skills once after
scaffolding and use the installed docs for every API detail; the source is in the
same module directory.references/concept-map.md in this skill: the PHP → Go index, built from
go.laravel.com v0.1.0 (commit e149f59). It tells you which feature and doc to
look at and what doesn't exist. When it disagrees with the installed docs or source,
the installed version wins. Note the disagreement in your report.Getting the module: the framework repo may be private. The skeleton's go.mod can
carry replace go.laravel.com => ../go-framework, which needs a framework checkout next
to the app. Otherwise set GOPRIVATE=go.laravel.com with git credentials for GitHub,
because go.laravel.com redirects to github.com/laravel/go-framework. Check
go list -m go.laravel.com resolves before porting.
bash <skill-dir>/scripts/inventory.sh /path/to/php-app > PORT_INVENTORY.md
It lists:
Read it, then read the code behind anything non-trivial.
Record the PHP baseline before anything else: run the PHP test suite and dump the
schema from a fresh php artisan migrate into a scratch database. If the PHP repo must
stay untouched, set LOG_CHANNEL=stderr VIEW_COMPILED_PATH=<scratch>, point
DB_DATABASE at a scratch database, and use --cache-directory=<scratch> for Pest.
Common baseline blockers:
composer install --ignore-platform-req=php.DB_DATABASE=:memory:.--order-by=reverse.composer update nesbot/carbon -W in a
throwaway copy. A phpunit bootstrap that preloads
Illuminate\Session\ArraySessionHandler fixes the session-start deprecation.php -d display_errors=stderr artisan ... whenever you parse artisan output,
so deprecations can't corrupt JSON on stdout.When the PHP suite is thin, write characterisation tests in PHP first, run them green against the PHP app, then port them.
Create PORT_PLAN.md next to the Go app (don't write into the PHP repo unless asked):
Show the plan to the user before writing Go when the app is bigger than a handful of routes, or when there are blockers. Gaps are their call, not yours.
laravel new <app> --go
Without the laravel CLI (don't pipe an installer into a shell without the user's OK),
clone the skeleton (github.com/laravel/go), delete its .git, and run every
laravel <cmd> as go run . <cmd>. The module is always named app. Then copy
.env.example to .env, set APP_KEY, copy APP_URL from PHP (it's used for absolute
URLs), and npm install.
Database driver: list sqlite.Driver or mysql.Driver in place of
postgres.Driver in bootstrap/app.go, import go.laravel.com/db/sqlite or
go.laravel.com/db/mysql, and run go mod tidy. The skeleton's go.sum lacks the
SQLite driver (modernc.org/*, about 10 modules), so this step needs network: with
GOPROXY=off it fails with module lookup disabled. Inside a macOS sandbox Go's TLS to
proxy.golang.org can fail (x509: OSStatus -26276); run it outside the sandbox, or pre-warm
GOMODCACHE with go mod download modernc.org/sqlite. Then set DATABASE_URL:
sqlite:storage/database.sqlite (relative to the app), or
sqlite:///abs/path for an absolute path.mysql://… or mariadb://…. Use mariadb:// for MariaDB, so the
query builder writes SQL MariaDB accepts.Strip the skeleton's examples before porting, or they pollute route and schema parity. The concept map's "Skeleton contents to strip" lists them: example routes, handlers, events, listeners, jobs, pages, schedules and tests. Check the skeleton's shared Inertia props for keys that collide with the PHP app's page props. Two routes don't come from route files:
ANY /storage/{fallback...} and ANY /storage/private/local/{fallback...} are mounted
for every local disk with a Mount. Drop the ones PHP doesn't have in Options.Configure:
Configure: func(cfg *config.Config, env *config.Env) {
for name, d := range cfg.Filesystems.Disks {
if l, ok := d.(config.LocalDisk); ok { l.Mount = ""; cfg.Filesystems.Disks[name] = l }
}
},
GET /up: leave Routes.Health empty for apps on Laravel 10 or earlier, which have no
health route.Non-React frontends (Vue, Svelte). Replace the skeleton's React toolchain
(package.json, lock file, Vite/Tailwind config, tsconfig) with the PHP app's own,
and copy resources/js and resources/css across. Point the root view at the app's
entry, and drop the React refresh preamble. Rename resources/js/Pages to pages and
fix the glob in app.js/ssr.js: the framework's test helper only looks for page
components in lowercase resources/js/pages. Then do the Inertia v3 bump.
API-only apps. Remove the frontend (resources/ except mail views, package.json,
Vite, tsconfig, the Inertia middleware, web routes, the session guard if unused).
Register the API routes under the same prefix and middleware group.
Each step should build (go build ./..., go vet ./...) before the next one starts.
config/*.php keys the app reads → the typed config the
framework exposes, plus app options in bootstrap/app.go. Only port what's used.db.Migration{Name, Run}) per PHP migration,
registered in migrations.All. Keep the same tables, columns, types, indexes and
foreign keys. Migrations are forward-only, so drop PHP's down() bodies.
migrations table is identical to PHP's. If you keep the PHP filenames as
migration names, an existing database treats them as already run. That's what you
want for app tables, and a trap for framework tables (next point).cache, sessions, jobs and job_batches use timestamp columns where PHP
uses integer epochs.failed_jobs uses job_id/error.job_batch_jobs, and no password_reset_tokens or
notifications table.PRAGMA table_info/index_list/
foreign_key_list per table on SQLite (or information_schema), not raw
.schema text, which is full of cosmetic noise.DB_TIME_PRECISION=0 gives
byte parity with PHP's stored values.ID field and the framework's generic query
functions. Map $casts to field types (see the Casts section), and declare
relationships the framework's way. There's no $fillable/$guarded, accessors or
mutators, global scopes, observers or model-level soft deletes (details below).client.Create[M](f, states...) are func(*M); the factory definition's own states
take (*factory.Faker, *M). Creating a parent inside a state fails with
db: a nested transaction…: create parents first, then set the foreign key in a state.
PHP's ->for(), ->has() and ->hasAttached() become "create parent, create child,
insert join rows".Services struct, built in services.New, read with services.From(ctx).
Stateless domain logic → plain functions taking ctx.auth.Ability).FormRequest → an input struct with
Rules() validation.Rules built with validation.For and rule.Field(&f.X, ...),
read with r.Validate[T](). Query strings use r.Query[T](). The framework's
messages and 422 body follow Laravel's English wording and shape, but check the
Laravel version (below).handlers/<resource> with Index, Show, Create, Store, Edit, Update and
Destroy. Keep every URI, method, route name (.Name(..); resources are named
automatically) and middleware. Bind models explicitly in the handler
(model.FromRoute[T](r, "post")).terminate() →
r.OnFinish.tests.New(t), the HTTP client (client.Get, client.PostJSON, ...) and
subsystem fakes (queuetest, mailtest, ...).go build ./..., go vet ./... and go test ./... green.
Route parity: go run . route:list --json (or laravel route:list --json)
against php artisan route:list --json. The Go list shows GET|HEAD /up first. It
also shows /broadcasting/auth, /_workflow/resume and the storage mount when those
features are on. The PHP list has package routes (Inertia devtools, storage/{path},
/mcp).
Schema parity: the diff from step 4.2.
Inertia pages: compare the data-page JSON per page.
Behaviour parity: every PHP feature test has a Go counterpart with the same assertions.
Route parity script: python3 -I scripts/parity/routes.py diff php-routes.json go-routes.json --ignore '^/(_ignition|sanctum|up$)'
reads both formats (PHP's method/action keys and leading deprecation noise, Go's
methods), lists missing and extra routes, and compares names and middleware by short
name. Middleware names differ by design; read that part, don't expect zero.
Prove the tests can fail: python3 -I scripts/parity/mutate.py mutants.json -- go test ./... -count=1.
Write 5–10 mutants (file, old, new, label) that each break one behaviour
(a policy, a filter, a validation rule, an expiry check). Every mutant should be
KILLED. NO-BUILD is not a survivor: rewrite the mutant until it compiles. A
SURVIVED mutant is either a missing test (write one) or equivalent (say why). The
script always restores the file.
Side-by-side replay: required for any app with API clients; it's the only check
that catches byte-level JSON differences. scripts/parity/ runs in-process on both
sides, so it needs no servers or ports:
fixture.sqlite in a parity dir. Copy it to php.sqlite for PHP before each
PHP run; the Go template copies it to go.sqlite itself on every run.requests.json: every endpoint, including the error paths (validation,
401, 403, 404, 405, unknown route), signed in and anonymous, plus Unicode and
HTML in inputs (escaping differs).php -d display_errors=stderr scripts/parity/replay.php <php-app> requests.json tokens.json > php.json.
Use PARITY_ENV for the PHP app's database and drivers, and PARITY_AUTH_SCHEME
for the token prefix.scripts/parity/replay_test.go to tests/parity/replay_test.go unchanged and
run PARITY_DIR=... PARITY_APP_KEY=... PARITY_GO_ENV="DB_TIME_PRECISION=0,..." go test ./tests/parity -run Replay -count=1.
It writes go.json.python3 -I scripts/parity/compare.py php.json go.json --mask ... and fix every
STATUS/TYPE/BODY/BYTES-ONLY line until it reports 0.Mask only truly volatile values (issued tokens, "now" timestamps), and check those
separately. With token auth, issue tokens with PHP and use them on both sides, and
check that a Go-issued token passes PHP:
php -d display_errors=stderr scripts/parity/token_check.php <php-app> <go-token> /api/user
should print 200. Any other ad-hoc PHP script on a newer PHP needs the
@class_exists(Illuminate\Session\ArraySessionHandler::class); line that both PHP
scripts carry, or its first request 500s.
Report what passed, what didn't, and every gap still open. Don't call a slice done because it builds.
The framework encodes with encoding/json/v2. Compared with PHP's json_encode:
/ and non-ASCII raw, where PHP writes \/ and \uXXXX
unless the app sets JSON_UNESCAPED_* flags. Go also doesn't HTML-escape <>&. To
match PHP, use a small PHP-style encoder for the affected responses, or decide
explicitly to change it.[] under v2 (PHP's empty array is [] too). Check maps
and any omitempty/omitzero fields against PHP, which keeps null keys unless a
Resource used when()/whenLoaded().web.Raw. When you encode the body yourself (a PHP-style
encoder, pretty-printed bodies), return
&web.Response{Status: s, Header: http.Header{"Content-Type": {"application/json"}}, Body: b}.orderBy returns rows in the database's plan
order, not insertion order. Issue the same SQL shape Eloquent did (log it with
DB::listen), or the order can change.2026-12-02T00:47:05Z), not Carbon's
2026-12-02T00:47:05.000000Z. Format explicitly wherever clients see dates.when()/whenLoaded() must be omitted, not null.renderables) for custom shapes, such as
{"errors": {...}}, and pretty-printed or empty-message bodies, and reproduce each
one.Accept: application/json: PHP redirects (302) on validation
errors and can 500 on Route [login] not defined. Decide what Go does, and note it.With the same APP_KEY:
crypt payloads and encrypted columns, and bcrypt
$2y$ password hashes.MorphName() returning PHP's stored value (the class name, or the alias from the
morph map) to read existing rows.Verified against the framework docs and source; details are in the concept map.
.Name("posts.show")); resources are named
automatically. Keep every PHP route name so route('…') call sites map one to one.FormRequest runs before the
controller body, so PUT /posts/missing with an invalid body is a 422, not a 404,
and someone else's post is a 403 only once validation passed. Ported handlers naturally
load the model first. Keep PHP's order: validate, then firstOrFail, then authorize.
Rules that query the database (unique with ignore) also run before the 404.{"message":"Method Not Allowed"}. Laravel 9
says "The PATCH method is not supported for this route. Supported methods: …", Laravel
10+ says "…for route …". Reproduce it in Errors.Render from the error's Allow
header.lang/ overrides, differ. There are no pipe-string rules, no
prepareForValidation/after hooks, and no required_if/exclude* family; use
rule.When instead. For strict API parity, budget a small hand-written validator
that reproduces the PHP rules' order, bail behaviour and messages.deleted_at IS NULL: plain queries,
eager loads, whereHas, relation queries and route binding. restore and
forceDelete become plain updates and deletes. There's no automatic LIKE escaping,
so build '%'.$x.'%' the same way PHP did. There's no firstOrNew, firstOr,
syncWithoutDetaching, saveMany or withDefault: check, then write, inside a
transaction.password.confirm. There's no
Gate::define, no global before/after, and no can: middleware; policies are
auth.Ability.
authentication.md for request authentication.
Port the PHP lookup exactly (same table, same hash) so live tokens stay valid.favorited when a token is present):
auth.Via returns 401 for a nil user, and auth.User[T](ctx) panics when no guard
ran. Add one middleware to the API stack that resolves the token and stores the user
under its own context key. Protected routes then use
auth.Via(func(r) (*User, error) { return fromCtx(r), nil }), so their 401s stay
framework-rendered. ActingAs bypasses that middleware, so tests send real tokens.make:command, make:job and make:migration. Write
everything else by hand.WithoutOverlapping,
RateLimited, ThrottlesExceptions) and no ShouldBeEncrypted. Use cache locks or
a gap decision.mail.md for what ships and decide for the others.notifications table.laravel/ai support: hand-write it, proxy it to PHP, or drop it. Port
the tool's logic into plain functions either way, so it stays tested.app.html.
Static titles can move server-side (head.md); titles that react to page state stay
on the client.RateLimiter is a fixed window. Keep
PHP's user-facing message and note the difference.boot() defaults (Date::use, Password::defaults,
DB::prohibitDestructiveCommands, Model::shouldBeStrict): list each in the plan as
dropped or replaced.throw or abort(404) → return web.Fail(err), web.Abort(404) or
web.Invalid(..). Never panic.ctx first and returns an error. Handle
each one; don't discard it.app() → config.From(ctx), services.From(ctx) or the subsystem's
package function.Collection chains → loops or slices helpers. Carbon → time.Time, always UTC (there
is no app timezone setting).references/concept-map.md (about 3.5k lines): PHP → Go for every feature area, with
file locations, gotchas, doc pointers, parity notes, the "Not available" and
"Go-only" lists, commands, and the skeleton strip list. Read "Global truths", then
the table of contents, then only the sections you need. "NOT FOUND" items were
checked against docs and source; "source only" items exist but are undocumented.scripts/inventory.sh: step 1.scripts/parity/, used in step 5: replay.php, the replay_test.go template,
compare.py, routes.py (route diff), mutate.py (mutation check) and
token_check.php (does PHP accept a Go-issued token).references/concept-map.md (opens in a new tab)scripts/inventory.sh (opens in a new tab)scripts/parity/compare.py (opens in a new tab)scripts/parity/mutate.py (opens in a new tab)scripts/parity/replay.php (opens in a new tab)scripts/parity/replay_test.go (opens in a new tab)scripts/parity/routes.py (opens in a new tab)scripts/parity/token_check.php (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub alfonsocampodonico/laravel-port-skills --plugin laravel-port-skills4 skills in this plugin
/port-go-to-rustPort an existing Laravel for Go app (laravel/go, module go.laravel.com) to Laravel for Rust (laravel/rust, crate laravel-rust), any size. Use whenever someone wants to migrate, convert, rewrite or port a Laravel Go app, or part of one (a route, handler, model, job, migration, test suite), to Rust or "Laravel Rust", or asks how a Laravel Go feature maps to the Rust framework, even if they don't say "port"./port-laravel-to-rustPort an existing Laravel PHP application to Laravel for Rust (laravel/rust, laravel/rust-framework), any size. Use whenever someone wants to migrate, convert, rewrite, or port a Laravel/PHP app, or part of one (a route, model, job, controller, migration, test suite), to Rust or to "Laravel Rust", or asks how a PHP Laravel feature maps to the Rust framework, even if they don't say "port"./port-rust-to-goPort an existing Laravel for Rust app (laravel/rust, crate laravel-rust) to Laravel for Go (laravel/go, module go.laravel.com), any size. Use whenever someone wants to migrate, convert, rewrite or port a Laravel Rust app, or part of one (a route, handler, model, job, migration, test suite), to Go or "Laravel Go", or asks how a Laravel Rust feature maps to the Go framework, even if they don't say "port".Other plugins' skills for the same job