azihsm-sdk
Copilot instructions3 starsChanged 3 months agoMITView on GitHub
For Linux systems, first install the following 4 Linux packages with the package manager of the distribution: For both Linux and Windows systems, run the following to install all other required dependencies: Build specific packages using: It auto fixes formatting issues. This ensures all source code follows rustfmt standards. Always run copyright checks before committing: It auto fixes copyright issues. This ensures all source code has correct copyright headers. Run cargo xtask cbindgen (no --fix) to verify the committed header…
The file
Show its rules and text
We split this copilot-instructions.md into the rules it gives an agent
20 rules. About 0 are common, 16 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈16
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
- could be automatic: a setting could enforce it
- Distinctive: line 21
Read the full issue/task description and relevant comments before making changes.
- Distinctive: line 22
If requirements are unclear or acceptance criteria are missing, ask for clarification instead of guessing.
- Distinctive: line 23
Keep changes minimal and scoped to the request.
- Distinctive: line 24
Prefer existing patterns and APIs.
- Very specific: line 25
Add or update tests when behavior changes, and update api/native/doc/ for public API changes.
- Distinctive: line 26
Run targeted checks for modified areas (see build, test, and formatting commands below).
- Very specific: line 27
Never commit generated artifacts (for example target/, bld/, or Generated Files/).
- Distinctive: line 30
Before running any commands in this document for the first time, restore required dependencies using these steps:
- Distinctive: line 46
Before running any commands below, ensure you have finished the initial setup steps.
- Distinctive: line 78
Always run formatting checks before committing:
- Distinctive: line 84
Always run copyright checks before committing:
- Very specific: line 98
Run cargo xtask cbindgen (no --fix) to verify the committed header is up to date.
- Distinctive: line 121
Follow Rust best practices and idiomatic patterns
- Distinctive: line 123
Write unit tests for new functionality
- Distinctive: line 124
Document public APIs and complex logic
- Very specific: line 125
Update documentation in api/native/doc/ folder when adding features or changing behavior
- Distinctive: line 133
Ensure private keys, secrets, and sensitive data are handled securely and never logged anywhere.
- Distinctive: line 137
Avoid taking new external dependencies, especially those that significantly increase binary size
- Distinctive: line 138
Ensure code doesn't panic across trust boundaries
- Distinctive: line 142
Add AZIHSM Integration test cases for interesting integration points
≈ “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
AZIHSM SDK Repository
Project Overview
Azure Integrated HSM (AZIHSM) SDK is a modular, cross-platform software development kit (SDK) written in Rust. This repository is home to AZIHSM SDK, its simulator, and its OpenSSL Provider. The project focuses on creating secure, high-performance APIs.
Technology Stack
- Language: For AZIHSM SDK and simulator: Rust (using Cargo build system), C for OpenSSL Provider, C++ for Google test integration tests
- Build Tool: Cargo with custom xtask automation
- Testing Framework: Rust unit tests for Rust code + Google test unit tests for C and C++ code. All tests including Google test have to be run with cargo-nextest (recommended)
Project Structure
api/- Core AZIHSM SDK implementationapi/tests/cpp/- Google test integration tests for AZIHSM SDK C APIcrates/- Shared support librariesddi/- Device Data Interface components for interacting with AZIHSM hardwareddi/sim/- AZIHSM functional simulatorplugins/ossl_prov/- OpenSSL Provider implementationxtask/- Custom build and automation tasks
Copilot Coding Agent Guidance
- Read the full issue/task description and relevant comments before making changes.
- If requirements are unclear or acceptance criteria are missing, ask for clarification instead of guessing.
- Keep changes minimal and scoped to the request; avoid drive-by refactors or unrelated fixes.
- Prefer existing patterns and APIs; avoid introducing new dependencies unless explicitly required.
- Add or update tests when behavior changes, and update
api/native/doc/for public API changes. - Run targeted checks for modified areas (see build, test, and formatting commands below).
- Never commit generated artifacts (for example
target/,bld/, orGenerated Files/).
Initial Setup
Before running any commands in this document for the first time, restore required dependencies using these steps:
For Linux systems, first install the following 4 Linux packages with the package manager of the distribution:
clang-format-18
libbsd-dev
libssl-dev
pkg-configFor both Linux and Windows systems, run the following to install all other required dependencies:
cargo xtask precheck --setupBuild Commands
Before running any commands below, ensure you have finished the initial setup steps.
Building
Build the project using Cargo xtask:
cargo xtask buildBuild specific packages using:
# Build specific packages you are modifying
cargo xtask build --package <package-name>Testing
Before running any commands below, ensure you have finished the initial setup steps.
Unit Tests
Use cargo-nextest (recommended):
# Run tests in specific packages you are modifying against simulator
cargo xtask nextest --features mock --package <package-name>Test Types
- Unit tests: Spread throughout crates, marked by
#[cfg(test)]blocks - AZIHSM Integration tests: Integration tests are in
ddi/lib/tests/andapi/tests/
Linting and Formatting
Before running any commands below, ensure you have finished the initial setup steps.
Required Before Each Commit
Always run formatting checks before committing:
cargo +nightly xtask fmt --fixIt auto fixes formatting issues. This ensures all source code follows rustfmt standards.
Always run copyright checks before committing:
cargo xtask copyright --fixIt auto fixes copyright issues. This ensures all source code has correct copyright headers.
Generated C header
The public C header (api/native/include/azihsm_api.h) is generated from the
azihsm_api_native crate with cbindgen and checked into the repository for
review and tooling. Whenever you change the native FFI (anything exported from
api/native/src), regenerate and commit the header:
cargo xtask cbindgen --fixRun cargo xtask cbindgen (no --fix) to verify the committed header is up to
date; cargo xtask precheck --cbindgen runs the same check in CI and fails the
build if the header has drifted from the Rust source. This requires
clang-format-18 (one of the packages listed under Initial Setup) and the
pinned cbindgen installed by cargo xtask precheck --setup.
On Windows, both header generation (including --fix) and freshness checking
are skipped with an explicit message; neither cbindgen nor clang-format is run,
and the checked-in header is left unchanged. Regenerate using Linux or WSL.
Linux CI continues to enforce that the checked-in header is up to date.
Running all of the above checks
Before running any commands below, ensure you have finished the initial setup steps.
You can run all checks (setup, build, formatting, copyright, linting, tests, code coverage etc.) against simulator with:
cargo xtask precheck --allIt will run all necessary checks to ensure code quality before committing. It will not auto fix linting, formatting or copyright issues.
Code Standards
Key Guidelines
- Follow Rust best practices and idiomatic patterns
- Maintain existing code structure and organization
- Write unit tests for new functionality
- Document public APIs and complex logic
- Update documentation in
api/native/doc/folder when adding features or changing behavior
Domain-specific Guidelines
Both api/ and ddi/ process data from untrusted sources.
Trust Boundaries (critical for security):
- Code must not panic on any input
- Validate all inputs rigorously
- Ensure private keys, secrets, and sensitive data are handled securely and never logged anywhere.
When possible:
- Avoid
unsafecode - Avoid taking new external dependencies, especially those that significantly increase binary size
- Ensure code doesn't panic across trust boundaries
Testing Best Practices
- Thoroughly test code with unit tests whenever possible
- Add AZIHSM Integration test cases for interesting integration points
- Unit tests should be fast, isolated, and not require root/administrator access
- Mark tests requiring special setup with
#[ignore]for manual testing
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.

