agentleFS
DankosikDankosik/cargo-modernize/.agents/skills/rust-structural-quality/SKILL.md

rust-structural-quality

Skill0 starsChanged 5 days agoApache-2.0View on GitHub

Deletion test. Use when adding a crate, module, trait, layer, helper, or parallel path, deciding placement, or consolidating scattered rules.

The file

Files
SKILL.md

Rust Structural Quality

Deletion test. Judge every structure by the responsibility it owns and the facts a reader or caller must coordinate. Keep it when its interface makes that responsibility easier to understand, preserve, or change; collapse it when it merely relocates the same reasoning.

Crate and module boundaries. Follow the workspace structure in AGENTS.md: engine logic in cargo-modernize-core, CLI orchestration in cargo-modernize, maintainer tooling in xtask, and rule data in catalog/. Add a crate only for a present dependency-direction, compile-time, or lifecycle boundary; split modules by coherent responsibility or authority rather than line count, and create directories alongside their first real artifact.

Polymorphism. Choose a concrete type for fixed behavior, an enum for closed alternatives, generics for required static variation, and dyn when consumers need type erasure or heterogeneous storage, weighing API, binary-size, and compile-time trade-offs. Reuse fitting standard traits, collapse single-implementation traits introduced solely for internal mocking, and require macros to earn what functions, generics, or traits cannot express cleanly.

Functions and receivers. Extract a single-caller private function when its signature expresses a complete decision (such as a validation or transformation) without reading its body; keep trivial forwarding and local-state fragments inline. Use methods for meaningful receivers, plain functions for stateless one-shot operations, and private context structs where grouped state clarifies ownership, collapsing one-off Drop-closure or trait-adapter wrappers satisfied by std or declared crates unless they enforce a cross-function invariant; see the responsibility examples. Treat broad names (manager, service, helpers) as prompts to inspect ownership rather than automatic defects.

Co-change and single ownership. Trace one realistic change: pieces that must change together through a copied rule, implicit call order, or split state belong under one owner or a compiler/test check. Keep parser access behind the core syntax adapter and prefer catalog data over hard-coded per-rule branches when a rule can be expressed declaratively. Exhaustive matches already surface new variants, independent similar text may stay separate, and flag-accumulating helpers warrant checking whether responsibilities diverged.

Coupling and surface area. Reduce coupling before adding layers by tightening visibility, narrowing parameters or results, or moving decisions to the existing owner (scan planner, matcher, conflict resolver, renderer, or adapter). Keep public APIs minimal and single-path while using internal re-exports freely for crate layout. Retain shims or fallbacks only with an accepted requirement, owner, observable trigger, and removal condition, and verify where rollback or error-mapping guarantees live before collapsing a container or wrapper. Judge structure by ownership and behavior rather than line-count or syntax taste.

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.