一键导入
rust-project-init
Scaffold a new Rust project with correct structure, dependencies, and configuration. Handles workspace, library, and binary crate setup.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Scaffold a new Rust project with correct structure, dependencies, and configuration. Handles workspace, library, and binary crate setup.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Diagnose and fix Rust borrow checker and lifetime errors. Paste compiler errors and code — get structured analysis and fixes.
Write Rust code with awareness of known AI pitfalls — ownership, lifetimes, async, module integration, idiomatic patterns. Use when writing new Rust code or implementing features.
Review Rust code for correctness, safety, idiomatic patterns, and common AI-generated code smells. Use when reviewing Rust code quality or before merging.
| name | rust-project-init |
| description | Scaffold a new Rust project with correct structure, dependencies, and configuration. Handles workspace, library, and binary crate setup. |
| user-invocable | true |
Set up a new Rust project with the right structure from the start. Avoids the "generate code, then fix 50 import errors" cycle.
The user wants to create a new Rust project, add a crate to a workspace, or set up a project structure.
Ask if not obvious:
src/main.rs) — an executablesrc/lib.rs) — reusable code for other cratessrc/main.rs + src/lib.rs) — binary that uses its own library# Binary
cargo init my-project
# Library
cargo init --lib my-project
# Workspace: create Cargo.toml at root
Workspace Cargo.toml:
[workspace]
resolver = "2"
members = [
"crates/*",
]
[workspace.dependencies]
# Shared dependency versions here
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
anyhow = "1"
thiserror = "2"
my-project/
├── Cargo.toml
├── src/
│ ├── lib.rs # Library root (pub mod declarations)
│ ├── main.rs # Binary entry (if applicable)
│ ├── error.rs # Error types
│ └── {module}/
│ ├── mod.rs # Module root
│ └── ...
├── tests/ # Integration tests
│ └── integration.rs
├── benches/ # Benchmarks
├── examples/ # Example programs
└── .cargo/
└── config.toml # Cargo configuration
[package]
name = "my-project"
version = "0.1.0"
edition = "2024" # Use latest stable edition
rust-version = "1.85" # Minimum supported Rust version
[dependencies]
# Add based on project needs
[dev-dependencies]
# Testing dependencies
[lints.rust]
unsafe_code = "forbid" # Unless unsafe is intentionally needed
[lints.clippy]
all = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
CLI application:
clap = { version = "4", features = ["derive"] }
anyhow = "1"
tracing = "0.1"
tracing-subscriber = "0.3"
Web API (Axum):
axum = "0.8"
tokio = { version = "1", features = ["full"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tower = "0.5"
tower-http = { version = "0.6", features = ["cors", "trace"] }
tracing = "0.1"
tracing-subscriber = "0.3"
Library crate:
thiserror = "2"
serde = { version = "1", features = ["derive"], optional = true }
[features]
default = []
serde = ["dep:serde"]
Recommend these in Cargo.toml or as config:
cargo fmt — formatting (add rustfmt.toml if custom rules needed)cargo clippy — lintingcargo test — testingcargo doc --no-deps — documentationMinimal rustfmt.toml:
edition = "2024"
Minimal .cargo/config.toml:
[alias]
xtask = "run --package xtask --"
cargo check to verify everything compilescargo clippy to catch any issuesmod declaration has a matching file