2.6 KiB
2.6 KiB
Agent Configuration
IMPORTANT: Prefer to use the write_file tool if the edit is for the majority of a file, or if you are correcting previous problems made edits from other tools.
Commands
IMPORTANT: Always export TERM=dumb.
IMPORTANT: The cargo command cannot be ran in parallel.
Build
- Build:
TERM=dumb cargo build - Build release:
TERM=dumb cargo build --release
Test
- Run all tests:
TERM=dumb cargo test - Run specific test:
TERM=dumb cargo test TEST_NAME - Run tests with output:
TERM=dumb cargo test -- --nocapture
Lint/Format Commands
- Check formatting:
TERM=dumb cargo fmt --check - Format code:
TERM=dumb cargo fmt - Lint:
TERM=dumb cargo clippy - Lint with errors:
TERM=dumb cargo clippy -- -D warnings
Code Style Guidelines
Imports
- Group imports in order: standard library, external crates, local modules
- Use explicit imports over glob imports (
use std::fs::File;notuse std::fs::*;)
Formatting
- Use rustfmt (configured via rustfmt.toml if exists)
- Max line length: 100 characters
- Indent with 4 spaces
Types
- Prefer explicit types in public API
- Use
&strfor string literals,Stringfor owned strings - Use
Option<T>for optional values,Result<T, E>for error handling
Naming Conventions
- Use snake_case for variables and functions
- Use PascalCase for types and traits
- Use UPPER_SNAKE_CASE for constants and statics
Error Handling
- Use
anyhow::Resultfor most error handling - Use
anyhow::Contextto add context to errors - Avoid
unwrap()in production code
Documentation
- Document all public APIs with rustdoc
- Use examples in documentation when helpful
Procedures
Fix build problems
- Check the project:
TERM=dumb cargo check. - If there are errors or warnings, create a new sub agent (expert rust developer) that uses the
TERM=dumb cargo checkoutput as input, planned using strategic thinking. a. Read all affected files d. Plan the fixes using strategic thinking:- Read other files if they provide context or examples
- Look up relevant API information
- Do not downgrade versions
- Preserve functionality
- Use
TERM=dumb cargo fixif appropriate. - Prefer the
write_filetool if there is evidence of double escaping - You must generate the full file contents when using
write_fileor it will be truncated. c. Return the list of files modified
- If any files were modified, loop back to 1.
Fix formatting
- Format the project the project:
TERM=dumb cargo fmt - Continue with the fix build problems procedure.