This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Aptos Core is a layer 1 blockchain written primarily in Rust with Move smart contracts. It's a production-grade system with 200+ workspace crates organized into major subsystems: consensus, execution, storage, network, mempool, API, and Move VM.
cargo build -p <package> # Build a single package
cargo check -p <package> # Quick compile check (faster than build)
cargo build --profile performance # Optimized build with LTOcargo test -p <package> # Test a single package
cargo test -p <package> -- <test_name> # Run a specific test
cargo test -p aptos-framework # Framework tests
cargo test -p smoke-test # E2E smoke tests
cargo test -p e2e-move-tests # Move e2e tests./scripts/rust_lint.sh # Full lint (clippy + fmt + sort + machete)
./scripts/rust_lint.sh --check # Check-only mode for CI
cargo xclippy # Just clippy
cargo +nightly fmt # Just formattingAfter modifying Move code in aptos-move/framework/:
cargo build -p aptos-cached-packages # REQUIRED: rebuild cached packages./scripts/dev_setup.sh # Install all build dependencies
./scripts/dev_setup.sh -y # Include Move Prover tools (z3, boogie)- API Layer (
api/) - REST endpoints receive transactions - Mempool (
mempool/) - Transaction validation and ordering - Consensus (
consensus/) - Byzantine fault-tolerant ordering - Execution (
execution/) - Orchestrates VM execution - Block Executor (
aptos-move/block-executor/) - Parallel execution via Block-STM - Move (
third_party/move/) - Executes Move bytecode, Compiles Move, Verifies Move - Storage (
storage/) - Persistent state (JellyfishMerkleTree) - State Sync (
state-sync/) - Blockchain synchronization
aptos-move/framework/move-stdlib/- Core Move stdlibaptos-move/framework/aptos-stdlib/- Aptos-specific stdlibaptos-move/framework/aptos-framework/- Core chain modules (coin, account, staking)aptos-move/framework/aptos-token-objects/- NFT standards
aptos-types- Core type definitions used everywhereaptos-vm- VM integration and transaction executionaptos-crypto- Cryptographic primitives (security-critical)aptos-api-types- API request/response types
These directories require extra care and should not be modified without explicit approval:
consensus/safety-rules/- Byzantine fault tolerancecrates/aptos-crypto/- Cryptographic implementationssecure/- Security-critical moduleskeyless/- Keyless authentication
[area] Brief description (50 char max)
Detailed explanation of why, not what.
Areas: consensus, mempool, network, storage, execution, vm, framework, api, cli, crypto, types
- Unit tests:
#[cfg(test)] mod tests { ... }in source files - Integration tests:
<crate>/tests/directories - Move tests:
#[test]attributes in.movefiles
- Prefer thiserror / anyhow
Resultfor error handling - Use
expect()overunwrap()with descriptive messages - Use checked arithmetic (
checked_add,saturating_sub, etc.) - Infallible locks via
aptos-infalliblecrate
#[cfg(any(test, feature = "fuzzing"))]
fn test_helper() { ... }- Struct names: CamlCase (
OrderedMap) - Module names: snake_case (
ordered_map) - Function names: snake_case (
register_currency) - Constants: UPPER_SNAKE_CASE (
TREASURY_ADDRESS) - Import types at top-level, use functions qualified by module