/laravel-port-skills:port-laravel-to-rustfrom laravel-port-skills
Ports Laravel PHP applications to Laravel for Rust (laravel/rust), preserving behavior, database schema, and Inertia frontends. Maps routes, models, controllers, migrations, jobs, and tests to idiomatic Rust using Axum and Tokio.
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 Rust keeps Laravel's vocabulary (routes, handlers, Eloquent-style models,
migrations, queues, events, Inertia) but is built on Axum and Tokio, with idiomatic Rust
underneath: extractors instead of controller classes, typed Inject<T> instead of
reflection autowiring, a Tokio task-local context instead of facades, #[model] structs
checked at compile time, #[validate] input structs, typed config sections, and
laravel::Result with ? instead of exceptions.
So a port is a re-expression, not a transliteration. Carry the app's behaviour and
data across exactly; let the code take the Rust framework's shape. A port that recreates
PHP patterns in Rust (god-classes of static helpers, stringly-typed config, empty service
structs registered as singletons, unwrap() where PHP threw) compiles but fights the
framework at every step.
Never invent framework APIs. The framework is new and not in your training data.
references/concept-map.md has the verified mapping. When something isn't there, read
the docs and source of the framework (see "Finding the framework" below) 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 Rust app produces the same schema, and confirm the Rust 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 check two things:
<script data-page> markup). An app
on @inertiajs/* v1 or v2 renders a blank page while every Rust test passes.
Bump the client to ^3, adapt the pages to the v3 API, and look at the rendered HTML,
or better a browser, before calling the frontend done.Blade has to be ported to the framework's templates (see the concept map).
Work in vertical slices that compile and pass tests, not a big-bang rewrite.
The framework moves fast; docs change between patch releases. Two sources, in this order of authority:
.agents/skills/
(writing-laravel-rust-apps, database-and-models, testing-laravel-rust-apps,
…) and a locator script:
.agents/skills/writing-laravel-rust-apps/scripts/docs-path.sh prints the docs
directory of the exact laravel-rust version in Cargo.lock. Read those skills
once after scaffolding and use those docs for every API detail. The crate source
is next to them in the cargo registry.references/concept-map.md in this skill: the PHP → Rust index. It tells you
which feature and doc to look at and what doesn't exist; it was built from one
framework version and may lag. When it disagrees with the installed docs or source,
the installed version wins. Note the disagreement in your report.Don't read a stray local rust-framework checkout instead of the installed version
unless you've confirmed they're the same version.
Run the inventory script from the PHP app's root:
bash <skill-dir>/scripts/inventory.sh /path/to/php-app > PORT_INVENTORY.md
It lists routes (via php artisan route:list --json when PHP is available, else the
route files), controllers, form requests, models, migrations, policies, jobs, events,
listeners, mail, notifications, commands, schedule, middleware, views, Inertia pages,
config files, Composer packages, and tests. Read it, then read the code behind anything
non-trivial: the inventory finds the files, it doesn't understand them.
Record the PHP baseline before anything else: run the PHP test suite
(php artisan test or vendor/bin/pest) and dump the schema from a fresh
php artisan migrate into a scratch database. These are what the port is measured
against. If the PHP repo must stay untouched, keep artisan and the tests from writing
into it: LOG_CHANNEL=stderr VIEW_COMPILED_PATH=<scratch>, DB_DATABASE=<scratch>.sqlite
(or a scratch database) for migrate, and --cache-directory=<scratch> for Pest.
Common baseline blockers:
composer install --ignore-platform-req=php.DB_DATABASE=:memory:.--order-by=reverse: if a
different test now fails, it's the environment, not the app.composer update nesbot/carbon -W in the throwaway copy fixes it. A phpunit
bootstrap that preloads Illuminate\Session\ArraySessionHandler fixes the
session-start deprecation for good.When the PHP suite is thin, write characterisation tests in PHP first, run them green against the PHP app, then port them. They are the cheapest parity proof there is.
Create PORT_PLAN.md next to the Rust app (or wherever the user wants; don't write
into the PHP repo unless asked) with:
references/concept-map.md.Show the plan to the user before writing Rust when the app is bigger than a handful of routes, or when there are blockers. Gaps are their call, not yours.
laravel new <app> --rust
Without the laravel CLI (don't pipe an installer into a shell without the user's OK),
clone the skeleton and drive it with cargo:
git clone --depth 1 https://github.com/laravel/rust.git <app> && rm -rf <app>/.git
cd <app> && cargo run -- migrate # every `laravel <cmd>` is `cargo run -- <cmd>`
Then: rename [package] name in Cargo.toml, copy .env.example to .env, set
APP_KEY (cargo run -- key:generate if the installed version has it, otherwise per
encryption.md), and npm install. The skeleton's .cargo/config.toml puts the build
dir under ~/.cargo; if that isn't writable (sandboxes), set CARGO_HOME to a writable
directory (config.local.toml can't override it).
Strip the skeleton's examples before porting, or they pollute route and schema
parity: the welcome handler, page and assets, the example event, listener, middleware
and channel, the sample API route (src/routes/api.rs), the hourly inspire
schedule, the web fallback route, the Sentry config (src/config/services.rs), and
their tests. Copy APP_URL from the PHP .env: route! builds absolute URLs from it.
Non-React frontends (Vue, Svelte). Replace the skeleton's React toolchain
(package.json, lock file, Vite and 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 (vite("resources/js/app.js")) and drop vite_react_refresh(). Rename
resources/js/Pages to pages and fix the glob in app.js and ssr.js: the
framework's test helper that checks a page component exists only looks in lowercase
resources/js/pages. With Pages/ the check is skipped without a warning on Linux.
Then do the Inertia v3 bump above.
API-only apps. Remove the whole frontend: resources/ (keep views/ only if
mail templates need it), package.json, Vite and tsconfig, the Inertia middleware,
web routes, and the session guard if nothing uses sessions. Keep public/favicon.ico.
Register the API routes with the same prefix (/api) and middleware group.
Check the skeleton's shared Inertia props too: it shares keys (such as status) that
can collide with the PHP app's page props.
Pick the database feature in Cargo.toml (database-postgres, database-mysql,
database-sqlite) to match the PHP app, and update the connection in
src/config/database.rs to match. Copy the relevant .env keys, and keep
APP_KEY only if you've confirmed the framework's encryption is compatible with the PHP
payloads (sessions and encrypted columns); otherwise plan a key rotation or a forced
re-login. The library is always named app, so imports start with app::.
Each step should compile (cargo build) before the next one starts.
config/*.php keys the app reads → typed
#[derive(Section)] structs with #[env(...)]. Only port what the code uses.laravel migrate on an empty database and diff the
schema against the PHP one (pg_dump --schema-only, mysqldump --no-data, or
sqlite3 .schema). The app's own tables should match exactly. The framework's own
tables (cache, jobs, failed_jobs, job batches, sessions) differ by design: timestamps
are datetime rather than integer epochs, failed_jobs has different columns, and
there are extra tables. Report those; don't try to make them match.
Shortcut: if the app runs on file, array, memory or sync drivers, keep the PHP
app's own framework-table migrations as they are and delete the skeleton's
0001_01_01_* ones. The schema is then identical and there's no migration-name
collision.
How to diff: .schema text is full of cosmetic noise (quoting, case, '0' vs
0). Compare sorted PRAGMA table_info/index_list/foreign_key_list per table
on SQLite, or information_schema on Postgres/MySQL.
Existing databases: the Rust app records migrations in the same migrations
table, so if its migration filenames match the PHP ones it will treat the framework
tables as already migrated and never create its own shape. Plan a forward migration
that drops and recreates the framework tables the app uses (with the DB-backed
cache, queue or session driver), or name the files differently on purpose. On SQLite
the framework writes RFC 3339 timestamps (2026-12-01T23:58:36+00:00) where PHP
wrote 2026-12-01 23:58:37. It reads both, but text sorting and comparison across a
mixed column break, so decide whether to normalise the existing rows.#[model] structs. Map $casts to Rust types (enums, JSON, timestamps),
relationships to their typed fields, scopes, accessors, $hidden / serialization,
observers to hooks or events. $fillable becomes fill structs.Inject<T>). Stateless domain logic → plain pub async fn in a module.FormRequest → #[laravel::input] structs with
#[validate(...)], taken as Valid<T>. Keep the error messages identical when API
clients depend on them.src/http/handlers/; each method an async fn whose arguments are extractors.
Keep every URI, HTTP method, route name and middleware. Resource controllers →
resource!.cargo build and cargo test green; cargo clippy clean.
Route parity: laravel route:list --json in the Rust app against
php -d display_errors=stderr artisan route:list --json, diffed with
python3 -I scripts/parity/routes.py diff php-routes.json rust-routes.json --ignore '^/(_ignition|sanctum|_workflow)'
(reads both formats; compares methods, URIs and middleware short names). Expect noise on both
sides: the PHP list has package routes (Inertia devtools, storage/{path}, /mcp),
and the Rust list always has /_workflow/resume but doesn't list the /up health
check (test /up with a request instead).
Inertia pages: compare the data-page JSON for each page. The Rust side adds a
head prop when the server sets the title; version only matches after
npm run build.
Schema parity: the diff from step 4.2.
Behaviour parity: every PHP feature test has a Rust counterpart with the same assertions. When the app has few tests, write characterisation tests against the PHP app first, then port them.
Prove the tests can fail. python3 -I scripts/parity/mutate.py mutants.json -- cargo test --no-fail-fast --quiet
applies each mutant (file, old, new, label: invert a condition, drop a filter,
loosen a policy), runs the tests and restores the file. Every mutant should be
KILLED; NO-BUILD is not a survivor, rewrite it. Keep --no-fail-fast: plain
cargo test stops at the first failing test binary and under-reports. A ported test
that can't fail proves nothing.
Side-by-side replay: required for any app with API clients; it's the only check
that catches byte-level JSON differences. The skill ships a harness in
scripts/parity/, in-process on both sides, so it needs no servers or ports:
fixture.sqlite in a parity dir (seed it, or copy production data). Copy it
to php.sqlite before each PHP run; the Rust template copies it to rust.sqlite
itself on every run.requests.json: every endpoint, including the error paths (validation, 401,
403, 404, 405, unknown route), signed-in and anonymous calls, and Unicode and HTML
in inputs.php -d display_errors=stderr scripts/parity/replay.php <php-app> requests.json tokens.json > php.json.
Set PARITY_ENV to point the PHP app at its copy of the database, and
PARITY_AUTH_SCHEME for the token prefix.scripts/parity/replay_test.rs to the app's tests/parity.rs unchanged and
run PARITY_DIR=... PARITY_APP_KEY=... PARITY_RUST_ENV="K=V,..." cargo test --test parity.
It writes rust.json.python3 -I scripts/parity/compare.py php.json rust.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. For token auth, issue tokens with PHP and use them on both sides: that
proves existing sessions survive the cutover. Also check that a Rust-issued token
passes PHP, for a period when both apps run:
php -d display_errors=stderr scripts/parity/token_check.php <php-app> <rust-token> /api/user
should print 200.
Report what passed, what didn't, and every gap still open. Don't call a slice done because it compiles.
Verified against the framework docs. Details and the full list are in the concept map.
route('posts.show', $post)
becomes route!(posts::show, &post). Drop ->name(), but keep the names in
PORT_PLAN.md so you can map every route('…') call site.down() or rollback, so drop the PHP
down() bodies. Migrations compile into the binary (build.rs).@push/@stack,
@can/@auth or view composers. Pass that data in from the handler instead. Apps on
Inertia skip most of this.JsonResource. Byte parity needs more than the same keys:
json_encode escapes / as \/ and non-ASCII as \uXXXX
unless the app sets flags. Clients that compare strings or signatures notice. Match
it with a small PHP-style encoder, or decide explicitly to change it.when()/whenLoaded() drop the key. Model that with
#[serde(skip_serializing_if = ...)], not null.toJSON prints 2026-12-02T00:47:05.000000Z. Set
DB_TIME_PRECISION=0 and format to match."message": ""), and renderable()s in
app/Exceptions/Handler.php reshape errors (RealWorld's
{"errors": {"field": [...]}} with 422). Read the handler and reproduce each shape.Accept: application/json: PHP redirects (302) on validation
errors and can 500 on Route [login] not defined. Rust answers JSON. Decide, and
note it.lang/ overrides, differ. There's also no equivalent for
validationData() wrapping with unprefixed keys. Typed input rejects PHP's loose
types before your rules run, and Query<T> answers a bad optional parameter with 400
where PHP gives 422 (and PHP reads a JSON body even on GET). For strict API parity,
budget a small hand-written validator that reproduces the PHP rules' order, bail
behaviour and messages. Use the framework's validation where messages don't matter.$fillable/$casts become fill structs and field types. Global scopes,
accessors/mutators, $appends, observer classes and dirty tracking don't exist.
Soft deletes are only a column helper, so every hidden PHP filter becomes an explicit
deleted_at check. Find each place PHP applied it implicitly: plain queries, eager
loads (.with(Rel.query(..))), whereHas (exists_where(..)) and relation queries.
Route-model binding without a filter behaves like PHP's withTrashed(). Rule::exists
ignores soft deletes on both sides. restore/forceDelete become plain updates and
deletes.
Search: contains() escapes % and _, unlike PHP's '%'.$x.'%'; for byte parity
use .like(format!("%{x}%")). Reading a relation you didn't eager-load panics, so eager
load explicitly.can: middleware. Password reset tokens live in the cache, not a table.
RequestGuard (see
authentication.md), but it can't read the request body, only runs on routes that
require login (no optional auth on public routes), and
laravel::auth::unauthenticated() is private. What works is a middleware on the API
group that resolves the user from the header, query or body into a request
extension, plus a small require_user middleware.APP_KEY, PHP-encoded JSON
claims) need byte-exact Rust code, quirks included (RealWorld sets iat == exp),
or every live token dies at cutover.#[policy]; user.can(..) returns a bool.Collection, Arr::, Str::of(). Use iterators and plain Rust. Carbon →
Jiff, and the app timezone is always UTC.make:* generators except make:migration. Write the files by hand.WithoutOverlapping/RateLimited job
middleware. Use cache locks or a gap decision.laravel/ai support. An app/Mcp server or routes/ai.php is a gap.
The options are a hand-written JSON-RPC handler, an MCP crate mounted as a service
(only if the installed framework can mount Tower services; check first), leaving that
path on PHP behind a proxy, or dropping it. Port the tool's logic into a plain
function either way, so it stays tested.@vite, @inertiaHead,
<x-inertia::head>, font directives) becomes resources/views/app.html. Titles move
server-side (the framework's head/with_head support; see head.md in the
installed docs). Static titles: set them server-side and drop the client
<Head title> and callback rather than setting them twice. Titles that react to page
state (<Head :title="form.name">) stay on the client. The server always adds a
head prop (its <title> defaults to APP_NAME).Redirect::back().with(..) and share
it from the Inertia middleware, so the flash prop keeps its shape. inertia::flash
produces a different prop shape.RateLimiter is a fixed window. Keep PHP's user-facing message (often a validation
error, not a 429), and note the algorithm difference.boot() defaults (Model::shouldBeStrict, Date::use,
Password::defaults, DB::prohibitDestructiveCommands) mostly have no equivalent.
List each in the plan as dropped or replaced; don't drop them silently.throw/abort(404) → return an error (laravel::Result, ?). Missing models via
route-model binding already give 404.app() → framework helpers (laravel::mail::to, laravel::config,
laravel::resolve) that read the task-local context, or Inject<T> in handlers.Collection chains → iterators. Carbon → the framework's time types.Option<T> per column from
the schema, not from guesswork.#[laravel::once],
context::add) instead of a global.references/concept-map.md: PHP idiom → Rust equivalent for every feature area, with
file locations, gotchas, doc pointers, the "Not available" list, Rust-only features
and CLI commands. It is long (~4.7k lines). Read its "Addenda from trial ports"
section first (lessons from three real ports, checked against 0.1.4), then the table
of contents, then only the sections for the area you are porting.
Items marked "NOT FOUND" were checked against the docs and source; items marked
"source only" exist but are undocumented, so read the source before using them.scripts/inventory.sh: the inventory in step 1.scripts/parity/, used in step 5: the in-process side-by-side replay (replay.php,
replay_test.rs template, compare.py), routes.py (route diff), mutate.py
(mutation check) and token_check.php (does PHP accept a Rust-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.rs (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
4 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-goPort an existing Laravel PHP application to Laravel for Go (laravel/go, laravel/go-framework, module go.laravel.com), 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 Go or to "Laravel Go", or asks how a PHP Laravel feature maps to the Go 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".npx claudepluginhub alfonsocampodonico/laravel-port-skills --plugin laravel-port-skillsOther plugins' skills for the same job