rust-coder Skill
基于仓库实际情况实现、重构和迁移生产级 Rust 代码,遵循所有权规则、类型驱动的不变量、明确的错误处理、安全的并发、最少的 unsafe 代码,并验证 Cargo 工作流。适用于 Rust 功能、crate、CLI、服务、库、异步代码、FFI、性能优化、迁移或较大规模的 .rs 和 Cargo.toml 改动,包括诸如 'rust-coder'、'write Rust' 或 '用 Codex 实现这个 Rust 功能' 之类的请求。
安装方式:把技能目录放入 ~/.claude/skills/(Claude Code)或在 claude.ai 设置中启用;也可复制右侧安装命令一键添加。
技能指令原文(SKILL.md)
Rust Coder
Implement directly in the current Codex session. Do not launch another Codex process.
Read references/standards.md completely before editing. Repository instructions and the declared toolchain override generic preferences.
Inspect
Read the smallest complete set of evidence:
- Nearest
AGENTS.md,CLAUDE.md, and repository instructions. - Root and target
Cargo.toml,Cargo.lock,rust-toolchain*, Cargo configuration, lint and format configuration, features, targets, and continuous-integration commands. - Every target file in full, its parent exports, immediate callers, traits, types, errors, feature gates, platform boundaries, focused tests, and one or two tested sibling modules.
- The exact format, check, test, Clippy, feature, and target commands used by the crate.
Determine the edit mode, crate kind, toolchain and minimum Rust version, public contract, ownership, resource lifecycle, error model, concurrency and cancellation, safety boundary, and invariants. Default to a hard cut; preserve compatibility only when an explicitly confirmed published contract requires it.
Ask only when an unresolved fact could change public behavior, durable state, safety, or migration semantics. Otherwise make repository-grounded assumptions and continue.
Design and implement
Resolve the change in this order:
- Domain invariants and invalid states.
- Ownership, borrowing boundaries, and resource lifetimes.
- Types, state transitions, public API, and errors.
- Concurrency, cancellation, and platform boundaries when relevant.
- Implementation mechanics and measured optimization.
Work directly with the available read and edit tools. Make the smallest coherent change and preserve unrelated work. Reuse existing crates, types, traits, errors, runtime, and helpers. Do not add dependencies, features, configuration, compatibility paths, unsafe, smart pointers, clones, lint suppressions, or abstractions merely to satisfy the compiler.
Treat borrow-checker and trait errors as design feedback. Keep checking and revising until the observable success criteria pass.
Verify
- Review the diff; every changed line must trace to the request.
- Run the repository's exact commands. Without stronger local commands, use focused equivalents of
cargo fmt --all --check,cargo check,cargo test, andcargo clippy --all-targets --all-features -- -D warnings. - Exercise every changed public feature combination and target that local tooling can validate.
- Search changed production Rust for unexplained
clone,Arc,Rc,Box, interior mutability,unwrap,expect, panics, placeholders,unsafe, and lint suppressions. - Add documentation, compile-fail, property, concurrency, Miri, package, or consumer checks only when the changed contract makes them relevant.
If a check fails, fix the exact observed failure and rerun it. Stop after three failed correction rounds and report the blocker instead of widening scope, cloning around ownership, adding unsafe code, or weakening validation.
Report
Lead with the outcome. Name changed files, consequential assumptions, ownership/type/error decisions, compatibility decisions, and every command actually run with its result.