agents.md
This file provides guidance for AI coding agents working autonomously in this repository. It extends CLAUDE.md with agent-specific workflows and safety guidelines.
Prerequisites: Read and understand
CLAUDE.mdbefore using this file. That document contains essential build commands, architecture overview, and project structure.
Never modify consensus-critical code without explicit user confirmation
consensus/safety_rules/consensus/src/round_manager.rsNever modify cryptographic code without explicit user confirmation
crates/aptos-crypto/Prefer reversible changes: Make small, incremental commits that can be easily reverted
When in doubt, ask: If a change might affect security, consensus, or data integrity, pause and ask the user
git log -p --follow -- <file>1. Reproduce: Understand the bug via tests or user description
2. Locate: Find relevant code using search tools
3. Analyze: Read surrounding code and tests
4. Fix: Make minimal change to fix the issue
5. Test: Run relevant tests
cargo test -p <package> <test_name>
6. Verify: Check no regressions
cargo test -p <package>
7. Lint: Ensure code quality
cargo xclippy -p <package>
cargo +nightly fmt --check
1. Understand: Read related code and architecture
2. Design: Plan minimal implementation
3. Implement: Write code following existing patterns
4. Test: Add unit tests alongside implementation
5. Integrate: Update any affected modules
6. Verify:
cargo build -p <package>
cargo test -p <package>
cargo xclippy -p <package>
1. Locate: Find module in aptos-move/framework/<package>/sources/
2. Understand: Read module and its tests
3. Modify: Make changes to Move code
4. Test Move: cargo test -p <framework-package>
5. Rebuild cached packages (REQUIRED):
cargo build -p aptos-cached-packages
6. Verify: Check for uncommitted generated files
git status aptos-move/framework/cached-packages/
1. Locate: Find endpoint in api/src/
2. Modify: Update implementation
3. Regenerate OpenAPI specs:
cargo run -p aptos-openapi-spec-generator -- -f yaml -o api/doc/spec.yaml
cargo run -p aptos-openapi-spec-generator -- -f json -o api/doc/spec.json
4. Test: cargo test -p aptos-api
third_party/move/move-vm/)cargo test -p move-vm-runtimeaptos-move/aptos-vm/)cargo test -p aptos-vmaptos-move/block-executor/)cargo test -p aptos-block-executorstorage/)cargo test -p aptos-dbconsensus/)# Check compilation
cargo check -p <package>
# Run package tests
cargo test -p <package>
# Check lints for package
cargo xclippy -p <package>
# Full lint check
./scripts/rust_lint.sh --check
# Or individual checks
cargo xclippy
cargo +nightly fmt --check
cargo sort --grouped --workspace --check
# Core packages
cargo test -p aptos-vm -p aptos-types -p aptos-crypto
# Framework
cargo test -p aptos-framework -p aptos-stdlib
# Smoke tests (slower but comprehensive)
cargo test -p smoke-test
# Find function definitions
grep -r "fn function_name" --type rust
# Find trait implementations
grep -r "impl.*TraitName" --type rust
# Find type usages
grep -r "TypeName" --type rust --glob "*.rs"
# Find Move module
grep -r "module.*::module_name" --glob "*.move"
# Show what a package depends on
cargo tree -p <package>
# Show what depends on a package
cargo tree -p <package> --invert
# Find duplicate dependencies
cargo tree -d
#[cfg(test)] mod tests { ... }<crate>/tests/ directoryaptos-move/e2e-tests/aptos-move/framework/*/tests/testsuite/smoke-test/# Clean and rebuild
cargo clean -p <package>
cargo build -p <package>
# Full clean (last resort)
cargo clean
cargo build
# Force rebuild cached packages
cargo clean -p aptos-cached-packages
./scripts/cargo_build_aptos_cached_packages.sh
cd protos && ./scripts/build_protos.sh
# Auto-fix formatting
cargo +nightly fmt
# Sort dependencies
cargo sort --grouped --workspace
# Check for unused deps
cargo machete --fix
cargo check after any Rust code changeResult over panic!)consensus/safety_rules/Arc for shared data across threadsVeccargo run -p aptos-vm-profilingWhen modifying one component, verify these integration points:
| Component | Affects | Verify With |
|---|---|---|
| VM | Execution, Gas | cargo test -p aptos-vm -p aptos-block-executor |
| Framework | VM, API | cargo test -p aptos-framework && cargo build -p aptos-cached-packages |
| Storage | Everything | cargo test -p aptos-db -p aptos-executor |
| API | Clients | cargo test -p aptos-api + check OpenAPI spec |
| Types | Everything | cargo test -p aptos-types |
| Network | Consensus, Sync | cargo test -p aptos-network |
snake_case.rsmodule_name.move*_test.rs or in tests/ directory*.yaml or *.toml[area] Brief description
- Detailed change 1
- Detailed change 2
Example:
[vm] Fix gas metering for vector operations
- Corrected gas calculation for vector push
- Added unit tests for edge cases
Areas: vm, framework, consensus, storage, api, network, types, cli, docs, test