Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Development setup

You need Rust, a handful of cargo tools, and on Linux a few system packages. Everything else (ONNX Runtime for the ears, wasm-bindgen for the web studio) is downloaded by the build itself.

Rust

Install rustup. rust-toolchain.toml at the root pins the Rust that CI and the releases build with (1.96.0), with rustfmt, clippy and the wasm32-unknown-unknown target, and rustup installs all of it the first time you run cargo in the repository. Your machine and CI run the same clippy, so its lints do not change under you. Moving to a newer Rust is a pull request of its own, with whatever its new lints ask for. The same goes for Ubuntu: the workflows run on ubuntu-24.04, the image the Linux releases are built on, and not on ubuntu-latest, which GitHub moves to each new release.

rust-version in Cargo.toml is the oldest Rust the workspace builds with: 1.96 too, because 1.95 cannot infer some of the types in claudius. The msrv job in CI checks it.

System packages

macOS: the Xcode command line tools (xcode-select --install), for the C and C++ that some crates compile (SQLite, signalsmith-stretch) and the clang runtime that ONNX Runtime links against.

Linux (Debian and Ubuntu; the list is what a bare ubuntu:24.04 needs on top of a compiler):

sudo apt install build-essential pkg-config libssl-dev libasound2-dev libclang-dev

pkg-config and libssl-dev let ort download ONNX Runtime at build time (only builds with the ears need them), libasound2-dev is ALSA for the studio’s audio output (only builds with the studio window), and libclang-dev is for the bindgen step of signalsmith-stretch. On Fedora: sudo dnf install gcc-c++ pkgconf-pkg-config openssl-devel alsa-lib-devel clang-devel. The native studio window also needs X11 or Wayland and OpenGL at run time, which any desktop has; no -dev packages are needed for them.

The Linux build needs glibc 2.38 or newer (Ubuntu 24.04, Debian 13, Fedora 39), because the ONNX Runtime library that ort downloads was built against it.

Windows builds are experimental and not checked yet: you need the Visual Studio C++ build tools and LLVM (for bindgen). Build without the ears there (below).

Features

claudius has two cargo features, both on by default:

  • ears: earshot’s listening models, through ONNX Runtime. Without it the verdicts use meters and music theory, claudius setup skips the models, and claudius doctor says “ears: not in this build”. ONNX Runtime has no build for Intel Macs, so they never get the ears, and the Windows build leaves them out until someone has run it there with them.
  • studio: the native studio window (egui). Without it claudius studio points you at claudius serve, which still serves the web studio, and the binary links no ALSA, X11 or OpenGL. That is the headless build for Linux servers.

Code that needs earshot goes behind #[cfg(feature = "ears")], the window behind studio. cargo xtask ci checks the builds without each of them, so a gated path cannot stop compiling unnoticed.

Tools

toolwhat it is for
trunk 0.21builds the web studio (WebAssembly)
cargo-nextestruns the tests; cargo xtask ci falls back to cargo test without it
mdBook 0.5builds this book
cargo-denychecks licences, advisories and where crates come from (deny.toml)
typosfinds misspellings (_typos.toml)
git-cliffturns commit messages into release notes (cliff.toml)
lycheechecks the links between the pages of the built site
actionlint, shellcheckcheck the workflows and the scripts in scripts/
gitleaksfinds secrets in commits before they leave your computer (.gitleaks.toml)
osv-scannerchecks the lockfiles against known vulnerabilities (osv-scanner.toml)
Node.js 24runs the website’s smoke test (Playwright)
dmgbuildthe Mac disk image’s window, in scripts/package/macos.sh: pip install --require-hashes -r packaging/macos/requirements.txt

All of them have prebuilt binaries. With cargo-binstall, which downloads those instead of compiling:

cargo binstall trunk cargo-nextest mdbook cargo-deny typos-cli git-cliff lychee

On macOS, Homebrew has all of them too:

brew install trunk cargo-nextest mdbook cargo-deny typos-cli git-cliff lychee actionlint shellcheck node gitleaks osv-scanner

Then turn on the repository’s git hooks, once per clone:

git config core.hooksPath .githooks

pre-commit checks the formatting and scans the staged changes for secrets with gitleaks; pre-push refuses a push to main, which changes only through pull requests.

Building each part

cargo xtask runs the repository’s chores; cargo xtask help lists them. The ones you need day to day:

commandbuildsinto
cargo buildevery crate (the dev profile is optimized, so songs render at a usable speed)target/debug
cargo build -p claudius-cli --no-default-features --features studioclaudius without the ears, as on Intel Macs and Windowstarget/debug
cargo build -p claudius-cli --no-default-features --features earsclaudius without the studio window: the headless buildtarget/debug
cargo xtask webthe web studio, with trunkcrates/claudius-ui/dist
cargo xtask web --plana web studio that runs the scripted plan in its page’s ?plan=, for the site’s end-to-end tests only (the ones that drive the studio, such as record.spec.mjs, download.spec.mjs and phone.spec.mjs; a link could otherwise drive it, the microphone included)target/studio-plan
cargo xtask docsthis booktarget/book
cargo xtask sitethe website: the landing page, the book at /docs/, the studio at /studio/ and the install scripts; --sounds also makes the instruments the studio’s demo plays into /studio/packs/, as the deploy does (web editions of the packs’ pianos, strings, guitars, basses and drum machines, claudius-packs web), downloading the notes they keep into target/demo-soundstarget/site
cargo xtask dista release archive for this machine, as the release workflow builds it (--headless for the Linux server build, --no-ears without the ears)target/dist

The first build downloads ONNX Runtime (about 120 MB) for earshot, into ~/Library/Caches/ort.pyke.io on macOS and ~/.cache/ort.pyke.io on Linux.

For the docs and the site there are live previews: mdbook serve docs rebuilds the book on every save at http://localhost:3000, once cargo xtask docs has written the book’s list of libraries (credits/libraries.md, from Cargo.lock, which git leaves out: without it mdbook stops at a missing chapter); and node site/tests/serve.mjs serves target/site the way Cloudflare does (headers, redirects, the 404 page) at http://127.0.0.1:4321.

Running the studio from source

cargo xtask web                                  # the web studio, once and after changes to the UI
cargo run --release -p claudius-cli -- setup     # the sample packs and the listening models, once (about 4 GB)
cargo run --release -p claudius-cli -- studio    # the native window, with the engine inside
cargo run --release -p claudius-cli -- serve     # or the studio in the browser at http://127.0.0.1:7878

A claudius built in a checkout serves the web studio from crates/claudius-ui/dist of that checkout.

When you work on the UI, NO_COLOR=true trunk serve in crates/claudius-ui rebuilds it on every save and serves it at http://127.0.0.1:8090. Open http://127.0.0.1:8090/?server=http://127.0.0.1:7878 to drive a claudius serve running next to it, or http://127.0.0.1:8090/?mock for the demo that needs no server. (NO_COLOR=true because trunk rejects the common NO_COLOR=1; cargo xtask web sets it for you.)

Before you push

cargo xtask ci runs what every pull request has to pass first: cargo fmt --check, clippy with warnings as errors on every target, clippy and cargo check of the builds without the ears or the studio window, the tests, and the examples in the docs. CI runs more; when you changed the matching part, run it too:

you changedrun
the docs or the sitecargo xtask site, then lychee --offline --include-fragments --root-dir "$PWD/target/site" 'target/site/**/*.html' for the links, and npm ci && npx playwright test in site/
recording or choosing files in the browser (audio/web_record.rs, audio/take.rs, record-worklet.js, pick.rs, the Record window)cargo clippy -p claudius-ui --target wasm32-unknown-unknown --features plan -- -D warnings, then cargo build --bin claudius && cargo xtask web --plan and npx playwright test tests/record.spec.mjs tests/files.spec.mjs in site/, which record in Chromium with a file for a microphone and a MIDI keyboard they play themselves, and choose files as a person would (they skip without those builds)
saying what to do to the palette (claudius_session::hearing, claudius_intent::spoken, the palette’s microphone)CLAUDIUS_WHISTLE_CLIPS=DIR cargo test --release -p claudius-session --test hearing -- --nocapture, with a folder of clips each beside its words; then, with those builds, CLAUDIUS_SPEECH=clip.wav CLAUDIUS_SPEECH_WORDS="turn the bass down by three decibels" CLAUDIUS_WHISTLE_MODEL=whistle.cact npx playwright test tests/palette.spec.mjs in site/, which says the clip to the palette’s microphone in Chromium and waits for its words in the field (it skips without them)
the web studio, the demo or the phone’s pagecargo build --bin claudius && cargo xtask web --plan, then npx playwright test in site/: with those two builds the end-to-end tests that drive the studio run too (without them they skip), as CI’s studio in a browser job runs them
the demo (crates/claudius-ui/src/mock/, its engine’s worker in crates/claudius-web)cargo xtask site, then node site/tests/serve.mjs and listen to http://127.0.0.1:4321/studio/?mock; cargo clippy -p claudius-web --target wasm32-unknown-unknown -- -D warnings
dependenciescargo deny check
anything with words in ittypos
workflows or scriptsactionlint and shellcheck scripts/*.sh scripts/ci/*.sh scripts/package/*.sh .githooks/* .claude/hooks/*.sh
a lockfileosv-scanner scan source --config osv-scanner.toml --lockfile Cargo.lock --lockfile site/package-lock.json
benchmarkscargo bench --no-run
the engine’s main steps (composing, rendering, scripts, judging, encoding, decoding, scratches)CI’s performance job counts their instructions against the base’s and fails one that takes more than 10 % more (Performance tests); cargo xtask perf on Linux with Valgrind counts them as it does. A change that slows one on purpose says so in the description: perf: render +20% (why)
code that the Intel Mac build compilesrustup target add x86_64-apple-darwin, then cargo check --target x86_64-apple-darwin -p claudius-cli --no-default-features --features studio (CI’s intel mac build job)
the engine, as a browser builds itcargo clippy -p claudius --no-default-features --target wasm32-unknown-unknown -- -D warnings (cargo xtask ci runs it)