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
- Very specific: line 8
Run cargo fmt and clippy (-D warnings) before every commit.
- Very specific: line 29
Every pub item has ///; every crate has //!
- Very specific: line 37
Avoid unsafe. Every unsafe block is preceded by // SAFETY: explaining why it is sound.
≈ “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.
Files
kornia-rs coding style
Run cargo fmt and clippy (-D warnings) before every commit.
Naming
- Functions/variables
snake_case, typesPascalCase. - Conversions are
<output>_from_<input>:gray_from_rgb,rgb_from_gray,bgr_from_rgb. Neverrgb_to_gray/gray_to_rgb. - Metadata APIs use
*_layout(e.g.ImageLayout), not*_info. - Domain-specific names (
image_src,homography_dst), notdata,helper.
Errors
- Library crates use
thiserrorerror enums (e.g.ImageError); noanyhow. - No
unwrap(),expect(),panic!()in library code; propagate with?. Constructors that can fail returnResult. - Variants carry context (
SizeMismatch { expected, got }), neverGeneric("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; useOptionfor empty results. - Borrow instead of
.clone(); never clone images/tensors needlessly. - Pre-allocated
&mutoutputs, 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-reviewsection 0b). - New dependencies: minimal, mind build time and binary size.
In this repository11 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- kornia-api-flavorSkill
- kornia-archSkill
- kornia-bindingsSkill
- kornia-code-reviewSkill
- kornia-curationSkill
- kornia-simdSkill
- kornia-workflowSkill
- releaseSkill
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
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.

