documenting-rust-code
Guidelines for writing high-quality Rust documentation following industry standards.
Install
mkdir -p .claude/skills/documenting-rust-code && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/3502" && unzip -o skill.zip -d .claude/skills/documenting-rust-code && rm skill.zipInstalls to .claude/skills/documenting-rust-code
Activation
This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.
Rust documentation practices for HASH codebase. Use when writing doc comments, documenting functions/types/traits/modules, creating error sections, using intra-doc links, or following rustdoc conventions.Key capabilities
- →Write doc comments with summaries
- →Create intra-doc links for types
- →Document error conditions
- →Include practical API examples
- →Format module-level documentation
How it works
The skill enforces rustdoc conventions by requiring summaries, error sections, and intra-doc links for all public APIs.
Inputs & outputs
When to use documenting-rust-code
- →Write module doc comments
- →Add error sections to documentation
- →Link to standard library types
- →Document a public trait
About this skill
Rust Documentation Practices
Comprehensive guidance on documenting Rust code in the HASH repository following rustdoc conventions.
Core Principles
Follow high-quality standards like time, jiff, and serde:
✅ DO:
- Begin every doc comment with single-line summary
- Use intra-doc links for all type references
- Document all error conditions with
# Errors - Include practical examples for public APIs
- Link standard library types: [
Vec], [HashMap], etc. - Use inline parameter descriptions for simple functions (0-2 params)
- Describe return values in main text, not separate sections
❌ DON'T:
- Document standard trait implementations (
Debug,Display,From) - Add separate
# Returnssections (inline instead) - Mention variable types already in signatures
- Use comments on same line as code
- Skip error documentation for fallible functions
Quick Reference
Basic Doc Comment
/// Retrieves an entity by its UUID.
///
/// Loads the entity from the store and verifies access permissions.
/// Returns the [`Entity`] if found and accessible.
///
/// # Errors
///
/// - [`NotFound`] if the entity doesn't exist
/// - [`AuthorizationError`] if access is denied
///
/// [`NotFound`]: EntityError::NotFound
/// [`AuthorizationError`]: EntityError::Authorization
pub fn get_entity(&self, id: EntityId) -> Result<Entity, Report<EntityError>> {
Intra-Doc Links
/// Updates the [`User`] using [`UserUpdateStrategy`].
///
/// See [`validation::user`] for validation rules.
///
/// [`validation::user`]: crate::validation::user
Documentation Patterns
Simple Functions (0-2 params)
Describe parameters inline:
/// Processes the `input` elements and returns filtered results.
///
/// Takes a collection of `input` elements, applies the `filter_fn`,
/// and returns a [`Vec`] containing only matching elements.
Complex Functions (3+ params)
Use explicit # Arguments section:
/// Merges multiple data sources with transformation rules.
///
/// # Arguments
///
/// * `sources` - Collection of data sources to merge
/// * `rules` - Transformation rules to apply
/// * `options` - Configuration controlling merge behavior
/// * `callback` - Optional function for each merged item
Error Documentation
/// # Errors
///
/// - [`WebAlreadyExists`] if web ID is taken
/// - [`AuthorizationError`] if permission denied
///
/// [`WebAlreadyExists`]: WebError::WebAlreadyExists
/// [`AuthorizationError`]: WebError::Authorization
Module Documentation
//! Entity management functionality.
//!
//! Main types:
//! - [`Entity`] - Core entity type
//! - [`EntityStore`] - Storage trait
//!
//! # Examples
//!
//! ```
//! use hash_graph::entity::Entity;
//! ```
Examples with Error Handling
/// # Examples
///
/// ```rust
/// let entities = get_entities_by_type(type_id)?;
/// assert_eq!(entities.len(), 2);
/// # Ok::<(), Box<dyn core::error::Error>>(())
/// ```
Verification
cargo doc --no-deps --all-features
References
- references/function-documentation.md: Functions and methods documentation patterns
- references/type-documentation.md: Types, structs, enums, and traits documentation
- references/error-documentation.md: Error conditions and panics documentation
- references/examples-and-links.md: Examples and intra-doc links usage
When not to use it
- →Documenting standard trait implementations
Prerequisites
Limitations
- →Requires manual maintenance of doc comments
- →Limited to Rust documentation conventions
How it compares
It mandates a high-quality standard similar to major Rust crates, ensuring consistency across the entire codebase.
Compared to similar skills
documenting-rust-code side by side with the closest alternatives in the catalog.
| Skill | Installs | Updated | Safety | Difficulty |
|---|---|---|---|---|
| documenting-rust-code (this skill) | 1 | 2mo | Review | Beginner |
| review-rust-docs | 1 | 5mo | No flags | Beginner |
| deepwiki-rs | 25 | 9mo | Review | Intermediate |
| code-review | 0 | 6mo | No flags | Intermediate |
Try saying
Example prompts that trigger this skill in your AI assistant.
More by hashintel
View all by hashintel →You might also like
review-rust-docs
RediSearch
Review the documentation of a Rust crate to ensure it meets our requirements and standards.
deepwiki-rs
sopaco
AI-powered Rust documentation generation engine for comprehensive codebase analysis, C4 architecture diagrams, and automated technical documentation. Use when Claude needs to analyze source code, understand software architecture, generate technical specs, or create professional documentation from any programming language.
code-review
jonatron55
Instructions for reviewing changes and ensuring quality before completion. Use when asking for a review or before committing changes.
rust-docs-guidelines
RediSearch
Guidelines for writing Rust documentation
write-documentation
r3bl-org
Write and format Rust documentation correctly. Apply proactively when writing code with rustdoc comments (//! or ///). Covers voice & tone, prose style (opening lines, explicit subjects, verb tense), structure (inverted pyramid), intra-doc links (crate:: paths, reference-style), constant conventions (binary/byte literal/decimal), and formatting (cargo rustdoc-fmt). Also use retroactively via /fix-intradoc-links, /fix-comments, or /fix-md-tables commands.
doc-cli-usage
BA-CalderonMorales
Use the Rust-based documentation CLI for common tasks.