用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/tomevault-io/skills-registry --skill rust-style命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
| Use when this capability is needed.
> Use when this capability is needed.
Review architecture and API design for the vfs-s3 project. Use when the user mentions @architect, asks to review an issue's design, discuss module boundaries, API shape, or architectural decisions for vfs-s3. Also trigger when the user wants to create an ADR (Architecture Decision Record) or evaluate a technical approach for the project. Intended for dispatch from Codex automation or Claude routines; GitHub trigger phrase: @vfs-s3-bot please prepare design doc Use when this capability is needed.
基于 SOC 职业分类
正在显示 SKILL.md
| name | rust-style |
| description | > Use when this capability is needed. |
This skill governs code written inside an already-bootstrapped Rust project: package commands, module layout, test authoring, refactoring, code review, naming, ownership, errors, filesystem operations, comments, and docs.
Project bootstrap (flake.nix, direnv, initial Cargo.toml, initial rust-toolchain.toml) belongs to the nix-dev-init skill. If the project is not yet bootstrapped, defer to nix-dev-init first and return here once direnv allow succeeds and Cargo is available.
Bootstrap is an environment concern. This skill is for day-to-day Rust implementation inside an existing project. Do not duplicate Nix, direnv, or initial Cargo setup rules here.
cargo add <crate> when cargo add is available.cargo add --dev <crate>.cargo check for a fast compile/type-check pass when tests are not needed yet.cargo test for the default verification pass.cargo clippy --all-targets -- -D warnings for linting.Cargo.lock manually.Cargo.lock for applications, CLI tools, and internal tools.Cargo.lock policy.@latest-style version shortcuts in documentation or committed commands.src/.src/main.rs thin for binary crates. It should parse CLI arguments and call library code.src/lib.rs and focused modules under src/.tests/.examples/ only for runnable examples that should compile.utils.rs and helpers.rs; name modules by domain or action.Typical binary crate shape:
src/
├── main.rs
├── lib.rs
├── cli.rs
├── config.rs
├── fs_ops.rs
└── render.rs
tests/
└── cli.rs
rustfmt define formatting. Do not hand-format around rustfmt.mod.rs only when the existing project already uses that style; otherwise prefer module_name.rs plus module_name/child.rs.cargo test as the default test command.#[cfg(test)] mod tests.tests/*.rs for integration tests that exercise public APIs or CLI behavior.tests/ when testing public API, CLI behavior, or crate-level wiring.tests/common/ only when multiple integration test files need it.Example unit test layout:
pub fn normalize_name(input: &str) -> String {
input.trim().replace('_', "-")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn normalize_name_trims_whitespace_and_replaces_underscores() {
assert_eq!(normalize_name(" rust_style "), "rust-style");
}
}
type aliases and enums before structs that use them.#[cfg(test)] mod tests at the bottom of the file.impl blocks close together.Debug for most domain structs.Clone, PartialEq, Eq, Ord, or Hash only when the type actually needs that capability.Value Object pattern:
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct SkillName(String);
impl SkillName {
pub fn parse(value: impl Into<String>) -> anyhow::Result<Self> {
let value = value.into();
if value.is_empty() {
anyhow::bail!("skill name must not be empty");
}
Ok(Self(value))
}
pub fn as_str(&self) -> &str {
&self.0
}
}
match statements for domain control flow.Display when the enum has a stable user-facing representation.FromStr or TryFrom<&str> when parsing user input.#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Provider {
Claude,
Codex,
}
&str, &Path, &[T].Result<T, E> for expected failures.async unless the project has real concurrency or nonblocking I/O requirements.as_*: as_str, as_path, as_slice.into_*: into_inner, into_path_buf.len, status, provider.get_* unless following an existing local convention.is_*, has_*, can_*, or should_*.parse, try_from, or from_str.impl AsRef<Path> only at outer convenience boundaries. Inside the codebase, pass &Path.impl Into<String> for constructors that store owned strings.Cow only when profiling or API shape shows it is worthwhile.&Vec<T> in function parameters.Vec<T> for ordered sequences.BTreeMap or sorted vectors when deterministic output order matters.HashMap when order is irrelevant and lookup dominates.&str for borrowed string input and String for owned string storage.format! when constructing a new owned string from values.format!("{name}").to_owned() or String::from when converting a string literal to String.to_string() in hot or repeated code.usize for indexing and collection lengths.as for narrowing integer conversions.TryFrom or try_into when a conversion can fail.anyhow::Result at application and CLI orchestration boundaries where errors are reported to humans and callers do not branch on error categories.thiserror is appropriate for deriving concrete error types. Do not introduce it just to wrap every possible failure.? for propagation.unwrap or expect in production code except for impossible states justified by a nearby invariant.Result for expected failures.panic! for logic bugs and impossible states.get() or explicit validation.# Panics.todo!, unimplemented!, or debugging panic! calls in production code.unreachable! only when the type system or previous validation makes the branch impossible.Application-boundary error:
use anyhow::{Context, Result};
pub fn read_config(path: &Path) -> Result<String> {
std::fs::read_to_string(path)
.with_context(|| format!("failed to read config file {}", path.display()))
}
Distinguishable domain error:
#[derive(Debug, thiserror::Error)]
pub enum ProviderError {
#[error("unknown provider: {0}")]
UnknownProvider(String),
}
#[derive(Debug, clap::Parser)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, clap::Subcommand)]
pub enum Command {
Render(RenderArgs),
Verify(VerifyArgs),
}
eprintln! for warnings and progress.tracing only when the project needs structured logs, spans, or long-running diagnostics.Path and PathBuf for paths. Do not build paths with string concatenation.DirEntry::file_type() instead of Path::is_dir() when symlink behavior matters.Symlink-aware traversal without following symlinks:
use anyhow::{Context, Result};
use std::path::{Path, PathBuf};
pub fn collect_regular_files(dir: &Path) -> Result<Vec<PathBuf>> {
let mut files = Vec::new();
collect_regular_files_into(dir, &mut files)?;
files.sort();
Ok(files)
}
fn collect_regular_files_into(dir: &Path, files: &mut Vec<PathBuf>) -> Result<()> {
for entry in std::fs::read_dir(dir)
.with_context(|| format!("failed to read directory {}", dir.display()))?
{
let entry = entry?;
let file_type = entry.file_type()?;
let path = entry.path();
if file_type.is_symlink() {
continue;
}
if file_type.is_dir() {
collect_regular_files_into(&path, files)?;
} file_type.() {
files.(path);
}
}
(())
}
serde(deny_unknown_fields) where unknown input keys should be rejected.#[serde(rename_all = "...")] to keep serialized field naming consistent.#[serde(default)] for optional input fields that have stable defaults.#[serde(skip_serializing_if = "Option::is_none")] when absent values should not appear in output.#[serde(flatten)] sparingly because it makes schemas less explicit.cargo test --all-features when features affect compiled code paths.pub for APIs intended to be consumed outside the crate.pub(crate) for items shared across internal modules, including inside private modules when it clarifies that the item is not an external API.#[non_exhaustive] for public enums or structs that may need new variants or fields.build.rs until native linking, environment probing, or code generation is actually required.snake_case.snake_case.UpperCamelCase.SCREAMING_SNAKE_CASE.UpperCamelCase names such as T, E, P.'a; use descriptive names only when they clarify an unusual relationship.kebab-case.manager, helper, util, and common unless the name is already established locally.render.rs over renderer.rs for module names.install.rs over installer.rs for module names.config.rs over config_manager.rs for module names.Renderer or Installer as type names only when the type owns behavior.as aliases unless they remove ambiguity or follow a local convention.crate:: for crate-local imports and super:: for parent-module test imports.//! for module-level documentation./// for item documentation.# Errors when the error cases are not obvious.# Panics.Run these before finishing Rust changes unless the project defines a stricter gate:
cargo fmt --check
cargo clippy --all-targets -- -D warnings
cargo test
unsafe by default.clippy::pedantic at project start.Recommended package-level guard:
[lints.rust]
unsafe_code = "forbid"
[lints.clippy]
dbg_macro = "deny"
todo = "deny"
unimplemented = "deny"
Source: furedea/agent-harness — distributed by TomeVault.