DEVELOPMENT.md in the repository — edit it there.Development
New here? Start with SETUP.md to get it running, then read CONTRIBUTING.md for the workflow.
cargo build # fast iteration (debug)
cargo test
cargo fmt && cargo clippy --all-targets --all-features -- -D warnings
pnpm run dev # engine + UI on a random seeded port pair
pnpm --filter slicer-engine-docs docs:dev # live docs site
sea-orm-cli migrate generate "my_migration" -d src/db # scaffold DB migrationDev servers run on a seeded port pair. pnpm run dev rolls a three-digit seed and serves the UI on 4<seed> and the engine on 5<seed>, with a work directory of its own — so a second worktree, a colleague on the same box, or an agent session never collides with yours. It prints the URL to open; the UI dev server proxies /api and /ws to the engine, so that one URL is all you need. Add -- --seed 742 to pin it, -- --ui-only / -- --backend-only for half the stack, and use pnpm run dev:web-slicer or pnpm run dev:desktop for the other runtimes.
Git hooks (autoformat on commit): pnpm install sets up Lefthook via the prepare script. On every commit it formats just the staged files so they already match CI — Prettier for ui/**/*.{ts,html,scss,css} and rustfmt for *.rs. Skip once with git commit --no-verify, or disable with LEFTHOOK=0 git commit.
See CONTRIBUTING.md for workflow, AGENTS.md for AI-agent guidance, and ARCHITECTURE.md for the long-form architecture overview (also rendered on the docs site).
G-code diagnostics: tools/gcode-analysis/ has Python scripts to measure and visualise sliced output — wall overlap, unfilled gaps, bead-width distribution, and layer/zoom renders.
Not sure what to check after a change? Ask the agent "what should I test?" — the test-changes skill replies with a short checklist for the platform you name (remote + web by default).
Common tasks
Add a CLI command. Create src/cli/commands/your_command.rs with a clap #[derive(Parser)] struct, implement it against the library API adapters, register it in src/cli/commands/mod.rs and the dispatcher, add CliError conversions, then check cargo run -- your-command --help. The command catalog and argument reference are in src/cli/README.md.
Add a database migration. Scaffold, implement up/down, then register in both places or it never runs:
sea-orm-cli migrate generate "your_migration_name" -d src/dbsrc/db/migrations/mod.rs— declare the module.src/db/migrator.rs— add it to themigrations()vector.
Add a slicing setting. Add the field to SlicingParams with an x-group, and it appears in the UI with no TypeScript change — the settings panel is schema-driven, and cache_fingerprint and profile resolution both walk the serialized struct by name. Regenerate with pnpm run gen-schemas (the schema is git-ignored). A brand-new group needs two more lines; see the progressive-disclosure instruction.
Implement a geometric operation. Use the Clipper2 API rather than reimplementing clipping, take and return SliceLayer or Paths, and cover the degenerate cases (empty paths, zero-area polygons, collinear runs) in tests. Which fill rule to use where is in src/core/README.md.
Verify across platforms. cargo test covers native; wasm-pack test --headless --firefox covers wasm; CI builds the cross-compilation targets. Use #[cfg(...)] for anything platform-specific, and check the wasm dependency split with cargo metadata --filter-platform aarch64-apple-ios-sim.
Architecture at a glance
The same engine runs in three different environments — on a server, compiled into the browser, and bundled into the desktop app — so the G-code is always identical no matter where you slice.
The UI selects its runtime mode at startup:
| Mode | Where slicing happens | When |
|---|---|---|
cloud | On your server | Default web build |
web | In your browser | web-slicer build |
native | On your desktop | Desktop app |
See Scene Engine and Slicing Pipeline for the contract.
References
RepRap G-code Wiki · Arachne Paper · Clipper2 · Marlin G-code · Klipper G-code · Tauri