agentleFS
korniakornia/kornia-rs/.claude/skills/kornia-coding-style/SKILL.md

kornia-coding-style

Skill748 starsChanged 7 days agoApache-2.0View on GitHub

Use when writing or reviewing Rust in kornia-rs — naming (<output>_from_<input>), error handling with thiserror, no unwrap/expect in library code, rustdoc structure, SAFETY comments, const instead of magic numbers, test layout. Trigger on any Rust edit under crates/.

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

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

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

    Run cargo fmt and clippy (-D warnings) before every commit.

    line 8
  2. Very specific:

    Every pub item has ///; every crate has //!

    line 29
  3. Very specific:

    Avoid unsafe. Every unsafe block is preceded by // SAFETY: explaining why it is sound.

    line 37

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “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

kornia-rs coding style

Run cargo fmt and clippy (-D warnings) before every commit.

Naming

  • Functions/variables snake_case, types PascalCase.
  • Conversions are <output>_from_<input>: gray_from_rgb, rgb_from_gray, bgr_from_rgb. Never rgb_to_gray / gray_to_rgb.
  • Metadata APIs use *_layout (e.g. ImageLayout), not *_info.
  • Domain-specific names (image_src, homography_dst), not data, helper.

Errors

  • Library crates use thiserror error enums (e.g. ImageError); no anyhow.
  • No unwrap(), expect(), panic!() in library code; propagate with ?. Constructors that can fail return Result.
  • Variants carry context (SizeMismatch { expected, got }), never Generic("failed").
  • Tests may unwrap, but prefer -> Result<(), Box<dyn Error>> with ?.

Documentation

Every pub item has ///; every crate has //!. Public functions require # Arguments, # Returns, # Errors sections, plus a compilable # Example for non-trivial APIs (runs as a doctest: cargo test --doc -p <crate>). Comments state invariants/rationale only — no obvious comments, no AI/prompt commentary, English only.

Safety

Avoid unsafe. Every unsafe block is preceded by // SAFETY: explaining why it is sound. Prefer bytemuck/zerocopy over raw pointers. No transmute/const-casting without a soundness argument.

Other conventions

  • Replace numeric literals used as thresholds, borders or loop bounds with named consts.
  • Return domain structs, not tuples of loosely related Vecs; use Option for empty results.
  • Borrow instead of .clone(); never clone images/tensors needlessly.
  • Pre-allocated &mut outputs, no allocation in hot paths, iterators over index loops, match on enums rather than strings.
  • Tests live in #[cfg(test)] modules, deterministic and focused.
  • Reuse existing kornia-rs utilities instead of reimplementing them (procedure: kornia-code-review section 0b).
  • New dependencies: minimal, mind build time and binary size.

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.