This file provides guidance to AI coding agents working with code in this repository.
hw-core is a Rust workspace for host-to-hardware crypto wallet communication. The first target is Trezor Safe 7 over BLE using the Trezor Host Protocol (THP). The transport/core stack is designed to be shared across wallet vendors.
All skills are mandatory reading before making changes.
- Project Overview – Crate architecture, dependency graph, feature flags, and key design patterns
- Development Commands – Building, testing, linting, running the CLI, and generating bindings
- Code Style – Module organization, async patterns, and trait design
- Error Handling – Layered
thiserrorenums,Resultreturns, and no panics in production - Defensive Programming – Type safety, exhaustive matching, and safe defaults
- Naming – Rust naming conventions and project-specific terminology
- Tests – Test organization, MockBackend, proptest, and fixture patterns
- Comments – When and how to write comments and doc comments
- Git and Commit Guidelines – Conventional Commits format and PR checklist
- Common Issues – Known build, BLE, and platform-specific issues
After any code changes, run formatting before finishing:
just fmt && just lintOr explicitly:
cargo fmt --all
cargo clippy --workspace --all-targets --all-features -- -D warnings- Comments and docstrings are opt-in, not default.
- When needed, keep them to a single line.
- Prefer no comment unless it explains intent, invariants, or safety that the code cannot make obvious on its own.
- When debugging protocol/flow mismatches, always check the Trezor Suite implementation first:
~/workspace/github/trezor-suite - Treat Trezor Suite app behavior as the reference for:
- request payload shapes
- derivation path/account handling
- signing request construction
- user-facing pairing/connect/address/sign flows
- Build times: Initial build takes several minutes; incremental builds are fast with sccache
- Linux BLE: Requires
sudo apt-get install -y libdbus-1-dev pkg-config - Pairing state: Stored at
~/.hw-core/thp-host.json; usepair --forceto reset - License: Apache-2.0
- Development status: See docs/roadmap.md and docs/plan.md