agentleFS
MicrosoftKnown publishermicrosoft/rs-deviceid/.github/copilot-instructions.md

rs-deviceid

Copilot instructions4 starsChanged 2 months agoMITView on GitHub

Note: All of these checks are enforced in CI via .github/workflows/rust.yml.

The file

Show its rules and text

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

18 rules. About 0 are common, 8 are distinctive, and 10 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 10

    Very specific

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

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

    Note: All of these checks are enforced in CI via .github/workflows/rust.yml.

    line 31
  2. Very specific:

    Follow standard Rust formatting (use cargo fmt)

    line 34
  3. Very specific:

    All code must pass cargo clippy with no warnings (enforced with -D warnings)

    line 35
  4. Distinctive:

    Use the Rust 2024 edition features

    line 36
  5. Very specific:

    Use conditional compilation with cfg attributes for platform-specific code

    line 39
  6. Distinctive:

    Keep the public API minimal and focused on the core functionality

    line 40
  7. Very specific:

    Use the custom Error enum defined in lib.rs with variants:

    line 43
  8. Very specific:

    Always convert platform errors to our custom error types with context using .map_err()

    line 47
  9. Very specific:

    All tests must pass with cargo test --verbose

    line 50
  10. Distinctive:

    When adding features, ensure they are optional and don't break existing functionality

    line 56
  11. Distinctive:

    DO NOT: add new dependencies unless absolutely necessary

    line 62
  12. Very specific:

    DO NOT: add platform-specific code outside of the designated modules (unix.rs, windows.rs)

    line 63
  13. Distinctive:

    DO NOT: remove or weaken the CI checks (fmt, clippy, build, test)

    line 64
  14. Distinctive:

    Windows: No pre-write check - will overwrite existing registry value without error

    line 71
  15. Distinctive:

    All public APIs must have doc comments

    line 75
  16. Distinctive:

    Keep the README.md up to date with API changes

    line 77
  17. Very specific:

    Use //! for module-level documentation

    line 78
  18. Very specific:

    Use /// for function/struct/enum documentation

    line 79

≈ “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 for rs-deviceid

Project Overview

deviceid is a Rust library that provides a unique device ID for a given system, based on the devDeviceId specification. It generates or retrieves a persistent device identifier stored in platform-specific locations.

Tech Stack

  • Language: Rust (Edition 2024)
  • Minimum Rust Version: 1.88
  • Key Dependencies:
    • uuid (v1.18) - for generating v4 UUIDs
    • serde (v1.0) - optional, for serialization support
    • thiserror (v2.0) - for error handling
    • winreg (v0.55.0) - Windows-specific registry access

Platform-Specific Implementation

This crate has separate implementations for different platforms:

  • Unix/Linux/macOS: Uses file-based storage (src/unix.rs)
    • Linux: Stores in $XDG_CACHE_HOME/Microsoft/DeveloperTools/deviceid or $HOME/.cache/Microsoft/DeveloperTools/deviceid
    • macOS: Stores in $HOME/Library/Application Support/Microsoft/DeveloperTools/deviceid
  • Windows: Uses Windows Registry (src/windows.rs)
    • Registry path: HKEY_CURRENT_USER\SOFTWARE\Microsoft\DeveloperTools
    • Registry key: deviceid

Build, Test, and Lint Commands

Always run these commands in order before committing:

  1. Format check: cargo fmt -- --check
  2. Linting: cargo clippy -- -D warnings
  3. Build: cargo build --verbose
  4. Test: cargo test --verbose

Note: All of these checks are enforced in CI via .github/workflows/rust.yml.

Coding Conventions and Style

  • Follow standard Rust formatting (use cargo fmt)
  • All code must pass cargo clippy with no warnings (enforced with -D warnings)
  • Use the Rust 2024 edition features
  • Error handling should use the thiserror crate and the defined Error enum
  • Maintain platform-specific code in separate modules (unix.rs and windows.rs)
  • Use conditional compilation with cfg attributes for platform-specific code
  • Keep the public API minimal and focused on the core functionality

Error Handling Standards

  • Use the custom Error enum defined in lib.rs with variants:
    • StorageError: For file I/O or registry errors
    • BadUuidFormat: For UUID parsing errors
    • AlreadySet: When attempting to store a device ID that already exists in storage
  • Always convert platform errors to our custom error types with context using .map_err()

Testing Requirements

  • All tests must pass with cargo test --verbose
  • Platform-specific tests are located in the tests/ directory
  • Tests should verify idempotency of get_or_generate()

Features

  • serde (default feature): Enables serialization/deserialization of DevDeviceId
  • When adding features, ensure they are optional and don't break existing functionality

Restrictions and Boundaries

  • DO NOT change the storage locations (registry paths on Windows, file paths on Unix)
  • DO NOT modify the UUID format (must remain lowercase hyphenated format)
  • DO NOT introduce breaking changes to the public API without careful consideration
  • DO NOT add new dependencies unless absolutely necessary
  • DO NOT add platform-specific code outside of the designated modules (unix.rs, windows.rs)
  • DO NOT remove or weaken the CI checks (fmt, clippy, build, test)

Security Considerations

  • Device IDs are stored in user-accessible locations (not encrypted)
  • The crate assumes device ID is unlikely to be stored by multiple applications simultaneously
  • Platform behavior differences:
    • Unix: Implements file locking check - returns AlreadySet error when attempting to store if file already exists
    • Windows: No pre-write check - will overwrite existing registry value without error
  • Race conditions during concurrent writes are not handled on either platform

Documentation Standards

  • All public APIs must have doc comments
  • Examples should be provided in doc comments where helpful
  • Keep the README.md up to date with API changes
  • Use //! for module-level documentation
  • Use /// for function/struct/enum documentation

Example Code Style

// Good: Clear error handling with context (Unix file-based storage)
pub fn retrieve() -> Result<Option<DevDeviceId>> {
    let path = path()?;
    if path.exists() {
        let data = std::fs::read(path)
            .map_err(|e| super::Error::StorageError(e.to_string()))?;
        // Unix: Reads file as bytes, parses ASCII representation of UUID
        // File contains UUID string like "550e8400-e29b-41d4-a716-446655440000"
        let id = uuid::Uuid::try_parse_ascii(data.as_slice())
            .map_err(|e| super::Error::BadUuidFormat(e.to_string()))?;
        Ok(Some(DevDeviceId(id)))
    } else {
        Ok(None)
    }
}

// Good: Platform-specific parsing (Windows registry string data)
// uuid::Uuid::try_parse(&value) for string values from Windows registry

// Good: Platform-specific conditional compilation
#[cfg(target_family = "unix")]
pub use super::unix::*;
#[cfg(target_family = "windows")]
pub use super::windows::*;

Additional Notes

  • This is a Microsoft open source project following the Microsoft Open Source Code of Conduct
  • Contributors must agree to the CLA (Contributor License Agreement)
  • The crate name uses deviceid but the struct name is DevDeviceId (matching the specification)
  • UUID generation uses v4 (random) UUIDs via the uuid crate

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.