SKILL.md--- name: rust-cargo-assistant description: Cargo build system, crate management, and Rust project configuration assistance. --- # Rust Cargo and Crate Management Skill Cargo build system, crate management, and Rust project configuration assistance. ## Instructions You are a Rust and Cargo ecosystem expert. When invoked: 1. **Cargo Management**: - Initialize and configure Cargo projects - Manage Cargo.toml and Cargo.lock files - Configure build profiles and features - Handle workspace and multi-crate projects - Use cargo commands effectively 2. **Dependency Management**: - Add, update, and remove crates - Handle feature flags and optional dependencies - Use semantic versioning and version resolution - Manage dev, build, and target-specific dependencies - Work with path and git dependencies 3. **Project Setup**: - Initialize libraries and binaries - Configure project structure - Set up testing and benchmarking - Configure documentation - Manage cross-compilation 4. **Troubleshooting**: - Fix dependency resolution errors - Debug compilation issues - Handle version conflicts - Clean build artifacts - Resolve linker errors 5. **Best Practices**: Provide guidance on Rust project organization, crate publishing, and performance optimization ## Cargo Basics ### Project Initialization ```bash # Create new binary project cargo new my-project # Create new library cargo new --lib my-lib # Create project with specific name cargo new --name my_awesome_project my-project # Initialize in existing directory cargo init # Initialize as library cargo init --lib # Project structure created: # my-project/ # ├── Cargo.toml # ├── .gitignore # └── src/ # └── main.rs (or lib.rs for library) ``` ### Basic Commands ```bash # Build project cargo build # Build with release optimizations cargo build --release # Run project cargo run # Run with arguments cargo run -- arg1 arg2 # Run specific binary cargo run --bin my-binary # Check code (faster than build) cargo check # Run tests cargo test # Run benchmarks cargo bench # Generate documentation cargo doc --open # Format code cargo fmt # Lint code cargo clippy # Clean build artifacts cargo clean # Update dependencies cargo update # Search for crates cargo search tokio # Install binary cargo install ripgrep ``` ## Usage Examples ``` @rust-cargo-assistant @rust-cargo-assistant --init-project @rust-cargo-assistant --add-dependencies @rust-cargo-assistant --optimize-build @rust-cargo-assistant --troubleshoot @rust-cargo-assistant --publish-crate ``` ## Cargo.toml Configuration ### Complete Example ```toml [package] name = "my-awesome-project" version = "0.1.0" edition = "2021" authors = ["Your Name <email@example.com>"] description = "A brief description of the project" documentation = "https://docs.rs/my-awesome-project" homepage = "https://github.com/user/my-awesome-project" repository = "https://github.com/user/my-awesome-project" r