AGENT SKILL

rust-api-design

Design and review Rust APIs, type invariants, ownership, traits, conversions, errors, documentation, compatibility, builders, and feature-exposed surfaces. Use when public or durable internal contracts change. Do not activate for purely local implementation details with no lasting interface consequence.

License 许可
Apache-2.0
所属仓库
RawSocketLabs/rsl
最近更新
2026-11-15
Stars
★ 2
Forks
0

01 前言 Front Matter

name
rust-api-design
description
Design and review Rust APIs, type invariants, ownership, traits, conversions, errors, documentation, compatibility, builders, and feature-exposed surfaces. Use when public or durable internal contracts change. Do not activate for purely local implementation details with no lasting interface consequence.

02 资源文件 5

03 SKILL.md 正文

Design Rust APIs

Inspect the contract

  1. Read $rust-core, the repository compatibility policy, MSRV, feature model, public callers, existing types, documentation, and downstream examples.
  2. Identify who establishes and preserves each invariant, what invalid states remain representable, and whether the API is public, serialized, FFI, wire, generated, or layout-sensitive.
  3. Read API, ownership, and errors for type and trait decisions. Read ownership patterns for state modeling, validated construction, exact quantities, borrowed options, frozen shared sequences, builders, type-state, and error-library boundaries. Read documentation and examples when the public teaching or compatibility surface changes.

Design and route

  • Prefer familiar concrete APIs until demonstrated callers need genericity, dynamic dispatch, type-state, or a macro.
  • Make fallibility, ownership transfer, allocation, panic, and error loss explicit.
  • Treat a repeated runtime guard as a modeling question: decide whether the state belongs in an enum variant, a validated constructor, or a type parameter, and delete the checks the chosen type proves.
  • Treat builders, newtypes, enums, traits, and validated wrappers as tools for real invariants, not universal patterns.
  • Route tests and SemVer evidence to $rust-testing, Cargo feature and dependency impact to $rust-dependencies-security, and domain semantics to the applicable skill.

Verify

Compile public examples and doctests. Exercise downstream call syntax, feature configurations, error paths, mutation invariants, and compatibility tooling when required. Record any deliberate breaking change and migration path.

Output

State the API contract, alternatives considered, compatibility and MSRV impact, error and panic behavior, documentation updates, tests, and unresolved risks.

04 同仓库更多 Skills

RawSocketLabs
RawSocketLabs/rsl

rust-unsafe-ffi

Design and review unsafe Rust, safe wrappers, manual Send or Sync, ABI boundaries, foreign ownership, callbacks, and FFI build integration. Use whenever unsafe code or a foreign interface is introduced, changed, or relied upon. Do not use unsafe merely to bypass borrow checking or for unmeasured optimization.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-testing

Select, implement, and assess Rust unit, integration, documentation, property, fuzz, snapshot, concurrency, unsafe, protocol, benchmark, and verification evidence. Use whenever behavior changes or claims need proof. Do not run every tool mechanically when the repository or risk makes it inapplicable.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-skill-maintenance

Maintain this modular Rust skills system, including canonical content, manifests, references, profiles, generated adapters, migrations, examples, evaluations, releases, and compatibility. Use when changing the skills repository itself. Do not hand-edit generated adapters.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-review

Review Rust diffs, commits, branches, and designs for actionable correctness, soundness, security, compatibility, concurrency, protocol, performance, testing, and maintainability risks. Use for review or pre-merge assessment. Do not modify code unless separately requested.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-repository-onboarding

Inspect, interview, profile, configure, and install the modular Rust engineering skills into a repository. Use when adopting or refreshing these skills, generating repository-specific Rust rules, or creating validation workflows. Never finalize policy before repository inspection and user approval.

★ 2
RawSocketLabs
RawSocketLabs/rsl

rust-protocol

Engineer and review binary protocols, wire formats, builders, encoders, parsers, framing, stateful messages, bit ordering, integrity, correction, malformed input, and conformance. Use for protocol or serializer code. Do not apply protocol rules to unrelated in-memory models.

★ 2