agentleFS
MicrosoftKnown publishermicrosoft/durabletask-dotnet/.github/copilot-instructions.md

durabletask-dotnet

Copilot instructions193 starsChanged 8 months agoMITView on GitHub

This repository contains C# code. The purpose of this code is to provide a standalone SDK that can be used to interact with the Durable Task coding paradigm, both through Azure Functions (Durable Functions) and non-function based Durable Task Scheduler (DTS). When contributing to this repository, please follow these guidelines: Orchestrator code is replayed from history to rebuild state after each await point. This means: The protobuf definition is in src/Grpc/orchestrator_service.proto. C# stubs are generated at build time by Grpc.Tools…

The file

Show its rules and text

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

22 rules. About 0 are common, 18 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈18

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

    When contributing to this repository, please follow these guidelines:

    line 7
  2. Distinctive:

    Do not add I/O, network calls, or file system access inside orchestrator logic.

    line 14
  3. Very specific:

    If changing TaskOrchestrationContext, FuncTaskOrchestrator, or any type under src/Abstractions/ that orchestrators call directly, verify …

    line 15
  4. Very specific:

    Run src/Grpc/refresh-protos.ps1 to pull the latest proto version from upstream.

    line 25
  5. Distinctive:

    Before renaming any file path referenced in another file, confirm the full impact with the user — do not assume file locations without …

    line 26
  6. Distinctive:

    All public methods and classes should have XML documentation comments.

    line 37
  7. Distinctive:

    No change should introduce a breaking change unless an exception is otherwise noted in the PR Summary, linked github issue, or discussion.

    line 38
  8. Very specific:

    Use this. for accessing class members.

    line 40
  9. Distinctive:

    Use the Async suffix on the name of all async methods.

    line 41
  10. Distinctive:

    Ensure that all private classes, that do not serve as base classes, are sealed.

    line 42
  11. Distinctive:

    When adding a new sample, follow these steps:

    line 48
  12. Very specific:

    Prefer inline literals over constants for values that are not reused.

    line 68
  13. Distinctive:

    Prefer defining variables using types rather than var, to help users understand the types involved.

    line 69
  14. Distinctive:

    Follow the patterns in the samples in the same directories where new samples are being added.

    line 70
  15. Distinctive:

    Add a comment describing what the sample is demonstrating.

    line 72
  16. Distinctive:

    Add Arrange, Act and Assert comments for each

    line 83
  17. Distinctive:

    Use the Moq library for mocking objects where possible.

    line 84
  18. Distinctive:

    Avoid adding excessive comments to tests.

    line 86
  19. Distinctive:

    Follow the patterns in the unit tests in the same project or classes to which new tests are being added.

    line 87
  20. Distinctive:

    When reviewing code, follow these guidelines:

    line 91
  21. Distinctive:

    Do not generate false-positive or already-resolved comments when new commits are pushed.

    line 94
  22. Distinctive:

    Do not re-post a review comment if a user has directly responded to it with justification for why the code exists as written.

    line 95

≈ “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 repository contains C# code.

The purpose of this code is to provide a standalone SDK that can be used to interact with the Durable Task coding paradigm, both through Azure Functions (Durable Functions) and non-function based Durable Task Scheduler (DTS).

When contributing to this repository, please follow these guidelines:

Replay Determinism — Critical Invariant

Orchestrator code is replayed from history to rebuild state after each await point. This means:

  • Orchestrator methods must be fully deterministic: never call DateTime.Now, Guid.NewGuid(), Random, or any non-deterministic API directly inside an orchestrator. Use context.CurrentUtcDateTime and context.NewGuid() instead.
  • Do not add I/O, network calls, or file system access inside orchestrator logic. These belong in activities.
  • If changing TaskOrchestrationContext, FuncTaskOrchestrator, or any type under src/Abstractions/ that orchestrators call directly, verify the change does not break replay of existing history.
  • Source generator output in src/Generators/ implements the abstract orchestrator/activity interfaces — any change to those interfaces must be reflected consistently in the generator output (see // IMPORTANT comments in TaskActivityContext.cs and TypeExtensions.cs).

gRPC / Protobuf Layer

The protobuf definition is in src/Grpc/orchestrator_service.proto. C# stubs are generated at build time by Grpc.Tools and are not committed to source.

  • Preserve all existing field numbers in the proto — removing or renumbering a field breaks wire compatibility with in-flight orchestrations.
  • Adding new optional fields is backward-compatible. Adding fields that the SDK or sidecar treats as required, adding fields without safe defaults, or changing existing field types is not.
  • Changing default serialization options in JsonDataConverter.cs could potentially be breaking for in-flight orchestrations (see // WARNING comment there).
  • Run src/Grpc/refresh-protos.ps1 to pull the latest proto version from upstream.
  • Before renaming any file path referenced in another file, confirm the full impact with the user — do not assume file locations without verification.

C# Code Guidelines

Here are some general guidelines that apply to all code.

  • The top of all *.cs files should have a copyright notice:
    // Copyright (c) Microsoft Corporation.
    // Licensed under the MIT License.
  • All public methods and classes should have XML documentation comments.
  • No change should introduce a breaking change unless an exception is otherwise noted in the PR Summary, linked github issue, or discussion.
  • Use this. for accessing class members.
  • Use the Async suffix on the name of all async methods.
  • Ensure that all private classes, that do not serve as base classes, are sealed.

C# Sample Code Guidelines

Sample code is located in the samples directory.

When adding a new sample, follow these steps:

  • The sample should be a standalone .NET project in one of the subdirectories of the samples directory.
  • The directory name should be the same as the project name.
  • The directory should contain a README.md file that explains what the sample does and how to run it.
  • The README.md file should follow the same format as other samples.
  • The csproj file should match the directory name.
  • The csproj file should be configured in the same way as other samples.
  • The project should preferably contain a single Program.cs file that contains all the sample code.
  • The sample should be added to the solution file in the samples directory.
  • The sample should be tested to ensure it works as expected.
  • A reference to the new sample should be added to the README.md file in the parent directory of the new sample.

The sample code should follow these guidelines:

  • Configuration settings should be read from environment variables, e.g. var endpoint = Environment.GetEnvironmentVariable("AZURE_OPENAI_ENDPOINT") ?? throw new InvalidOperationException("AZURE_OPENAI_ENDPOINT is not set.");.
  • Environment variables should use upper snake_case naming convention.
  • Secrets should not be hardcoded in the code or committed to the repository.
  • The code should be well-documented with comments explaining the purpose of each step.
  • The code should be simple and to the point, avoiding unnecessary complexity.
  • Prefer inline literals over constants for values that are not reused. For example, use new ChatClientAgent(chatClient, instructions: "You are a helpful assistant.") instead of defining a constant for "instructions".
  • Prefer defining variables using types rather than var, to help users understand the types involved.
  • Follow the patterns in the samples in the same directories where new samples are being added.
  • The structure of the sample should be as follows:
    • Add a comment describing what the sample is demonstrating.
    • Then add the necessary using statements.
    • Then add the main code logic.
    • Finally, add any helper methods or classes at the bottom of the file.

C# Unit Test Guidelines

Unit tests are located in the test root directory in projects with a .Tests.csproj suffix.

Unit tests should follow these guidelines:

  • Add Arrange, Act and Assert comments for each
  • Use the Moq library for mocking objects where possible.
  • Validate that each test actually tests the target behavior, e.g. we should not have tests that create a mock, call the mock and then verify that the mock was called, without the target code being involved. We also shouldn't have tests that test language features, e.g. something that the compiler would catch anyway.
  • Avoid adding excessive comments to tests. Instead favor clear easy to understand code.
  • Follow the patterns in the unit tests in the same project or classes to which new tests are being added.

Code Review Guidelines

When reviewing code, follow these guidelines:

  • Provide all review comments in a single review pass. Avoid scattering feedback across multiple partial reviews; consolidate findings into one coherent review round.
  • Do not generate false-positive or already-resolved comments when new commits are pushed. Only surface issues that still apply after the latest changes, and avoid re-posting comments that have been addressed or are no longer relevant.
  • Do not re-post a review comment if a user has directly responded to it with justification for why the code exists as written. Respect user explanations and avoid redundant feedback on justified code decisions.

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.