capn is a development automation tool for Rust workspaces. It runs as pre-commit and pre-push hooks, handling code formatting and comprehensive validation before you push.
This project was originally forked from facet-dev.
- Code Formatting: Formats staged Rust files with
rustfmt(edition 2024) - Cargo.lock Staging: Automatically stages lockfile changes
- Arborium Setup: Configures arborium syntax highlighting for rustdoc
- Edition 2024 Enforcement: Ensures all crates use Rust edition 2024
- External Path Deps Check: Catches path dependencies pointing outside the workspace
- Clippy: Runs
cargo clippywith warnings as errors - Tests: Runs tests via
cargo nextest(only affected crates) - Doc Tests: Runs documentation tests (disabled by default)
- Documentation: Builds docs with
cargo doc -D warnings - Unused Dependencies: Checks for unused deps with
cargo-shear - Target Size: Reports target directory size at the end
All checks run in parallel with live progress spinners. If any check fails, remaining tasks are cancelled immediately.
On macOS and Linux:
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/bearcove/capn/releases/latest/download/capn-installer.sh | shOn Windows (PowerShell):
powershell -ExecutionPolicy ByPass -c "irm https://github.com/bearcove/capn/releases/latest/download/capn-installer.ps1 | iex"cargo install capnThis installs both capn and a captain compatibility shim that forwards to capn.
cargo install --git https://github.com/bearcove/capn capnInitialize capn in your project:
capn initThis creates:
hooks/pre-commitandhooks/pre-pushscriptshooks/install.shto install the hooksconductor.jsonfor Conductor integration.config/capn/config.styxconfiguration file
Then install the hooks:
./hooks/install.shcapnRuns all pre-commit checks, formats code, and stages changes.
capn pre-pushRuns clippy, tests, doc builds, and cargo-shear on affected crates.
HAVE_MERCY=1 git push # Skip tests, doc-tests, docs
HAVE_MERCY=2 git push # Also skip clippy
HAVE_MERCY=3 git push # Skip everythingcapn debug-packagesCapn uses Styx configuration at .config/capn/config.styx:
@schema {id crate:capn-config@1, cli capn}
pre-commit {
// `generate-readmes` defaults to false and is deprecated/ignored.
// Enable it only to get a reminder to use cargo-reedme.
generate-readmes false
rustfmt true
cargo-lock true
arborium true
edition-2024 true
external-path-deps true
internal-dev-deps-release-plz true
}
pre-push {
clippy true
nextest true
doc-tests false // Disabled by default
docs true
cargo-shear true
// Optional: specify features instead of --all-features
// clippy-features (feature1 feature2)
// doc-test-features (feature1)
// docs-features (feature1)
}
If you still have a legacy .config/captain/, run capn migrate to move it.
When both exist, .config/capn/ takes precedence.
| Option | Default | Description |
|---|---|---|
generate-readmes |
false |
Deprecated/ignored. If enabled, capn recommends cargo-reedme |
rustfmt |
true |
Format staged Rust files |
cargo-lock |
true |
Stage Cargo.lock changes |
arborium |
true |
Set up arborium syntax highlighting |
edition-2024 |
true |
Require Rust edition 2024 |
external-path-deps |
true |
Check for external path dependencies |
internal-dev-deps-release-plz |
true |
Catch release-plz-incompatible internal deps |
| Option | Default | Description |
|---|---|---|
clippy |
true |
Run clippy with -D warnings |
nextest |
true |
Run tests via cargo-nextest |
doc-tests |
false |
Run documentation tests |
docs |
true |
Build docs with -D warnings |
cargo-shear |
true |
Check for unused dependencies |
clippy-features |
- | Features for clippy (omit for --all-features) |
doc-test-features |
- | Features for doc tests |
docs-features |
- | Features for rustdoc |
Capn no longer generates README.md files.
If you enable pre-commit.generate-readmes = true, capn prints a warning and recommends using cargo-reedme instead.
Set RUST_LOG for debug output:
RUST_LOG=capn=debug capn
RUST_LOG=capn=trace capn # Very verboseLicensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.