/laravel-port-skills:port-go-to-rustfrom laravel-port-skills
Ports Laravel for Go apps (laravel/go) to Laravel for Rust (laravel/rust). Maps routes, handlers, models, jobs, migrations, and tests between frameworks while preserving behavior, database, and frontend.
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.
Both frameworks are Laravel re-expressed in a compiled language, from the same docs tree, so most features exist on both sides under similar names. The shape differs:
| Laravel for Go | Laravel for Rust | |
|---|---|---|
| Handler | func(r *web.Request) *web.Response | async fn with extractors, returns laravel::Result<impl IntoResponse> |
| Errors | return web.Fail(err), web.Abort(404) | ? on laravel::Result, return Err(abort(404)) |
| Dependencies | services.From(ctx) and one Services struct; no container | container: Inject<T>, laravel::resolve, singletons |
| Context | r / ctx passed explicitly to every call | Tokio task-local context, read implicitly |
| Registration | explicit slices in bootstrap/app.go | attribute macros and src/app.rs builder calls |
| Models | plain structs + generic functions (model.Find[T]) | #[model] structs with associated query methods |
| Validation | Rules() on the input struct | #[validate] input structs, Valid<T> |
| Routes | named with .Name(..) | no names: route!(handler) |
| JSON | encoding/json/v2 | serde_json |
| Async | goroutines, ctx cancellation | async/.await on Tokio |
So a port is a re-expression, not a line-by-line translation. Keep behaviour and data
identical; let the code take Rust's shape. Signs of a transliteration that fights the
framework: a hand-rolled Services struct passed around instead of Inject<T>, ctx
parameters threaded through every function, .unwrap() where Go returned an error,
HashMap<String, Value> where Go had a struct.
references/go-rust-map.md is the verified Go → Rust mapping. When something isn't
there, read the installed Rust docs and source (below) before writing the call. If it
doesn't exist, record a gap; don't fake it.resources/js, resources/css, package.json and vite.config.ts carry over as long
as handlers emit the same prop keys and model JSON. Server templates
(resources/views/*.html) must be rewritten from Go html/template to MiniJinja..agents/skills/writing-laravel-rust-apps/scripts/docs-path.sh
prints the docs of the exact laravel-rust version in Cargo.lock; the crate source
sits next to it in the cargo registry. The app's .agents/skills/ hold the framework's
own agent skills: read them once.go list -m -f '{{.Dir}}' go.laravel.com in the Go app gives the
installed module, with docs/ inside. The Go app's .agents/skills/ explain its
conventions.references/go-rust-map.md in this skill: built from go.laravel.com v0.1.0
(commit e149f59) and laravel-rust 0.1.4. Installed docs win when they disagree; note
the disagreement in your report.bash <skill-dir>/scripts/inventory.sh /path/to/go-app > PORT_INVENTORY.md
go run . route:list --json > source-routes.json # in the Go app
The inventory lists routes, handlers, middleware, models, services, jobs, events,
listeners, commands, migrations, seeders, factories, policies, tests, everything
registered in bootstrap/app.go, the app's own packages outside the framework layout,
the frontend, and non-framework Go modules (each needs a Rust crate or a rewrite).
Record the Go baseline: go test ./... green, plus a schema dump of a freshly
migrated scratch database (sorted PRAGMA table_info/index_list/foreign_key_list
per table on SQLite, information_schema elsewhere).
PORT_PLAN.md next to the Rust app:
Show the plan before writing Rust when the app is bigger than a handful of routes or has blockers.
laravel new <app> --rust, or clone github.com/laravel/rust, delete .git, and run
every laravel <cmd> as cargo run -- <cmd>. Copy APP_KEY and APP_URL from the Go
app's environment (same key = encrypted data and cookies keep working; check the map).
Pick the database feature in Cargo.toml to match the Go driver.
Strip the skeleton's examples (routes, handlers, pages, jobs, tests) before porting, or they pollute route and schema parity.
Frontend: copy resources/js, resources/css, package.json, the lock file and
vite.config.ts from the Go app, then port the root view (resources/views/app.html)
from Go template syntax to MiniJinja (the map's frontend section has each tag).
Each step compiles (cargo build, cargo clippy) before the next.
config.Config fields and Options.Configure → typed config sections.db.Migration, same names, same tables,
columns, indexes and foreign keys. Both are forward-only. Check the map's data section
for whether existing migration rows are recognised and for framework-owned tables.model: tags → #[model] structs. Nullable pointer
fields → Option<T>. JSON tags → serde attributes with the same keys.Services struct → container bindings resolved with
Inject<T>; plain functions taking ctx → plain functions (context is implicit).auth.Via, guards, auth.Ability → the Rust guard,
middleware and #[policy]. Port token lookups byte for byte so live tokens survive.Rules() input structs → #[validate] structs. Messages must stay
byte-identical; check the map for wording and rule-order differences.route.URL("name", ..) call site to route!(handler, ..).src/app.rs. An unregistered job or listener is a silent parity
bug on both sides: check every Go slice entry has its Rust registration.go test tests to #[laravel::test], same assertions.cargo build, cargo clippy, cargo test green.cargo run -- route:list --json > port-routes.json, then
python3 -I scripts/parity/routes.py diff source-routes.json port-routes.json --ignore '^/(up$|_workflow)'.
Go lists /up and names; Rust lists /_workflow/resume and no names, so expect
NAME lines and read the middleware lines.python3 -I scripts/parity/mutate.py mutants.json -- cargo test --quiet.
5–10 mutants that each break one behaviour; all must be KILLED. NO-BUILD is not a
survivor, rewrite it.fixture.sqlite (production-like data), requests.json
(every endpoint, error paths, signed in and anonymous, Unicode and HTML in inputs)
and tokens.json (tokens issued by the Go app, used on both sides).scripts/parity/replay_test.go to the Go app's tests/parity/ and run
PARITY_DIR=... PARITY_APP_KEY=... go test ./tests/parity -run Replay -count=1 → go.json.scripts/parity/replay_test.rs to tests/parity.rs and run
PARITY_DIR=... PARITY_APP_KEY=... cargo test --test parity → rust.json.
App-specific env goes in PARITY_GO_ENV / PARITY_RUST_ENV (K=V,K=V).
Each run copies fixture.sqlite fresh, so reruns are stable.python3 -I scripts/parity/compare.py go.json rust.json --mask ... until it
reports 0. Mask only volatile values (issued tokens, "now" timestamps) and check
those separately: a Rust-issued token must work against the Go app, and the reverse.Report what passed, what didn't, and every open gap.
Verified against both frameworks; details and evidence are in references/go-rust-map.md.
.Name(..), urls.Route(r, "x.y", ..),
RouteIs("admin.*") and {{route "x.y"}} becomes route!(handler, ..) /
redirect!(..) / a path check. Keep the Go names in the plan to map each call site.#[job], #[listener],
#[command] through inventory: a file without its mod line in lib.rs never
registers, and a lib not named app needs discover(env!("CARGO_CRATE_NAME")).
Check every entry of each Go slice has a Rust counterpart that actually registers.map[string]any keys in random
order and whole floats as 1; Rust (serde_json with preserve_order) writes
insertion order and 1.0. Go untagged struct fields are PascalCase; serde defaults to
snake_case. Use structs with explicit renames for every body, and integer types for
integral values.Find/First return a NotFound error (404
{"message":"Not Found"}); Rust find returns None, and route binding answers 404
"No query results for model Post with the key 42." in every mode, model name and
key included. Reproduce Go's body in the error renderer if clients see it. Debug error
keys also differ (error/trace vs error/file/line/causes).Option field is a 422 "The X field is
required." (Go used the zero value); rules skip null only on Option fields; the
Json<T> extractor answers 415 on a non-JSON Content-Type; validated inputs must
declare anyone, authenticated or authorize(..) or they don't compile.wants_json() reads only Accept. Go's ExpectsJSON is true on every API route.
Error rendering still returns JSON on API routes, but handler branches on it change.like is ILIKE on Postgres (use like_case_sensitive); each
filter(..) is parenthesised and ANDed, so build ORs inside one expression. A
non-optional BelongsTo fails to eager-load when the parent row is missing (Go gave
nil).db:seed runs only the default seeder in Rust (Go ran all of them in order). Add a
default seeder that calls the others. Go's factory For makes a parent per model; Rust
shares one.migrate takes no lock (don't run it from several pods at once)
and its table macros hard-code default names. The schema dump file is named after the
connection, not default-schema.sql.Services at startup and fails fast; Rust builds
singletons on first use, so a broken factory fails the first request. A
#[env(.., required)] config field fails startup of every command, key:generate
included.tokio::spawn loses the request context: use
laravel::task::spawn. A command that relied on ctx cancellation for Ctrl+C must call
console.trap_shutdown()..env keys keep the last value in Go, the
first in Rust. Rust's default QUEUE_CONNECTION is always database (Go: sync
without DATABASE_URL). The default SQLite path moves from storage/database.sqlite
to storage/app/database.sqlite: set DATABASE_URL explicitly.date.Now(ctx) uses the server location; laravel::now() is
UTC. Format strings move from Go layouts to strftime. JSON log lines nest
(request.id, fields{}), the daily file becomes laravel.YYYY-MM-DD.log, and
RUST_LOG overrides LOG_LEVEL: update log queries and alerts.html/template → MiniJinja ({{.Body}} → {{ inertia }},
{{vite "a.tsx"}} → {{ vite("a.tsx") }}). The JS frontend is unchanged.r.OnFinish, the number helpers and several queue assertions have no Rust
equivalent.With the same APP_KEY and the same database (details and evidence: the cutover
verdict table at the top of the map's section D):
$2y$, same cost), encrypted columns and crypt
payloads (byte-identical format; JSON payloads only if the field names and time formats
match), encrypted cookies, signed URLs (HMAC-SHA256 over the raw APP_KEY, if the route
paths stay), app-defined API tokens (neither framework owns a token format; port the
lookup byte for byte), feature-flag values, stored files, and the migrations table
(identical on both sides; keep the migration names identical and the history is adopted).cache, cache_locks, jobs, failed_jobs, job_batches,
job_batch_jobs, sessions, features, workflow tables) have identical DDL. Neither
side has a password-reset table."42", Rust as 42). Every user signs in once; open forms get a 419.signature in Go,
hash in Rust).….v1) and queued listeners. Drain the queues. User jobs
cross only if both sides pin the same job name (JobName() / #[job(name = ..)]) and
the same data field names (json tags / serde renames).CACHE_PREFIX explicitly on both sides, or flush.{"time"}, Rust {"timestamp"}).2006-01-02 15:04:05.999999999, Rust as
YYYY-MM-DDTHH:MM:SS.ffffff+00:00. Each reads the other, but once both formats share
a table, ORDER BY, > and = on those columns are wrong. Rewrite the column to the
new format in a forward migration at cutover. Postgres and MySQL are unaffected.if err != nil { return web.Fail(err) } → ?. Don't .unwrap() what Go handled.ctx parameters disappear: Rust reads the request context implicitly. Keep explicit
parameters only for real data.services.From(ctx).Mailer → Inject<Mailer> in handlers, laravel::resolve elsewhere.*string) → Option<String>; zero-value semantics ("", 0) stay
plain types. Decide per column from the schema.time.Time (always UTC) → the framework's Jiff types (also UTC).errgroup → tokio::spawn / futures::join!; never block the
runtime with sync IO inside a handler.references/go-rust-map.md: Go → Rust for every feature area, side-by-side code,
cheat-sheet rows, compatibility rows (what survives the cutover) and "NOT FOUND" lists
for both directions. Read its cheat sheets first, then the sections you need.scripts/inventory.sh: step 1 (detects Go or Rust).scripts/parity/: replay_test.go, replay_test.rs, compare.py, routes.py,
mutate.py, used in step 5.references/go-rust-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_test.go (opens in a new tab)scripts/parity/replay_test.rs (opens in a new tab)scripts/parity/routes.py (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-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-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