Enforces Rust development policies including zero warnings, static dispatch preference, minimal Arc usage, and comprehensive testing requirements...
Enforces core Rust development policies for the aiassisted project. Use this skill to verify code compliance or guide implementation.
Use this skill when:
| Policy | Requirement |
|---|---|
| Zero warnings | cargo check must produce 0 warnings |
| Static dispatch | Prefer generics over dyn traits |
| Minimal Arc | Use Arc only for actual concurrent sharing |
| Testing | Unit tests for all modules (positive + negative) |
| Integration tests | Workflow tests in tests/ directory |
Verify no warnings:
cargo check 2>&1 | grep -c warning # Must be 0
Common fixes:
_ or remove#[allow(dead_code)]Check for dynamic dispatch patterns:
// โ Avoid
fn process(handler: &dyn Handler) { }
fn process(handler: Box<dyn Handler>) { }
// โ
Prefer
fn process<H: Handler>(handler: &H) { }
fn process(handler: impl Handler) { }
Acceptable exceptions:
Review Arc usage - this CLI runs sequentially with no shared state:
// โ Avoid in this codebase
fn execute(fs: Arc<dyn FileSystem>) { }
// โ
Prefer
fn execute<F: FileSystem>(fs: &F) { }
Arc is acceptable for:
Every module must have:
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_function_success() { } // Positive test
#[test]
fn test_function_error() { } // Negative test
#[test]
fn test_function_edge_case() { } // Edge case
}
Required coverage:
Mock dependencies with mockall:
use mockall::{mock, predicate::*};
mock! {
pub FileSystem {}
impl crate::core::infra::FileSystem for FileSystem {
async fn read(&self, path: &Path) -> Result<String>;
}
}
Located in tests/ directory, use real implementations:
use wiremock::{Mock, MockServer, ResponseTemplate};
#[tokio::test]
async fn test_full_workflow() {
let mock_server = MockServer::start().await;
// Test with real HTTP client
}
Check warnings:
cargo check 2>&1 | grep warning
Search for dyn usage:
grep -r "dyn " src/
Search for Arc usage:
grep -r "Arc<" src/
Verify test coverage:
cargo test
Check for missing tests:
Look for modules without #[cfg(test)]
For comprehensive policy documentation, see rust-policy-guide.md.