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
- Very specific: line 31
Note: All of these checks are enforced in CI via .github/workflows/rust.yml.
- Very specific: line 34
Follow standard Rust formatting (use cargo fmt)
- Very specific: line 35
All code must pass cargo clippy with no warnings (enforced with -D warnings)
- Distinctive: line 36
Use the Rust 2024 edition features
- Very specific: line 39
Use conditional compilation with cfg attributes for platform-specific code
- Distinctive: line 40
Keep the public API minimal and focused on the core functionality
- Very specific: line 43
Use the custom Error enum defined in lib.rs with variants:
- Very specific: line 47
Always convert platform errors to our custom error types with context using .map_err()
- Very specific: line 50
All tests must pass with cargo test --verbose
- Distinctive: line 56
When adding features, ensure they are optional and don't break existing functionality
- Distinctive: line 62
DO NOT: add new dependencies unless absolutely necessary
- Very specific: line 63
DO NOT: add platform-specific code outside of the designated modules (unix.rs, windows.rs)
- Distinctive: line 64
DO NOT: remove or weaken the CI checks (fmt, clippy, build, test)
- Distinctive: line 71
Windows: No pre-write check - will overwrite existing registry value without error
- Distinctive: line 75
All public APIs must have doc comments
- Distinctive: line 77
Keep the README.md up to date with API changes
- Very specific: line 78
Use //! for module-level documentation
- Very specific: line 79
Use /// for function/struct/enum documentation
≈ “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.
Files
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 UUIDsserde(v1.0) - optional, for serialization supportthiserror(v2.0) - for error handlingwinreg(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/deviceidor$HOME/.cache/Microsoft/DeveloperTools/deviceid - macOS: Stores in
$HOME/Library/Application Support/Microsoft/DeveloperTools/deviceid
- Linux: Stores in
- Windows: Uses Windows Registry (
src/windows.rs)- Registry path:
HKEY_CURRENT_USER\SOFTWARE\Microsoft\DeveloperTools - Registry key:
deviceid
- Registry path:
Build, Test, and Lint Commands
Always run these commands in order before committing:
- Format check:
cargo fmt -- --check - Linting:
cargo clippy -- -D warnings - Build:
cargo build --verbose - 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 clippywith no warnings (enforced with-D warnings) - Use the Rust 2024 edition features
- Error handling should use the
thiserrorcrate and the definedErrorenum - Maintain platform-specific code in separate modules (
unix.rsandwindows.rs) - Use conditional compilation with
cfgattributes for platform-specific code - Keep the public API minimal and focused on the core functionality
Error Handling Standards
- Use the custom
Errorenum defined inlib.rswith variants:StorageError: For file I/O or registry errorsBadUuidFormat: For UUID parsing errorsAlreadySet: 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 ofDevDeviceId- 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
AlreadySeterror when attempting to store if file already exists - Windows: No pre-write check - will overwrite existing registry value without error
- Unix: Implements file locking check - returns
- 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.mdup 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
deviceidbut the struct name isDevDeviceId(matching the specification) - UUID generation uses v4 (random) UUIDs via the
uuidcrate
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.

