agentleFS
zircotezircote/rlm-rs/.github/copilot-instructions.md

rlm-rs

Copilot instructions62 starsChanged 10 months agoMITView on GitHub

This document provides context for GitHub Copilot when working with this Rust project. This is a Rust crate using modern tooling: - Rust: 1.95+ (2024 edition) - Build System: Cargo - Linting: clippy with pedantic and nursery lints - Formatting: rustfmt - Testing: Built-in test framework + proptest - Supply Chain Security: cargo-deny Use Result types instead of panicking: Use thiserror for custom error types: Provide explicit return types for public functions: Use doc comments with examples: rust /// use…

The file

We split this copilot-instructions.md into the rules it gives an agent

10 rules. About 0 are common, 6 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

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

    Use Result types instead of panicking:

    line 19
  2. Very specific:

    Use thiserror for custom error types:

    line 33
  3. Distinctive:

    Use doc comments with examples:

    line 69
  4. Distinctive:

    Prefer borrowing over ownership when possible:

    line 104
  5. Very specific:

    Use Cow for efficient string handling:

    line 118
  6. Distinctive:

    Use builder pattern for complex structs:

    line 134
  7. Distinctive:

    Write comprehensive unit tests:

    line 166
  8. Distinctive:

    Use proptest for property-based testing:

    line 186
  9. Distinctive:

    Use async/await with tokio:

    line 201
  10. Very specific:

    Prefer const fn for compile-time evaluation:

    line 243

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions 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
copilot-instructions.md

GitHub Copilot Instructions

This document provides context for GitHub Copilot when working with this Rust project.

Project Context

This is a Rust crate using modern tooling:

  • Rust: 1.95+ (2024 edition)
  • Build System: Cargo
  • Linting: clippy with pedantic and nursery lints
  • Formatting: rustfmt
  • Testing: Built-in test framework + proptest
  • Supply Chain Security: cargo-deny

Code Generation Guidelines

Error Handling

Use Result types instead of panicking:

// Good - Returns Result
pub fn parse_value(input: &str) -> Result<i64, ParseError> {
    input.parse().map_err(|e| ParseError::InvalidFormat(e))
}

// Avoid - Panics on failure
pub fn parse_value(input: &str) -> i64 {
    input.parse().unwrap() // Never do this
}

Use thiserror for custom error types:

use thiserror::Error;

#[derive(Error, Debug)]
pub enum AppError {
    #[error("invalid input: {0}")]
    InvalidInput(String),

    #[error("operation failed: {operation}")]
    OperationFailed { operation: String },

    #[error(transparent)]
    Io(#[from] std::io::Error),
}

Type Annotations

Provide explicit return types for public functions:

// Good - explicit return type
pub fn process_data(items: &[String]) -> Vec<ProcessedItem> {
    // implementation
}

// Avoid for public APIs
pub fn process_data(items: &[String]) -> impl Iterator<Item = ProcessedItem> {
    // implementation
}

Documentation

Use doc comments with examples:

/// Processes a list of items according to the given configuration.
///
/// # Arguments
///
/// * `items` - The items to process.
/// * `config` - Configuration options for processing.
///
/// # Returns
///
/// A vector of processed items.
///
/// # Errors
///
/// Returns [`Error::InvalidInput`] if any item is invalid.
///
/// # Examples
///
/// ```rust
/// use rlm_rs::{process, Config};
///
/// let items = vec!["a", "b", "c"];
/// let config = Config::default();
/// let result = process(&items, &config)?;
/// # Ok::<(), rlm_rs::Error>(())
/// ```
pub fn process(items: &[&str], config: &Config) -> Result<Vec<Item>> {
    // implementation
}

Ownership and Borrowing

Prefer borrowing over ownership when possible:

// Good - borrows the slice
pub fn sum_values(values: &[i64]) -> i64 {
    values.iter().sum()
}

// Avoid - takes ownership unnecessarily
pub fn sum_values(values: Vec<i64>) -> i64 {
    values.iter().sum()
}

Use Cow for efficient string handling:

use std::borrow::Cow;

pub fn normalize_name(name: &str) -> Cow<'_, str> {
    if name.contains(' ') {
        Cow::Owned(name.replace(' ', "_"))
    } else {
        Cow::Borrowed(name)
    }
}

Structs and Enums

Use builder pattern for complex structs:

#[derive(Debug, Clone, Default)]
pub struct Config {
    pub timeout: Duration,
    pub retries: u32,
    pub verbose: bool,
}

impl Config {
    #[must_use]
    pub fn new() -> Self {
        Self::default()
    }

    #[must_use]
    pub fn with_timeout(mut self, timeout: Duration) -> Self {
        self.timeout = timeout;
        self
    }

    #[must_use]
    pub fn with_retries(mut self, retries: u32) -> Self {
        self.retries = retries;
        self
    }
}

Testing

Write comprehensive unit tests:

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_add_positive_numbers() {
        assert_eq!(add(2, 3), 5);
    }

    #[test]
    fn test_divide_by_zero_returns_error() {
        let result = divide(10, 0);
        assert!(matches!(result, Err(Error::DivisionByZero)));
    }
}

Use proptest for property-based testing:

use proptest::prelude::*;

proptest! {
    #[test]
    fn add_is_commutative(a in any::<i64>(), b in any::<i64>()) {
        prop_assert_eq!(add(a, b), add(b, a));
    }
}

Async Code

Use async/await with tokio:

pub async fn fetch_data(url: &str) -> Result<Data> {
    let response = reqwest::get(url).await?;
    let data = response.json().await?;
    Ok(data)
}

Common Patterns

Iterator Chains

let result: Vec<_> = items
    .iter()
    .filter(|item| item.is_valid())
    .map(|item| item.transform())
    .collect();

Option and Result Combinators

// Option chaining
let value = config
    .get_setting("key")
    .and_then(|s| s.parse().ok())
    .unwrap_or_default();

// Result chaining with ?
fn process() -> Result<Output> {
    let data = load_data()?;
    let parsed = parse_data(&data)?;
    let result = transform(parsed)?;
    Ok(result)
}

Const Functions

Prefer const fn for compile-time evaluation:

#[must_use]
pub const fn new() -> Self {
    Self { value: 0 }
}

File Locations

  • Source code: src/
  • Library entry: src/lib.rs
  • Binary entry: src/main.rs
  • Integration tests: tests/
  • Benchmarks: benches/ (with criterion)

Commands

cargo build           # Build
cargo test            # Run tests
cargo clippy          # Lint
cargo fmt             # Format
cargo doc --open      # Generate and view docs
cargo deny check      # Check supply chain

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.