Checks
The commands every change passes and the rules of the engineering guide, summarised.
Run these before opening an issue or a pull request:
just format-check # rustfmt with the pinned nightly
just lint # clippy, pedantic, no unwrap / expect / panic
cargo test --workspacejust release-preflight runs all three in that order.
Formatting
Never run cargo fmt on stable in this repository. just format, just format-check or plain cargo fmt select the pinned nightly through rust-toolchain.toml.
The full rules are in CLAUDE.md. This page summarises them.
Lint set
just lint runs clippy on every crate and target with warnings denied:
cargo clippy --workspace --all-targets -- -D warnings -W clippy::pedantic \
-W clippy::unwrap_used -W clippy::expect_used -W clippy::panic \
-W clippy::dbg_macro -W clippy::print_stdout -W clippy::print_stderr \
-W clippy::todo -W clippy::undocumented_unsafe_blocksFor one crate, run cargo fmt -p <crate> -- --check, the same clippy line with -p <crate>, and cargo test -p <crate> <test_name>.
Crate boundaries
The root Cargo.toml is a virtual workspace with one responsibility per crate. The dependency rules are mandatory:
krad-app -> krad-ui -> {krad-session -> {krad-pty, krad-term}, krad-repo, krad-store, krad-agents, krad-chat, krad-gitlab, krad-github, krad-update, krad-lsp, krad-extensions, krad-host}, pluskrad-app -> krad-agentsandkrad-app -> krad-store.krad-repo,krad-chat,krad-lsp,krad-extensionsandkrad-agentsmay depend onkrad-host, which depends only onkrad-domain. Any crate may depend onkrad-domain. No other edges and no cycles.krad-domaindepends on no workspace crate and on none ofgpui,libghostty-vtortokio.krad-termdoes not depend onkrad-pty; it is tested by feeding raw bytes.gpuiis allowed only inkrad-uiandkrad-app. After a change to aCargo.toml,cargo tree -i gpui-pre -e normal --workspaceconfirms it.- External dependencies are declared once in
[workspace.dependencies]. Adding, removing or upgrading a crate is asked first.
Error handling
thiserrorenums per crate or module boundary in library crates;anyhowonly inkrad-appand top-level task handlers.- Errors propagate with
?and gain context when they cross a layer. AResultthat matters is never silenced withlet _ =or.ok(). - No
.unwrap(),.expect()orpanic!in production code.expectis allowed only where the invariant is proven locally, and its message states it. Tests may unwrap.
Naming and style
- Names follow the vocabulary in
CONTEXT.md. snake_casefor functions, modules and variables,UpperCamelCasefor types and traits,SCREAMING_SNAKE_CASEfor constants. NoIprefixes, noImpl,ManagerorHelpersuffixes.foo.rsplusfoo/for submodules, neverfoo/mod.rs. A file past about 400 lines, or one that mixes responsibilities, is split.- Private by default,
pub(crate)for crate internals,pubonly for what another crate uses. - The domain is modelled with types: newtypes for identifiers and units, enums instead of boolean flags or string states, no magic values.
- No comments, except the
// SAFETY:comment everyunsafeblock needs and the# Errors,# Panicsand# Safetysections clippy requires. tracinginstead ofprintln!, and no secrets, tokens or terminal contents in logs or error messages.- The UI thread never blocks: PTY, process, file and network I/O run on the background executor or dedicated threads.
Tests
- Behaviour changes add or update tests: unit tests in
#[cfg(test)] mod testsnext to the code, cross-crate behaviour in the crate'stests/, and GPUI interaction tests when UI behaviour changes. - Domain logic is testable without a window, and terminal behaviour is tested by feeding raw ANSI bytes to
krad-term. - A change to platform code states on which platforms it was compiled and tested.