|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides instructions for agentic coding assistants working in this Rust repository. |
| 4 | + |
| 5 | +## Build and Test Commands |
| 6 | + |
| 7 | +```bash |
| 8 | +# Build project (debug) |
| 9 | +make build |
| 10 | + |
| 11 | +# Build release version |
| 12 | +make release |
| 13 | + |
| 14 | +# Run application |
| 15 | +make run |
| 16 | + |
| 17 | +# Run all tests |
| 18 | +make test |
| 19 | + |
| 20 | +# Run a specific test |
| 21 | +cargo test --test <test_module_name> |
| 22 | + |
| 23 | +# Clean build artifacts |
| 24 | +make clean |
| 25 | +``` |
| 26 | + |
| 27 | +## Linting and Formatting |
| 28 | + |
| 29 | +```bash |
| 30 | +# Run linter (Clippy) |
| 31 | +make lint |
| 32 | + |
| 33 | +# Auto-format code (Rustfmt) |
| 34 | +make format |
| 35 | + |
| 36 | +# Auto-fix lint issues |
| 37 | +make fix |
| 38 | +``` |
| 39 | + |
| 40 | +## Cross-Compilation Targets |
| 41 | + |
| 42 | +The project supports cross-compilation using `cross`. Available targets: |
| 43 | + |
| 44 | +```bash |
| 45 | +make linux-musl # x86_64 Linux (musl) |
| 46 | +make aarch64-linux-musl # ARM64 Linux (musl) |
| 47 | +make aarch64-android # ARM64 Android |
| 48 | +make linux-gnu # x86_64 Linux (GNU) |
| 49 | +make windows-gnu # x86_64 Windows |
| 50 | +make freebsd # x86_64 FreeBSD |
| 51 | +make loongarch # LoongArch Linux |
| 52 | +``` |
| 53 | + |
| 54 | +## Code Style Guidelines |
| 55 | + |
| 56 | +### General |
| 57 | +- **File encoding**: UTF-8 |
| 58 | +- **Line endings**: LF (Unix-style) |
| 59 | +- **Trailing whitespace**: Must be trimmed |
| 60 | +- **Final newline**: Required at end of file |
| 61 | + |
| 62 | +### Rust-specific |
| 63 | +- **Indentation**: 4 spaces (no tabs) |
| 64 | +- **Import style**: Grouped as shown in Cargo.toml: |
| 65 | + 1. Standard library |
| 66 | + 2. External dependencies |
| 67 | + 3. Internal modules |
| 68 | +- **Naming conventions**: |
| 69 | + - Variables/functions: `snake_case` |
| 70 | + - Types: `PascalCase` |
| 71 | + - Constants: `SCREAMING_SNAKE_CASE` |
| 72 | +- **Error handling**: |
| 73 | + - Use `anyhow` for application errors |
| 74 | + - Use `thiserror` for structured error types |
| 75 | + - Prefer `?` operator over `unwrap()` |
| 76 | + - Avoid `panic!` in production code |
| 77 | +- **Type annotations**: |
| 78 | + - Use Rust's type inference where possible |
| 79 | + - Explicitly annotate public API signatures |
| 80 | + - Use `derive` macros for common traits (Debug, Clone, etc.) |
| 81 | + |
| 82 | +### Documentation |
| 83 | +- **Public API**: Must have doc comments `///` |
| 84 | +- **Module-level**: Use `//!` at top of module files |
| 85 | +- **Examples**: Include usage examples in doc comments |
| 86 | + |
| 87 | +## Development Workflow |
| 88 | + |
| 89 | +```bash |
| 90 | +# Watch mode with live reload |
| 91 | +make dev |
| 92 | + |
| 93 | +# Check for compilation errors |
| 94 | +make check |
| 95 | +``` |
| 96 | + |
| 97 | +## Configuration |
| 98 | + |
| 99 | +- Project configuration uses TOML format (`config.example.toml`) |
| 100 | +- Copy `config.example.toml` to `config.toml` and customize |
| 101 | + |
| 102 | +## Performance Optimization |
| 103 | + |
| 104 | +Release builds include these optimizations: |
| 105 | +```toml |
| 106 | +[profile.release] |
| 107 | +opt-level = 3 |
| 108 | +strip = true |
| 109 | +lto = true |
| 110 | +panic = "abort" |
| 111 | +codegen-units = 1 |
| 112 | +``` |
| 113 | + |
| 114 | +## Dependencies Management |
| 115 | + |
| 116 | +- Dependencies are managed via Cargo.toml |
| 117 | +- Always run `cargo update` after modifying dependencies |
| 118 | +- Use exact version pins (">=0.1.0") for production dependencies |
| 119 | + |
| 120 | +## Git Integration |
| 121 | + |
| 122 | +- Branch naming: `<type>/<short-description>` |
| 123 | +- Commit messages: |
| 124 | + - Use imperative mood ("Add feature" not "Added feature") |
| 125 | + - First line <= 50 characters |
| 126 | + - Body explains "why" not just "what" |
| 127 | +``` |
0 commit comments