/laravel-port-skills:port-rust-to-gofrom laravel-port-skills
Ports Laravel for Rust apps (routes, handlers, models, jobs, migrations, tests) to Laravel for Go. Maps framework concepts between the two compiled-language Laravel re-expressions.
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 Rust | Laravel for Go | |
|---|---|---|
| Handler | async fn with extractors, returns laravel::Result<impl IntoResponse> | func(r *web.Request) *web.Response |
| Errors | ? on laravel::Result, return Err(abort(404)) | return web.Fail(err), web.Abort(404) |
| Dependencies | container: Inject<T>, laravel::resolve, singletons | services.From(ctx) and one Services struct; no container |
| Context | Tokio task-local context, read implicitly | r / ctx passed explicitly to every call |
| Registration | attribute macros and src/app.rs builder calls | explicit slices in bootstrap/app.go; nothing is discovered |
| Models | #[model] structs with associated query methods | plain structs + generic functions (model.Find[T]) |
| Validation | #[validate] input structs, Valid<T> | Rules() on the input struct, r.Validate[T]() |
| Routes | no names: route!(handler) | named with .Name(..) (opt-in) |
| JSON | serde_json | encoding/json/v2 |
| Async | async/.await on Tokio | goroutines, ctx cancellation |
So a port is a re-expression, not a line-by-line translation. Keep behaviour and data
identical; let the code take Go's shape. Signs of a transliteration that fights the
framework: a global registry imitating the container, map[string]any where Rust had a
typed struct, panic where Rust returned Err, goroutines spawned where Rust only
awaited sequentially.
references/go-rust-map.md is the verified mapping (written Go | Rust; read it right
to left). When something isn't there, read the installed Go 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. Rust props are snake_case
identifiers unless renamed: keep the exact keys in Go maps and json tags. Server
templates (resources/views/*.html) must be rewritten from MiniJinja to Go
html/template.bootstrap/app.go. An
unregistered job fails at dispatch; an unregistered listener is silently never called.go list -m -f '{{.Dir}}' go.laravel.com gives the installed module,
with docs/ inside; the app's .agents/skills/ hold the framework's own agent skills
(read them once). The framework repo may be private: the skeleton's go.mod can carry
replace go.laravel.com => ../go-framework, or set GOPRIVATE=go.laravel.com with
GitHub credentials. Check go list -m go.laravel.com resolves before porting..agents/skills/writing-laravel-rust-apps/scripts/docs-path.sh in
the Rust app prints the docs of the version in Cargo.lock; the crate source is next to
it in the cargo registry.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/rust-app > PORT_INVENTORY.md
cargo run --quiet -- route:list --json > source-routes.json # in the Rust app
The inventory lists routes, handlers, middleware, models, services, jobs, events,
listeners, console and schedule, config, migrations, seeders, factories, policies,
tests, src/app.rs registrations, the attribute macros in use (each one is a feature to
map), the app's own modules outside the framework layout, the frontend, and non-framework
crates (each needs a Go module or a rewrite).
Record the Rust baseline: cargo 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 Go app:
Show the plan before writing Go when the app is bigger than a handful of routes or has blockers.
laravel new <app> --go, or clone github.com/laravel/go, delete .git, and run every
laravel <cmd> as go run . <cmd>. The module is always named app. Copy APP_KEY and
APP_URL from the Rust app's environment (check the map for which encrypted data
survives). List the database driver matching the Rust feature (sqlite.Driver,
mysql.Driver, postgres.Driver) in bootstrap/app.go and run go mod tidy; the
SQLite driver needs network for that step.
Strip the skeleton's examples (routes, handlers, events, listeners, jobs, pages,
schedules, tests) before porting. Also clear the local disks' Mount in
Options.Configure if the Rust app serves no /storage/... routes, and leave
Routes.Health empty if it has no /up.
Frontend: copy resources/js, resources/css, package.json, the lock file and
vite.config.ts from the Rust app, then port resources/views/app.html from MiniJinja
to Go template syntax (the map's frontend section has each tag).
Each step builds (go build ./..., go vet ./...) before the next.
config.Config fields and Options.Configure.db.Migration{Name, Run} per Rust migration, same names, same
tables, columns, indexes and foreign keys, registered in migrations.All. Both are
forward-only. Check the map's data section for whether existing migration rows are
recognised and for framework-owned tables.#[model] structs → plain structs with model: tags. Option<T> →
pointer or nullable types. Serde renames and skips → json tags with the same
keys.Inject<T> → fields on the Services struct,
built in services.New, read with services.From(ctx).auth.Via and friends;
#[policy] → auth.Ability. Port token lookups byte for byte so live tokens survive.#[validate] structs → input structs with Rules(). Messages must
stay byte-identical; check the map for wording and rule-order differences..Name(..) only where Go code
needs route.URL.bootstrap/app.go.#[laravel::test] tests → go test with the skeleton's tests.New(t),
same assertions.go build ./..., go vet ./..., go test ./... green.go run . route:list --json > port-routes.json, then
python3 -I scripts/parity/routes.py diff source-routes.json port-routes.json --ignore '^/(up$|_workflow|storage)'.
Rust lists /_workflow/resume; Go lists /up and the storage mounts when enabled.
Read the middleware lines (names are compared case- and underscore-insensitively).python3 -I scripts/parity/mutate.py mutants.json -- go test ./... -count=1.
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 Rust app, used on both sides).scripts/parity/replay_test.rs to tests/parity.rs and run
PARITY_DIR=... PARITY_APP_KEY=... cargo test --test parity → rust.json.scripts/parity/replay_test.go to tests/parity/ and run
PARITY_DIR=... PARITY_APP_KEY=... go test ./tests/parity -run Replay -count=1 → go.json.
App-specific env goes in PARITY_RUST_ENV / PARITY_GO_ENV (K=V,K=V). Each run
copies fixture.sqlite fresh, so reruns are stable.python3 -I scripts/parity/compare.py rust.json go.json --mask ... until it reports
0. Mask only volatile values (issued tokens, "now" timestamps) and check those
separately: a Go-issued token must work against the Rust 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
(rows are Go | Rust: read them right to left).
#[job], #[listener], #[command],
seeder, migration and morph type the Rust app discovered must be added to its slice in
bootstrap/app.go. A missing listener is silently never called.route!(handler)); Go needs .Name(..) only
where code generates URLs (urls.Route, {{route ..}}). Resources are named
automatically.serde_json + preserve_order) writes keys in insertion
order and whole floats as 1.0; Go (json/v2, no options) writes map[string]any keys
in random order and floats as 1. Serde's snake_case keys must be spelled out in
json tags (untagged Go fields encode PascalCase). Use structs for every body.Post
with the key 42."; Go answers {"message":"Not Found"}. Rust find returns None;
Go Find/First/SelectOne return a *db.NotFoundError, so check db.IsNotFound(err) where Rust
matched on None. Reproduce Rust's body in Errors.Render if clients depend on it.rule.Required to every field Rust declared
non-Option. Go never answers 415 for a non-JSON body. Authorization on input structs
is optional in Go: port each authorize(..) to an Authorize(r) error method, or the
check silently disappears.ExpectsJSON is true on every API route in Go, while Rust's wants_json() read
only Accept. Handler branches on it change for clients without an Accept header.like was ILIKE on Postgres; Go's like is case-sensitive, so use
WhereLike(col, pat, false). Rust parenthesised each filter(..); Go's
OrWhere follows SQL precedence, so wrap groups in WhereGroup.db:seed runs all seeders in Go (Rust ran only the default). Register only the
seeders that should run, in order. Go's factory For creates a parent per model.migrate takes a lock and honours configured table names. The
schema dump is default-schema.sql.ctx;
goroutines get ctx passed in. Ctrl+C handling comes from ctx cancellation and
Signals(), not trap_shutdown..env keys keep the last value in Go (Rust
kept the first). Without DATABASE_URL Go defaults the queue to sync (Rust:
database). The default SQLite path moves from storage/app/database.sqlite to
storage/database.sqlite: set DATABASE_URL explicitly.laravel::now() was UTC; Go's date.Now(ctx) uses the server
location, so run Go with TZ=UTC or convert. strftime formats → Go layouts. JSON log
lines flatten (request_id), the daily file becomes laravel-YYYY-MM-DD.log, and
LOG_LEVEL replaces RUST_LOG.html/template ({{ inertia }} → {{.Body}},
{{ vite("a.tsx") }} → {{vite "a.tsx"}}). The JS frontend is unchanged.app.swap), the Inertia handler extractor, inertia::null(),
chop_start/chop_end, and the _where closure variants of fakes have no Go
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) } in handlers, return err elsewhere.
Never panic.ctx (or r) as the first parameter of every function
that touches the DB, cache, queue, mail or config.Inject<T> / laravel::resolve::<T>() → services.From(ctx).T.Option<T> → pointer or nullable type; plain types where Rust used plain types.time.Time (UTC).tokio::spawn / join! → goroutines with errgroup, passing ctx.slices helpers.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 (right to left), then the sections
you need.scripts/inventory.sh: step 1 (detects Go or Rust).scripts/parity/: replay_test.rs, replay_test.go, 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
laravel-rust, laravel-go, porting, migration, code-conversion
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-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-rustOther plugins' skills for the same job