agentleFS
vivienmvivienm/skills/rust-conventions/SKILL.md

rust-conventions

Skill0 starsChanged 30 days agoMITView on GitHub

Apply personal Rust coding conventions when adding or substantially rewriting Rust code. Do not use to enforce style on unchanged code.

4 other projects use a version of this.

Adopted by

Most recently taken up by

  • Other versions4 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 4

    1. static-web-server/static-web-server★ 2.4ksame name
    2. leroyguillaume/claude★ 7same name
    3. fielding/skills★ 1same name
    4. flntfnd/claude-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository2 other files it gives its agents.

The file

We split this skill into the rules it gives an agent

9 rules. 0 are common, 3 are distinctive, and 6 are very specific to this project.

  • 0

    Common

    Most of the 4 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Place use imports before mod foo.

    line 19
  2. Distinctive:

    Prefer imports that keep module bodies readable.

    line 26
  3. Distinctive:

    Do not wait for a name to occur multiple times before importing it.

    line 28
  4. Very specific:

    Import distinctive types directly, such as Path, HashMap, Arc, Duration, and PhantomData.

    line 30
  5. Very specific:

    Import utility modules such as io, fs, env, and process when useful.

    line 33
  6. Very specific:

    Keep meaningful qualifiers such as io::Result, io::Error, io::ErrorKind, and fs::read_to_string, rather than importing every member …

    line 34
  7. Distinctive:

    Keep fully qualified paths when they improve clarity.

    line 51
  8. Very specific:

    When practical, functions and methods that accept a filesystem path should use a generic parameter bounded by AsRef<Path> instead of &Path, …

    line 93
  9. Very specific:

    When deriving any of the following traits, use this relative order: Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Display, …

    line 99

“Common” is measured: kept by at least 6 in 10 of the 4 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 conventions

Apply these preferences only to code you add or substantially rewrite, unless repository instructions specify otherwise. Do not flag or change existing code solely to enforce them, including code copied or moved unchanged.

Modules

For modules with submodules, prefer foo.rs over foo/mod.rs.

Place use imports before mod foo; declarations; preserve any ordering required by macros.

Imports

Choosing what to import

Prefer imports that keep module bodies readable. Import a commonly used type or trait directly, or import its module when that gives a useful short qualifier. Do not wait for a name to occur multiple times before importing it.

  • Import distinctive types directly, such as Path, HashMap, Arc, Duration, and PhantomData. Prefer Path over std::path::Path or path::Path in signatures and expressions.
  • Import utility modules such as io, fs, env, and process when useful. Keep meaningful qualifiers such as io::Result, io::Error, io::ErrorKind, and fs::read_to_string, rather than importing every member directly. This can coexist with direct imports such as File, Read, and Write: use fs::{self, File} or io::{self, Read}.
  • For formatting implementations, prefer fmt::{self, Formatter} and write Formatter and fmt::Result. Import Display or Debug directly when useful.
  • Apply the same readability criterion to external crates and local modules. A module qualifier can distinguish related APIs, as in mpsc::Sender and oneshot::Sender, or identify a domain, as in image::Error.
  • For traits needed only for method resolution, prefer as _ when their name is otherwise unnecessary, e.g. use anyhow::Context as _; or use std::fmt::Write as _;. Keep named imports for traits used in bounds or implementations.

Resolve collisions, including with derive macros, with a meaningful module qualifier or descriptive alias, such as error::Error or Error as StdError. Keep fully qualified paths when they improve clarity; occasional utility calls and derive macro paths need not all become imports. Import only what is used.

For example:

use std::{fs, io, path::Path};

fn read_config<P: AsRef<Path>>(path: P) -> io::Result<String> {
    fs::read_to_string(path)
}

Grouping and layout

  • For imports from the current module, prefer use self::foo over use foo.
  • Organize imports into three groups: standard library (std, core, alloc), external crates, and local imports (self, super, crate), in that order. Separate groups with a blank line.
  • Within each group, combine imports from the same crate into a single use declaration, using nested brace trees to factor out shared path prefixes. Apply the same grouping to local imports sharing a crate, self, or super root. Keep imports with different visibility or attributes separate.

For example:

use std::sync::{
    atomic::{AtomicI64, Ordering},
    Arc, Mutex,
};

use crate::{
    config::{Config, Mode},
    input::Reader,
    output::{Format, Writer},
    storage::Store,
};

Path parameters

When practical, functions and methods that accept a filesystem path should use a generic parameter bounded by AsRef<Path> instead of &Path, especially in public APIs. Use path.as_ref() inside the body when a &Path is needed.

Derives

When deriving any of the following traits, use this relative order: Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash, Debug, Display, Default. Place any other derived traits after these, with traits from external crates (e.g. Serialize, Deserialize) first, followed by traits from the local crate (e.g. CrateSpecificTrait).

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.