agentleFS
nanlongnanlong/rust-engineer-skill/skills/rust-engineer/SKILL.md

rust-engineer

Skill1 starsChanged 4 months agoApache-2.0View on GitHub

Design, implement, diagnose, refactor, and review Rust through a constraint-driven loop covering the problem, ownership, types, minimal Trait boundaries, real execution paths, compiler feedback, layered verification, and source review. Use for changes to Rust source or Cargo manifests; borrow checker, lifetime, trait-bound, Send/Sync, async, cancellation, unsafe, or FFI problems; public APIs and cross-process contracts; module, crate, workspace, and test organization; dependency selection; performance; observability; and CI evidence.

12 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use build-engineer, react-specialist and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • belokonmSkill

    build-engineer

    Expert in monorepo tooling (Turborepo, Nx, Bazel), CI/CD pipelines, and bundler optimization (Webpack/Vite/Rspack).

    Also in 3 projects that use this

  • belokonmSkill

    react-specialist

    Expert React developer specializing in React 18+, Next.js ecosystem, and modern React patterns. This agent excels at building performant, scalable React applications using hooks, concurrent features, state management solutions like Zustand, and data fetching with TanStack Query.

    Also in 3 projects that use this

  • nilecuiSkill

    ui-designer

    Extract design systems from reference UI images and generate implementation-ready UI design prompts. Use when users provide UI screenshots/mockups and want to create consistent designs, generate design systems, or build MVP UIs matching reference aesthetics.

    Also in 3 projects that use this

  • +9 more from belokonm

The file

Show its rules and text

We split this skill into the rules it gives an agent

33 rules. 0 are common, 29 are distinctive, and 4 are very specific to this project.

  • 0

    Common

    Most of the 11 edited versions we read keep these.

  • 29

    Distinctive

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Treat Rust as a modeling tool.

    line 18
  2. Distinctive:

    Use this loop as the primary method:

    line 20
  3. Distinctive:

    Follow this priority order:

    line 26
  4. Distinctive:

    FULL: Use when any TRIVIAL condition is false or unproven.

    line 40
  5. Distinctive:

    Keep context discovery inside problem and constraints.

    line 47
  6. Distinctive:

    Treat concurrency, async, unsafe, FFI, networking, performance, observability, and production concerns as conditional branches that return …

    line 48
  7. Distinctive:

    Start tests from caller-visible behavior.

    line 54
  8. Very specific:

    Follow the repository's module-file convention.

    line 56
  9. Distinctive:

    Keep concrete adapters private by default.

    line 57
  10. Distinctive:

    Treat a third-party crate as a capability, ownership, runtime, compatibility, and supply-chain decision.

    line 58
  11. Distinctive:

    Read references/modeling.md when ownership, lifetimes, type/error design, or Trait boundaries are not obviously local, or compiler feedback …

    line 77
  12. Distinctive:

    Read references/organization.md when adding, moving, or reviewing modules, crates, workspaces, binaries, tests, examples, benchmarks, …

    line 78
  13. Distinctive:

    Read references/testing.md when designing or reviewing tests, Trait contracts, integration boundaries, or completion evidence.

    line 79
  14. Distinctive:

    Read references/systems.md for concurrency, async, cancellation, networking, security, unsafe, FFI, performance, or macros.

    line 80
  15. Distinctive:

    Read references/ecosystem.md for dependency discovery, comparison, introduction, upgrade, replacement, features, TLS/runtime choices, …

    line 81
  16. Distinctive:

    Read references/contracts.md for public Rust APIs, Traits, serialized or persisted formats, configuration, database schemas, generated …

    line 82
  17. Very specific:

    Read references/observability.md for structured events, tracing, metrics, OpenTelemetry, cross-task/process context, lifecycle diagnosis, …

    line 83
  18. Distinctive:

    Read references/engineering.md for external-system boundaries, cross-responsibility refactoring, production hardening, evidence escalation, …

    line 84
  19. Distinctive:

    Read the smallest necessary repository rules, worktree state, manifests, toolchain, features, public exports, direct callers, adjacent …

    line 101
  20. Distinctive:

    Write the desired caller first.

    line 119
  21. Distinctive:

    Keep local deterministic algorithms concrete when no independent behavior seam exists.

    line 121
  22. Distinctive:

    Use an enum for a closed set that callers must exhaustively handle.

    line 125
  23. Distinctive:

    Prefer static dispatch when the implementation is known at compile time.

    line 126
  24. Distinctive:

    Use dynamic dispatch only for a real runtime requirement.

    line 127
  25. Very specific:

    Keep the Trait small and caller-oriented.

    line 129
  26. Distinctive:

    write the narrowest caller-visible unit or contract test that fixes intended behavior.

    line 136
  27. Distinctive:

    add failure, shutdown, and cleanup required by this path.

    line 139
  28. Distinctive:

    add integration coverage only when the path truly crosses a component, protocol, process, or storage boundary.

    line 140
  29. Distinctive:

    Keep library behavior reusable and binaries thin.

    line 142
  30. Very specific:

    Use complete diagnostics, rustc --explain, minimal experiments, and source when required.

    line 153
  31. Distinctive:

    Test failure, cancellation, shutdown, and cleanup when they are part of the contract.

    line 166
  32. Distinctive:

    Read from public surface to implementation:

    line 170
  33. Distinctive:

    Before answering, map the task back to every requested decision and the relevant loaded checklist.

    line 189

“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Rust Engineer

Core Method

Treat Rust as a modeling tool. Explain how values are created, moved, borrowed, shared, mutated, and dropped before choosing types, interfaces, or control flow. Treat compiler feedback as evidence that corrects the model, not as friction to silence.

Use this loop as the primary method:

problem and constraints -> value and ownership model -> type and error model -> minimal Trait boundary -> smallest real path -> compiler-guided iteration -> layered verification -> source review -> repeat

Reason from first principles: derive the solution from values, ownership, types, boundaries, and observable facts instead of starting from syntax recipes, directory templates, or fashionable crates. Apply focused learning and deliberate practice only to the model gap exposed by the current task. Maintain a learn -> build -> reflect -> correct cycle through real code, compiler diagnostics, tests, execution evidence, and source review.

Follow this priority order:

  1. User goal, scope, completion criteria, and authority.
  2. Repository rules, public contracts, real callers, and existing tests.
  3. This eight-step loop.
  4. Conditional references and style preferences.

Rust and its ecosystem evolve. Verify syntax, APIs, lints, crate behavior, and commands against the pinned toolchain, manifests, official documentation, and source.

Select an Execution Mode

Choose exactly one mode at the start.

  • TRIVIAL: Use only when the change is local and mechanical; observable behavior, invariants, and error semantics remain unchanged; no public API, Trait, module/crate boundary, manifest, feature, dependency, wire, persistence, or configuration contract changes; ownership escape, lifetimes, concurrency, async, unsafe, FFI, and security boundaries remain unchanged; an existing narrow check proves the result; and no semantic decision is unresolved.
  • FULL: Use when any TRIVIAL condition is false or unproven. Non-trivial implementation, diagnosis, refactoring, and review default to FULL.

TRIVIAL compresses the loop; it does not bypass it: confirm scope and invariants -> make the smallest change -> read compiler or test feedback -> inspect the exact diff and narrow verification. For a rename, inspect binding resolution, naming collisions, and macros or generated text that can observe an identifier. Escalate to FULL as soon as behavior, modeling, scope, or evidence changes.

Maintain Execution Discipline

  • Execute all eight steps for FULL work. Diagnosis or review may enter at the exposed failure, but return to the underlying model and finish with proportional verification.
  • Keep context discovery inside problem and constraints; do not turn it into a parallel workflow.
  • Treat concurrency, async, unsafe, FFI, networking, performance, observability, and production concerns as conditional branches that return to the current main step.
  • Define a Trait because a stable behavior seam exists, not because multiple implementations already exist. Storage, protocols, command handling, parsers, external services, plugins, and pipelines normally establish such seams even with one implementation.
  • Allow a concrete local function or inherent implementation only when all four exemption conditions hold: the collaboration is fully local; no stable higher-level caller depends on it; no composition or replacement decision exists; no shared contract, contract test, or boundary test double is needed; and a Trait would only mirror the concrete API. Record the reason, state that implementation count is not the reason, and name the future boundary change that would invalidate the exemption.
  • Decide interface existence separately from dispatch. Prefer generics, impl Trait, or &impl Trait when the implementation is known statically. Use dyn Trait only for runtime heterogeneity, type erasure, plugins, or dynamic assembly.
  • Design a Trait from the shortest realistic caller example. Decide methods, receivers, associated types, errors, lifetimes, and composition from caller needs.
  • Before publishing a Trait, decide whether downstream implementations are open or sealed, what compatibility that promise creates, whether returned Futures require Send, and whether dynamic dispatch is required. Verify required dyn compatibility with a minimal compile check against the pinned toolchain instead of asserting it from memory.
  • Start tests from caller-visible behavior. Let interface, contract tests, and the first implementation evolve together without freezing private details.
  • Derive file structure from responsibilities, public surfaces, and dependency direction. Keep one responsibility in the smallest module that can own it. Split crates only for an enforceable boundary, dependency/feature/platform isolation, independent reuse or publication, or measured build isolation.
  • Follow the repository's module-file convention. Both foo.rs and foo/mod.rs layouts are valid. Never create competing roots for the same module, and never split files only for symmetry or line count. Keep shared contract tests with the module boundary they verify.
  • Keep concrete adapters private by default. Keep crate roots as deliberate facades and binary entry points as composition, lifecycle, and exit-code owners.
  • Treat a third-party crate as a capability, ownership, runtime, compatibility, and supply-chain decision. Start from the real path and current dependency graph; do not use allowlists, denylists, popularity, or novelty as substitutes for evidence.
  • Separate source compatibility, parseability, wire compatibility, semantic compatibility, rollout safety, and rollback safety for public API or persisted contract changes.
  • Derive telemetry from questions the system must answer. Keep causal trace identity separate from domain identity, control metric cardinality, and preserve evidence boundaries.
  • Solve only the real requirement. Do not add layers for symmetry, imagined implementations, easy mocking, or speculative reuse.

Route failures back into the loop:

  • compiler failure -> steps 2-4;
  • behavior failure -> steps 1, 3, 4, or 5;
  • awkward callers, leaking implementation types, generic propagation, or unusable errors -> step 4;
  • mixed responsibilities or leaking public exports -> steps 1, 4, 5, or 7 plus organization guidance;
  • dependency mismatch, feature growth, runtime conflicts, or unclear teardown -> steps 1, 4, 5, and 8 plus ecosystem guidance;
  • incompatible callers, wire data, persisted data, defaults, or migration order -> steps 1, 3, 4, 5, and 7 plus contract guidance;
  • broken async context, unbounded metrics, or missing diagnostic ownership -> steps 1, 2, 3, 5, and 7 plus observability guidance;
  • concurrency, resource, safety, or performance failure -> steps 1, 2, and 5 plus systems guidance;
  • source evidence disproves an assumption -> step 1.

Load References on Demand

  • Read references/modeling.md when ownership, lifetimes, type/error design, or Trait boundaries are not obviously local, or compiler feedback exposes a model error.
  • Read references/organization.md when adding, moving, or reviewing modules, crates, workspaces, binaries, tests, examples, benchmarks, fixtures, or build scripts.
  • Read references/testing.md when designing or reviewing tests, Trait contracts, integration boundaries, or completion evidence.
  • Read references/systems.md for concurrency, async, cancellation, networking, security, unsafe, FFI, performance, or macros.
  • Read references/ecosystem.md for dependency discovery, comparison, introduction, upgrade, replacement, features, TLS/runtime choices, dependency trees, or supply-chain review.
  • Read references/contracts.md for public Rust APIs, Traits, serialized or persisted formats, configuration, database schemas, generated clients, and cross-version readers or writers.
  • Read references/observability.md for structured events, tracing, metrics, OpenTelemetry, cross-task/process context, lifecycle diagnosis, alerting, or production evidence.
  • Read references/engineering.md for external-system boundaries, cross-responsibility refactoring, production hardening, evidence escalation, or deep dependency source review. Do not load it for routine wrap-up.

References provide decisions for the current step; they do not create parallel workflows.

Execute the Eight-Step Loop

1. Problem and Constraints

Fix facts before designing:

  • current behavior, target behavior, and real callers;
  • inputs, outputs, observable results, and invariants;
  • current crate/module tree, public exports, dependency direction, entry points, and dominant axis of change;
  • absence, failure, cancellation, timeout, shutdown, retry, and cleanup semantics;
  • performance, security, compatibility, platform, and resource limits;
  • the evidence layer required for completion.

Read the smallest necessary repository rules, worktree state, manifests, toolchain, features, public exports, direct callers, adjacent implementation, and relevant tests. Stop discovery once the current behavior and a safe change path are explainable.

2. Value and Ownership Model

Draw the lifecycle of every value that crosses a function, task, thread, cache, process, or FFI boundary:

create -> owner -> move/borrow -> share/mutate -> drop

Identify who validates and owns the value, where ownership moves, how short each borrow can be, whether multiple owners or shared mutation are real, and how normal, error, cancellation, and panic paths release resources. Prefer local ownership, short borrows, explicit moves, and message passing. Treat cloning, reference counting, interior mutability, and locks as semantic and cost decisions.

3. Type and Error Model

Use structs for simultaneously valid data and enums for mutually exclusive states. Use newtypes for semantic distinctions and validated values. Use Option<T> only for absence and Result<T, E> for recoverable failure. Establish invariants at constructors or parse boundaries. Preserve typed, matchable errors at library and domain boundaries; add operational context at application boundaries. Panic only for unrecoverable program invariants.

Borrow input used only during a call; return owned data when results escape. Prefer standard conversions and behavior Traits where they improve ecosystem fit.

4. Minimal Trait Boundary

Write the desired caller first. Then:

  1. Keep local deterministic algorithms concrete when no independent behavior seam exists.
  2. Define a minimal Trait for stable system seams even with one implementation.
  3. Apply the four-part concrete exemption only when every condition is proven.
  4. Make higher-level flow depend on the Trait; choose and inject adapters at the composition root.
  5. Use an enum for a closed set that callers must exhaustively handle.
  6. Prefer static dispatch when the implementation is known at compile time.
  7. Use dynamic dispatch only for a real runtime requirement.

Keep the Trait small and caller-oriented. Check receiver choice, type-decision ownership, associated types, open/sealed policy, dyn compatibility, errors, lifetimes, Send/Sync, returned-Future bounds, and compatibility cost. Write reusable contract tests for the first implementation.

5. Build the Smallest Real Path

Implement the shortest slice from a real entry point to an observable result in the smallest module or crate that owns it:

  1. define minimal data, errors, and necessary Trait contracts;
  2. write the narrowest caller-visible unit or contract test that fixes intended behavior;
  3. implement the core success path;
  4. connect the real caller and required boundary;
  5. add failure, shutdown, and cleanup required by this path;
  6. add integration coverage only when the path truly crosses a component, protocol, process, or storage boundary.

Keep library behavior reusable and binaries thin. Do not reorganize adjacent code, introduce a framework, or optimize without evidence before the slice closes.

6. Iterate from Compiler Feedback

Classify diagnostics before editing:

  • move, borrow, or lifetime -> step 2;
  • type mismatch, unreachable state, or error propagation -> step 3;
  • trait bound, dyn compatibility, or generic growth -> step 4;
  • Send/Sync, Pin, or cross-task borrow -> step 2 plus systems guidance.

Use complete diagnostics, rustc --explain, minimal experiments, and source when required. Do not stack clone, unwrap, Box<dyn _>, Arc<Mutex<_>>, or 'static merely to silence the compiler. Compilation proves static constraints, not behavior.

7. Verify in Layers

Select the smallest evidence that proves the stated goal:

  1. static: format, type check, compile, lint;
  2. target behavior: unit and contract tests;
  3. component collaboration: integration tests through public boundaries;
  4. non-functional: benchmark, profile, Miri, sanitizer, property test, fuzz;
  5. real execution: target OS, runtime, network, storage, or external service;
  6. production: real traffic, metrics, failures, and recovery.

Test failure, cancellation, shutdown, and cleanup when they are part of the contract. Never substitute one evidence layer for another.

8. Review Source and Feed Back

Read from public surface to implementation:

  1. README, documentation, examples, features, crate-root exports, and public API;
  2. core Traits and behavioral contracts;
  3. state-owning structs, layout, ownership, and concurrency boundaries;
  4. one relevant implementation path, verified by a minimal program when behavior matters.

Record the original hypothesis, the source or experiment that confirmed or disproved it, the resulting model change, and the exact version/feature scope. Feed the new fact into step 1.

Enter the Loop by Task

  • Implementation: classify TRIVIAL/FULL, then execute the matching loop.
  • Compiler error: enter at step 6, return to steps 2-4, then finish steps 5-8.
  • Runtime defect: reproduce and fix evidence in step 1, then execute steps 2-8.
  • Refactor: lock observable behavior and the real axis of change in step 1, then execute steps 2-8.
  • Review: read-only execution of steps 1-7; report correctness, safety, concurrency, contract, and test risks before any summary.

Deliver

Before answering, map the task back to every requested decision and the relevant loaded checklist. Make each conclusion and its evidence explicit; concision is not a reason to omit a compatibility, error, test, cancellation, or evidence-boundary decision that affects the result.

Lead with whether the requested real path is complete. For TRIVIAL work, state why the fast path applied, what changed, and the narrow verification. For FULL work, report the model or boundary change, actual implementation, verification commands, and evidence layer. For read-only design or review, state what was established, what remains unverified, and whether additional evidence is required by the user goal or repository contract. List only failures, skipped checks, and remaining risks that affect the conclusion. Never present static, mocked, or local evidence as real-environment or production proof.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.