agentleFS
Microsoft AzureKnown publisherAzure/azihsm-sdk/.github/copilot-instructions.md

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
  1. Distinctive:

    Read the full issue/task description and relevant comments before making changes.

    line 21
  2. Distinctive:

    If requirements are unclear or acceptance criteria are missing, ask for clarification instead of guessing.

    line 22
  3. Distinctive:

    Keep changes minimal and scoped to the request.

    line 23
  4. Distinctive:

    Prefer existing patterns and APIs.

    line 24
  5. Very specific:

    Add or update tests when behavior changes, and update api/native/doc/ for public API changes.

    line 25
  6. Distinctive:

    Run targeted checks for modified areas (see build, test, and formatting commands below).

    line 26
  7. Very specific:

    Never commit generated artifacts (for example target/, bld/, or Generated Files/).

    line 27
  8. Distinctive:

    Before running any commands in this document for the first time, restore required dependencies using these steps:

    line 30
  9. Distinctive:

    Before running any commands below, ensure you have finished the initial setup steps.

    line 46
  10. Distinctive:

    Always run formatting checks before committing:

    line 78
  11. Distinctive:

    Always run copyright checks before committing:

    line 84
  12. Very specific:

    Run cargo xtask cbindgen (no --fix) to verify the committed header is up to date.

    line 98
  13. Distinctive:

    Follow Rust best practices and idiomatic patterns

    line 121
  14. Distinctive:

    Write unit tests for new functionality

    line 123
  15. Distinctive:

    Document public APIs and complex logic

    line 124
  16. Very specific:

    Update documentation in api/native/doc/ folder when adding features or changing behavior

    line 125
  17. Distinctive:

    Ensure private keys, secrets, and sensitive data are handled securely and never logged anywhere.

    line 133
  18. Distinctive:

    Avoid taking new external dependencies, especially those that significantly increase binary size

    line 137
  19. Distinctive:

    Ensure code doesn't panic across trust boundaries

    line 138
  20. Distinctive:

    Add AZIHSM Integration test cases for interesting integration points

    line 142

≈ “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

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 implementation
  • api/tests/cpp/ - Google test integration tests for AZIHSM SDK C API
  • crates/ - Shared support libraries
  • ddi/ - Device Data Interface components for interacting with AZIHSM hardware
  • ddi/sim/ - AZIHSM functional simulator
  • plugins/ossl_prov/ - OpenSSL Provider implementation
  • xtask/ - 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/, or Generated 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-config

For both Linux and Windows systems, run the following to install all other required dependencies:

cargo xtask precheck --setup

Build Commands

Before running any commands below, ensure you have finished the initial setup steps.

Building

Build the project using Cargo xtask:

cargo xtask build

Build 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/ and api/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 --fix

It auto fixes formatting issues. This ensures all source code follows rustfmt standards.

Always run copyright checks before committing:

cargo xtask copyright --fix

It 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 --fix

Run 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 --all

It 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

  1. Follow Rust best practices and idiomatic patterns
  2. Maintain existing code structure and organization
  3. Write unit tests for new functionality
  4. Document public APIs and complex logic
  5. 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:

  1. Avoid unsafe code
  2. Avoid taking new external dependencies, especially those that significantly increase binary size
  3. 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

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.