Format, lint, and test Slabs apps in CI
Run formatting, static security scanning, Clippy, Rustdoc, and parallel tests locally and in GitHub Actions without missing auto-discovered slab files.
Run the 6-step slabs check gate
In v0.5.0, slabs check runs the complete verification pipeline in one command:
slabs check
# Or skip Rustdoc checks in an application repo:
slabs check --no-docs
slabs check executes six stages in order:
- Formatting check (
cargo fmt --all -- --checkplusrustfmt --edition 2021 --checkacross discoveredslabs/andjobs/files). - Static
[security]scanner across the workspace (auto-discovered throughcargo metadata). cargo clippy --all-targets -- -D warnings.RUSTDOCFLAGS="-D warnings" cargo doc --no-deps(unless--no-docsis passed).cargo test --doc.cargo nextest run(falling back tocargo testwhencargo-nextestis not installed).
What the [security] static scanner checks
Every slabs check and slabs doctor run inspects your crate and discovered slab files for six classes of bugs:
- String interpolation or
format!(insidesqlx::query*calls. - Unannotated
PreEscaped(HTML escapes without an explicit safety justification. unsafeblocks or missingunsafe_code = "forbid"inCargo.toml.- Hardcoded secrets or default keys in source files.
.unwrap()or.expect(in production handler code underslabs/andjobs/(outside#[cfg(test)]).- Slab files under
slabs/that have no co-located#[cfg(test)]module.
Run targeted checks on changed or single slabs
During active development, you do not need to wait for the full workspace suite after every edit. Target only the slabs you touched with --changed or --slab:
# Check only slabs modified since HEAD (or against a specific git ref)
slabs check --changed
slabs check --changed --base origin/main
# Check a single slab by <feature>/<action>
slabs check --slab rooms/create_room
Targeted mode runs formatting, the [security] static scanner, and cargo-nextest (or cargo test) scoped exclusively to the selected slab(s). That gives humans and parallel AI agents a sub-second feedback loop while iterating. Run the full slabs check gate before merging.
Catch full-table scans with slabs check --explain
Missing indexes hide inside passing unit tests because test tables hold only a few rows. Audit every static query plan before merge with --explain or --strict-explain:
# Warn on unintended full-table SCANs
slabs check --explain
# Fail CI if any unannotated full-table SCAN is found
slabs check --strict-explain
slabs check --explain boots an in-memory SQLite database from migrations/ (or schema.sql), extracts static SELECT and WITH queries from slabs/ and jobs/, runs EXPLAIN QUERY PLAN on each query, and reports any unintended full-table SCAN.
When a full-table scan is deliberate (such as reading a ten-row settings table or running a bounded admin export), document the reason directly above the query with an inline opt-out comment:
#![allow(unused)]
fn main() {
// slabs:allow-scan: lookup table holds fewer than 20 static plan tiers
let tiers: Vec<PlanRow> = sqlx::query_as("SELECT id, name FROM plan_tiers ORDER BY sort_order")
.fetch_all(ctx.db.reader())
.await?;
}
Audit PR route and auth contracts with slabs manifest
Generate a deterministic summary of every discovered route, HTTP method, authentication guard, referenced SQL table, background job, and co-located test without compiling or booting the server:
# Print a human-readable contract summary
slabs manifest
# Emit JSON or write a checked-in snapshot
slabs manifest --json
slabs manifest --write slabs-manifest.json
# Diff the current app contract against a saved snapshot or git ref
slabs manifest --diff slabs-manifest.json
slabs manifest --diff origin/main
In pull requests and CI, slabs manifest --diff <snapshot_or_git_ref> flags removed routes and marks authentication guard downgrades (for example changing require_admin to require_session, or dropping a guard altogether) with [SECURITY] so reviewers catch breaking API changes and auth regressions before merge.
Verify full-stack flows in parallel with slabs dev --ephemeral
When multiple AI agents or browser scripts test the same repo at once, sharing port 3000 and one local .db file causes collisions. Boot an isolated throwaway instance instead:
slabs dev --ephemeral
slabs dev --ephemeral creates a temporary SQLite database, applies migrations, seeds it from seeds.sql, binds an ephemeral loopback port (127.0.0.1:0), prints SLABS_EPHEMERAL_URL=http://127.0.0.1:<port> once ready, and deletes the temporary database and storage directory on exit. Agents can run parallel browser checks or curl smoke tests against their own SLABS_EPHEMERAL_URL without touching the shared development database.
Run slabs doctor for environment checks
Before deploying or opening a pull request, run slabs doctor:
slabs doctor
slabs doctor verifies your Rust toolchain, unsafe_code = "forbid", schema.sql, .dockerignore, SLABS_ENV and SLABS_SECRET_KEY rules, and prints a summary of the [security] static scan.
Format both src/ and auto-discovered slabs/ and jobs/
slabs-build writes $OUT_DIR/discovered_slabs.rs with #[path = "..."] attributes pointing to files under slabs/ and jobs/. Because cargo fmt does not expand include! from OUT_DIR, running cargo fmt alone skips every file in slabs/ and jobs/.
Use slabs fmt:
# Format in place
slabs fmt
# Check in CI without modifying files
slabs fmt --check
If you run in an environment without the slabs binary on PATH, run cargo fmt followed by rustfmt:
mise exec -- cargo fmt --all -- --check
mise exec -- rustfmt --edition 2021 --check slabs/*/*.rs jobs/*.rs
Configure the two-tier Clippy policy
Slabs separates lint strictness between framework crates and application crates:
| Scope | Configured lints |
|---|---|
Framework crates (crates/*) | unsafe_code = "forbid", missing_docs = "warn", missing_debug_implementations = "warn", unreachable_pub = "warn", rust_2018_idioms = "warn", and clippy::pedantic. |
Application crates (slabs new app) | unsafe_code = "forbid", dbg_macro = "warn", todo = "warn", unimplemented = "warn", await_holding_lock = "deny", and await_holding_refcell_ref = "deny". |
Generated applications put these lints directly in Cargo.toml:
[lints.rust]
unsafe_code = "forbid"
[lints.clippy]
dbg_macro = "warn"
todo = "warn"
unimplemented = "warn"
await_holding_lock = "deny"
await_holding_refcell_ref = "deny"
Enforce permissive licenses and advisories with deny.toml
The Slabs workspace ships a root deny.toml for cargo-deny that checks RustSec advisories, restricts crate sources to crates.io, and enforces MIT-compatible licenses:
cargo deny check
Share rules with agents via AGENTS.md and CLAUDE.md
Put your formatting, security scan, Clippy, Tailwind, and cargo nextest commands in AGENTS.md, then add a one-line CLAUDE.md at the repo root:
@AGENTS.md
See Use Slabs agent skills in your workflow to pair those always-on rules with the four Slabs skills.
Run isolated tests with cargo-nextest
Every slab test boots an isolated in-memory SQLite database (sqlite::memory:) and a unique temporary storage directory through crate::test_app().await. Run the suite with per-test process isolation:
mise exec -- cargo nextest run
Rebuild Tailwind CSS v4 before committing UI changes
Tailwind CSS v4 scans slabs/ via @source "../slabs"; in assets/input.css. Whenever you add new utility classes to a slab, recompile assets/styles/app.css:
slabs css
GitHub Actions workflow template
slabs new app generates a least-privilege .github/workflows/ci.yml with permissions: { contents: read }:
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
check:
name: Format, Clippy, and Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- uses: taiki-e/install-action@nextest
- name: Check formatting
run: |
cargo fmt --all -- --check
rustfmt --edition 2021 --check slabs/*/*.rs
- name: Clippy
run: cargo clippy --all-targets -- -D warnings
- name: Tests
run: cargo nextest run