Skip to content

Development

Getting Started

Development

Introduction

Day-to-day work on a Laravel for Rust application centers on a few tools: laravel dev for running your server, queue worker, and Vite together, Cargo for building and testing your backend, and the AI coding agents that can implement and verify features alongside you. Because Cargo compiles your dependencies from source, a few built-in defaults and habits make a large difference in how fast you iterate and how much disk space your machine keeps free.

This guide covers your local development workflow, how new Laravel applications keep Cargo build artifacts under control, and how to take advantage of the built-in agent instructions, skills, and cloud-agent workflows.

Running your application locally

When you work on an application locally, you usually want the web server, a queue worker, and Vite's asset server running at the same time. Start all three together with laravel dev:

1laravel dev
1laravel dev

While laravel dev runs, saving a file in src/, Cargo.toml, Cargo.lock, or .env rebuilds and restarts your server and queue worker, and refreshes your browser once the server is ready. Frontend edits in resources/ hot-reload through Vite, and template edits in resources/views/ reload the page automatically.

If you want to run a single process on its own, such as keeping Vite running while you restart the server by hand, use the individual scripts in package.json:

1npm run dev:server
2npm run dev:queue
3npm run dev:vite
1npm run dev:server
2npm run dev:queue
3npm run dev:vite

Run your application's console commands through the laravel CLI from any directory inside your project, such as laravel migrate or laravel route:list. In environments where the laravel CLI isn't installed, run commands through Cargo instead:

1cargo run -- route:list
1cargo run -- route:list

WebSockets

If your application broadcasts events over WebSockets, run the local Reverb server in another terminal alongside laravel dev after enabling Laravel's reverb feature:

1laravel reverb:start
1laravel reverb:start

To learn more about configuring the local server, check out the WebSockets guide.

Verification commands

Before opening a pull request or handing off a change, run your test suite, linter, and frontend checks to catch errors early:

1cargo test
2cargo fmt
3cargo clippy --all-targets
4npm run types:check
5npm run check
1cargo test
2cargo fmt
3cargo clippy --all-targets
4npm run types:check
5npm run check

To focus on one test or module while you iterate, pass a name filter to Cargo, such as cargo test posts. To automatically fix frontend lint and formatting issues, run npm run check:fix. To learn more about writing feature tests and configuring your test database, check out the testing guide.

Managing Cargo build artifacts and disk space

Cargo compiles every crate in your dependency graph from source, including the framework, database drivers, and async runtime. If you work on several Laravel applications, switch between Git worktrees, or alternate between debug and release builds, compiled artifacts can grow to tens of gigabytes on disk. New Laravel applications ship with two defaults that reduce that footprint right away, and a handful of Cargo habits keep disk usage predictable over time.

The shared build cache

By default, Cargo compiles a separate copy of every dependency inside each project's target/ directory. If you build three Laravel applications on the same machine, Cargo would normally compile and store the entire dependency tree three separate times.

To avoid that duplication, every new Laravel application includes a .cargo/config.toml file that points Cargo's intermediate build directory at a single shared location:

1[build]
2build-dir = "{cargo-cache-home}/build/laravel-rust"
1[build]
2build-dir = "{cargo-cache-home}/build/laravel-rust"

With this setting in place, Cargo stores compiled dependencies and intermediate artifacts in one shared directory under your Cargo cache home (~/.cargo/build/laravel-rust on macOS and Linux by default). Each application's own target/ directory stays small because it holds only your project's final binaries.

When you create a second Laravel application, or check out a new Git worktree for a feature branch, Cargo reuses the dependencies it already compiled. A fresh build compiles your application's own code in seconds instead of rebuilding the entire dependency graph and writing another gigabyte or more to disk.

If you'd rather keep an application's build artifacts isolated inside its own target/ directory, remove the build-dir line from .cargo/config.toml.

Faster, smaller development builds

Full debug symbols for every third-party crate make development builds much slower to link and far larger on disk. Every new application trims debug information in Cargo.toml while keeping readable stack traces for your own code:

1[profile.dev]
2debug = "line-tables-only"
3 
4[profile.dev.package."*"]
5debug = false
1[profile.dev]
2debug = "line-tables-only"
3 
4[profile.dev.package."*"]
5debug = false

debug = "line-tables-only" keeps file names and line numbers in panics and backtraces for your application without writing full variable debug tables. Setting debug = false for [profile.dev.package."*"] omits debug symbols for third-party crates altogether.

If you attach a native debugger such as lldb or gdb and want to inspect local variables inside your application, change debug = "line-tables-only" to debug = true while you debug, then switch it back when you're done.

Cleaning up build artifacts

Over time, updating Rust toolchains, upgrading dependencies, or switching feature flags leaves older compiled artifacts in your build cache. Before deleting anything, preview what cargo clean would remove and how much space it will reclaim:

1cargo clean --dry-run
1cargo clean --dry-run

To clear only your current application's compiled artifacts while leaving compiled dependencies intact in the shared cache, pass --workspace:

1cargo clean --workspace
1cargo clean --workspace

If you ran local production builds with cargo build --release and want to reclaim that space without affecting development builds, clean the release profile alone:

1cargo clean --release
1cargo clean --release

When you want to wipe both your project's target/ directory and the entire shared build cache at ~/.cargo/build/laravel-rust, run cargo clean with no flags:

1cargo clean
1cargo clean

Because .cargo/config.toml points build-dir at ~/.cargo/build/laravel-rust, running cargo clean with no flags deletes the shared build cache for every Laravel application on your machine. The next build of any application will recompile its dependencies from scratch. Use cargo clean --workspace when you only want to clean your current project.

Keeping Cargo caches lean

A few habits keep Cargo from filling your drive over months of work:

  • Clear the shared cache after Rust upgrades. Each rustup update produces a new set of compiled artifacts alongside the old toolchain's artifacts. Running cargo clean once after updating Rust removes the stale files right away.
  • Remove old Rust toolchains. If you install nightly or pinned toolchains alongside stable, list what's installed with rustup toolchain list and remove ones you no longer need with rustup toolchain remove <name>.
  • Enable only the Cargo features you use. Optional drivers in Cargo.toml, such as database-mysql, redis, s3, or sqs, each pull in additional crates. Removing features your application doesn't use trims both compile times and cache size.
  • Avoid local release builds unless you need them. Release builds compile a separate optimized copy of your entire dependency graph. Rely on development builds locally, and let your CI pipeline or Laravel Cloud handle release builds when you deploy.
  • Keep an eye on Cargo's cache directories. Alongside ~/.cargo/build/laravel-rust, Cargo stores downloaded crate archives and unpacked sources in ~/.cargo/registry. If disk space gets tight, inspect both directories to see where space has accumulated.

Developing with AI agents

Laravel's predictable directory layout, strong static typing, and built-in test helpers give AI coding agents the context they need to write idiomatic code. Every new Laravel application includes project instructions and focused agent skills that tell an agent where files belong, how your application is tested, and where to read the exact documentation for your installed framework version.

Project instructions and skills

At the root of every new application, you'll find two instruction files and a .agents/skills/ directory:

  • AGENTS.md gives coding agents a concise overview of your application's layout, verification commands, and conventions, including resource-oriented handlers, testing practices, and where new code belongs.
  • CLAUDE.md imports @AGENTS.md, so tools that look for either file read the same instructions.
  • .agents/skills/ holds seven Agent Skills that agents load on demand when working on specific areas of your application:
    • writing-laravel-rust-apps helps agents locate the installed framework docs, organize code by domain, write lean CRUD handlers and sub-resources, extract reusable action functions under src/actions/, and follow Laravel for Rust idioms.
    • database-and-models covers #[model] structs, typed column queries, eager-loaded relationships, forward-only migrations, framework table macros, and keeping each model's policy and factory in the same file.
    • validation-and-input covers typed body validation (Valid<T> and #[laravel::input]), lenient query structs (Query<T> and #[laravel::query]), required authorization attributes, and custom validation rules.
    • auth-and-authorization covers Authenticatable users, #[laravel::auth::page(...)] routes, Authenticated<User>, #[policy] structs, and compile-time-checked user.authorize(...) checks.
    • queues-and-workflows covers choosing between tasks, queued jobs, durable workflows, and events/listeners, declaring modules so attributes are discovered, deterministic workflow steps, and thin scheduled callbacks.
    • testing-laravel-rust-apps guides agents through writing HTTP feature tests under tests/, using refresh_database and model factories, faking subsystems, and testing jobs, listeners, and scheduled logic directly.
    • inertia-frontend guides agents through building Inertia v3, React, TypeScript, and Tailwind CSS v4 pages, forms, shared props, and Vite Plus assets.

Update AGENTS.md and .agents/skills/ as your application grows. Add notes about your domain terminology, custom services, and internal conventions so every agent session follows your team's patterns.

Version-matched framework documentation

Because Laravel for Rust evolves quickly, an AI agent that relies on memorized training data or web searches can guess outdated signatures or confuse APIs from other frameworks. To prevent that, the laravel-rust crate bundles the complete Markdown guides for the exact version your application depends on.

The writing-laravel-rust-apps skill includes a small helper script that prints the path to the installed documentation directory for your current Cargo.lock:

1.agents/skills/writing-laravel-rust-apps/scripts/docs-path.sh
1.agents/skills/writing-laravel-rust-apps/scripts/docs-path.sh

Agents run this script to read <docs>/documentation.md and open the exact guide for the feature they're working on before writing code. You can run the script yourself anytime you want to search or browse the offline guides that match your application's installed version.

Developing with cloud agents

You can build Laravel for Rust applications locally on your laptop, and the shared build cache makes local iteration much smoother. Even so, the best day-to-day experience with Laravel for Rust comes from leaning into cloud coding agents, such as Amp, Cursor, and Devin, and running several of them in parallel.

Rust's compiler catches a wide class of bugs before your code ever runs, though compiling large dependency graphs and running full test suites locally takes disk space, CPU, and time. Running that work in parallel cloud agents lets you keep the compiler's guarantees without fighting disk space or waiting on local builds:

  • No local disk space or hardware strain. Cloud sandboxes handle compilation, build caches, and test databases on remote machines, so you aren't constantly managing gigabytes of Cargo artifacts or listening to laptop fans spin while you work.
  • Parallel progress instead of waiting on builds. Rather than sitting through one compile-and-test cycle at a time on a single branch, you can assign three or four independent tasks to separate cloud agents at once, such as adding a resource endpoint, writing a background job, and updating an Inertia page, and review pull requests as they arrive.
  • Fast verification before you review. Rust's type checker, cargo clippy, TypeScript's type checker, and Laravel's isolated database feature tests give remote agents fast, objective feedback. Paired with AGENTS.md, .agents/skills/, and the bundled version-matched docs, a cloud agent can implement a feature, run cargo test and npm run check, resolve compiler or test failures on its own, and open a ready-to-review pull request.
  • Live review on every pull request. When you host your application on Laravel Cloud, preview environments build and deploy every pull request automatically. You can test an agent's work in a real browser at a live preview URL before merging, without even checking out the branch locally.

To get the most out of parallel cloud agents, keep your tests fast and self-contained using refresh_database and subsystem fakes, keep AGENTS.md current as your architecture grows, and split features into clear, independent tasks that agents can verify end to end.