Development
- Introduction
- Running your application locally
- Managing Cargo build artifacts and disk space
- Developing with AI agents
Introduction
This guide covers your local development workflow: starting the server, reading errors, running the checks that keep a change shippable, and keeping Cargo's build artifacts under control. It also covers the built-in agent instructions and skills, and how to work with cloud agents.
A dust-framework application is a normal Cargo project. Everything you know about cargo build, cargo test, and cargo clippy applies; the dust command adds the application-aware shortcuts on top.
Running your application locally
Start the development server from your application's directory:
dust devdust dev runs the application's serve command through Cargo. It listens on 127.0.0.1:8000 by default. Visit http://127.0.0.1:8000 to see the welcome page, and stop the server with Ctrl+C.
Run your application's console commands through the dust CLI from any directory inside your project, such as dust migrate or dust route:list. The CLI compiles the application first and prints the compiler's output only when the build fails. In environments where the dust CLI isn't installed, run commands through Cargo instead:
cargo run -- route:listTo run the server without the CLI, use the same binary and command it uses:
cargo run -- serveThe development loop
dust dev starts the server and leaves it running; it does not watch the filesystem. After you change Rust code, configuration, or .env, stop the server and start it again. A normal edit-build-run cycle looks like this:
- Change a handler, route, view, or configuration file.
- Press Ctrl+C in the server's terminal.
- Run
dust devagain, orcargo run -- serveif you prefer.
Views are the exception: in debug mode, dust-framework reloads templates from resources/views on every render, so an edit appears on the next page refresh without a restart. In production, where debug mode is off, each view is compiled on first render and cached until the process restarts.
Keep a second terminal for commands. dust migrate, dust route:list, and your own commands each boot the application separately, so they see the code as it is on disk. They do not need the server to be running, and they do not share its state.
WebSockets
If your application broadcasts events over WebSockets, run the local Relay server in another terminal alongside dust dev after enabling dust-framework's relay feature:
dust relay:startTo learn more about configuring the local server, check out the WebSockets guide. In production, the relay usually runs as its own systemd unit, which dust restart restarts along with the cron daemon; see the commands guide.
Verification commands
Before opening a pull request or handing off a change, run your test suite, formatter, and linter to catch errors early:
cargo testcargo fmt --checkcargo clippy --all-targets -- -D warningscargo fmt without --check rewrites your files. Run it before committing, then use --check in CI so an unformatted file fails the build instead of being silently changed. cargo clippy uses the workspace's lint configuration, and -D warnings turns every warning into an error; the framework's own CI runs the same command.
To focus on one test or module while you iterate, pass a name filter to Cargo, such as cargo test posts. To run a single test exactly, add its full name; to see output from a passing test, pass -- --nocapture.
cargo test postscargo test posts::a_post_can_be_published -- --nocaptureTo learn more about writing feature tests and configuring your test database, check out the testing guide.
Debugging a request
When a page fails, start with the error page. In debug mode, it shows the error, its causes, the route, and the request, and the stack trace points at the line that failed. With debug mode off, the user sees a generic page and the details go to your logs.
Raise the log level for the run when you need to see what the framework did:
RUST_LOG=debug dust devFor a narrower view, name the targets you care about, such as the database and the request logger:
RUST_LOG=info,sqlx=debug,dust::request=debug dust devRUST_LOG takes precedence over LOG_LEVEL in .env, so you can turn detail on for one run without editing the file. The logging guide explains the filter syntax, and the tracing guide shows how to see where a slow request spent its time.
If the compiler rejects a handler with a message about not being able to handle requests, add #[dust::routing::debug_handler]. It names the exact argument or lock that the router can't accept.
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 dust-framework applications, switch between Git worktrees, or alternate between debug and release builds, compiled artifacts can grow to tens of gigabytes on disk. A few Cargo settings and habits keep that footprint predictable.
The shared build cache
By default, Cargo compiles a separate copy of every dependency inside each project's target/ directory. If you build three dust-framework applications on the same machine, Cargo would normally compile and store the entire dependency tree three separate times.
To avoid that duplication, point Cargo's intermediate build directory at a single shared location in .cargo/config.toml at the root of each application:
[build]build-dir = "{cargo-cache-home}/build/dust-framework"With this setting in place, Cargo stores compiled dependencies and intermediate artifacts in one shared directory under your Cargo cache home (~/.cargo/build/dust-framework 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 dust-framework 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. Do this if two applications need different versions of the same dependency, because a shared build directory assumes they resolve the same graph; when they don't, Cargo keeps the artifacts apart by hash, but the cache grows.
Faster, smaller development builds
Full debug symbols for every third-party crate make development builds much slower to link and far larger on disk. Trim debug information in Cargo.toml while keeping readable stack traces for your own code:
[profile.dev]debug = "line-tables-only"[profile.dev.package."*"]debug = falsedebug = "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.
These settings affect only development builds. cargo build --release uses the release profile, which optimizes for speed and strips debug information by default.
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:
cargo clean --dry-runTo clear only your current application's compiled artifacts while leaving compiled dependencies intact in the shared cache, pass --workspace:
cargo clean --workspaceIf you ran local production builds with cargo build --release and want to reclaim that space without affecting development builds, clean the release profile alone:
cargo clean --releaseWhen you want to wipe both your project's target/ directory and the entire shared build cache at ~/.cargo/build/dust-framework, run cargo clean with no flags:
cargo clean[!WARNING] Because
.cargo/config.tomlpointsbuild-dirat~/.cargo/build/dust-framework, runningcargo cleanwith no flags deletes the shared build cache for every dust-framework application on your machine. The next build of any application will recompile its dependencies from scratch. Usecargo clean --workspacewhen 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 updateproduces a new set of compiled artifacts alongside the old toolchain's artifacts. Runningcargo cleanonce 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 listand remove ones you no longer need withrustup toolchain remove <name>. - Enable only the Cargo features you use. Optional drivers in
Cargo.toml, such asdatabase-mysql,redis,s3, orsqs, 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 DUST Cloud handle release builds when you deploy.
- Keep an eye on Cargo's cache directories. Alongside
~/.cargo/build/dust-framework, 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
dust-framework's predictable directory layout, strong static typing, and built-in test helpers give AI coding agents the context they need to write idiomatic code. A project can add 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
dust new does not create these files for you; add them when you want an agent to follow your conventions. A common setup has two instruction files and a .agents/skills/ directory:
AGENTS.mdgives 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.mdimports@AGENTS.md, so tools that look for either file read the same instructions..agents/skills/holds Agent Skills that agents load on demand when working on specific areas of your application, such as:writing-dust-appshelps agents locate the installed framework docs, organize code by domain, write lean CRUD handlers and sub-resources, extract reusable action functions undersrc/actions/, and follow dust-framework idioms.database-and-modelscovers#[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-inputcovers typed body validation (Valid<T>and#[dust::input]), lenient query structs (Query<T>and#[dust::query]), required authorization attributes, and custom validation rules.auth-and-authorizationcoversAuthenticatableusers,#[dust::auth::page(...)]routes,Authenticated<User>,#[policy]structs, and compile-time-checkeduser.authorize(...)checks.queues-and-workflowscovers choosing between tasks, queued jobs, durable workflows, and events/listeners, declaring modules so attributes are discovered, deterministic workflow steps, and thin scheduled callbacks.testing-dust-appsguides agents through writing HTTP feature tests undertests/, usingrefresh_databaseand model factories, faking subsystems, and testing jobs, listeners, and scheduled logic directly.
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. Keep the verification commands in AGENTS.md identical to the ones your CI runs; an agent that can reproduce a failure locally can usually fix it before you look.
Version-matched framework documentation
Because dust-framework 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 dust-framework crate packages the complete Markdown guides for the exact version your application depends on. They live in the docs/ directory of the installed crate, under $CARGO_HOME/registry/src/<registry>/dust-framework-<version>/docs, or in the repository's docs/ when you depend on a path checkout.
Point the agent at <docs>/documentation.md and ask it to open the exact guide for the feature it is working on before writing code. You can browse the same directory yourself whenever you want to read the offline guides that match your application's installed version. The documentation guide explains how the guides are organized and how to read them offline.
Developing with cloud agents
You can build dust-framework applications locally on your laptop, and the shared build cache makes local iteration much smoother. Even so, the best day-to-day experience with dust-framework 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.
- Fast verification before you review. Rust's type checker,
cargo clippy, and dust-framework's isolated database feature tests give remote agents fast, objective feedback. Paired with project instructions you write, skills you add, and the version-matched docs, a cloud agent can implement a feature, runcargo test, 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 DUST 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.