agentleFS
MicrosoftKnown publishermicrosoft/dcp/AGENTS.md

dcp

AGENTS.md192 starsChanged 6 months agoMITView on GitHub

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

26 rules. About 0 are common, 15 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    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:

    Before writing any code, analyze the existing codebase to understand and adopt its naming conventions, coding style, and language usage.

    line 8
  2. Very specific:

    Look for broadly reusable utilities in the pkg/ directory, especially for concurrency, resiliency, data structures and data manipulation, …

    line 12
  3. Distinctive:

    Add new dependencies only as a last resort, or when explicitly requested by the developer.

    line 14
  4. Distinctive:

    All errors and edge cases must be handled.

    line 18
  5. Distinctive:

    Prefer simple solutions with proven run time and memory consumption characteristics over complex ones.

    line 19
  6. Distinctive:

    Avoid goroutine leaks by ensuring that all goroutines are properly terminated when they are no longer needed.

    line 22
  7. Distinctive:

    When reading from channels, always check that a channel is not closed and that the value read is valid (and not a zero value of some type).

    line 23
  8. Distinctive:

    All utility packages must have unit tests.

    line 24
  9. Distinctive:

    Every change must build successfully and pass all tests (refer to Working inside the repository for details on how to run tests).

    line 27
  10. Distinctive:

    When declaring a new variable, use a different name than the one used in the outer scope.

    line 36
  11. Distinctive:

    If a function invokes multiple error-returning functions, use a different variable name for each error to avoid confusion.

    line 39
  12. Very specific:

    Do not use meaningless, filler words such as "helper" or "fixture".

    line 43
  13. Distinctive:

    Do not create "convenience" functions that merely wrap the underlying call to another function, without doing any additional work.

    line 46
  14. Distinctive:

    Place new code in the correct location according to the project's structure:

    line 52
  15. Very specific:

    Internal Packages: All other packages go in internal/.

    line 57
  16. Distinctive:

    Use lowercase for error messages to enable easy error composition.

    line 61
  17. Distinctive:

    When logging, start the log message with an uppercase letter.

    line 62
  18. Very specific:

    Use OpenFile(), or (for temporary files) OpenTempFile() functions from github.com/microsoft/dcp/pkg/io package to open files.

    line 65
  19. Very specific:

    Always close files after no longer needed, either by calling Close() from the method that opened the file (with defer statement), or when …

    line 66
  20. Very specific:

    Run make generate after making changes to API definitions (files under api/v1 folder).

    line 69
  21. Very specific:

    Run make generate-grpc after making changes to protobuf definitions (files with .proto extension).

    line 70
  22. Very specific:

    Do not run make without a target.

    line 85
  23. Very specific:

    Before running tests, make sure test prerequisites are built by running make test-prereqs.

    line 88
  24. Very specific:

    Use make test to run unit tests and integration tests.

    line 89
  25. Very specific:

    If working on a change involving a lot of goroutine synchronization, channel operations, and locking, run tests with -race flag to enable …

    line 91
  26. Distinctive:

    No single test (not even those classified as "advanced" e.g.

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md 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
AGENTS.md

Project guiding principles

Follow existing conventions

Before writing any code, analyze the existing codebase to understand and adopt its naming conventions, coding style, and language usage. Consistency is key to maintaining a readable and maintainable codebase.

Avoid code duplication and minimize dependencies

This repository contains a rich set of utility packages. Look for opportunities to use them before writing new code.

  • Look for broadly reusable utilities in the pkg/ directory, especially for concurrency, resiliency, data structures and data manipulation, operating system interaction, and test utilities.
  • For internal, project-specific utilities, use internal/ directory.
  • Add new dependencies only as a last resort, or when explicitly requested by the developer.

Reliability and performance are critical

This codebase implements several custom Kubernetes types and controllers. Implementation is highly parallel, and leverages multiple operating system processes and Docker/Podman containers. Clear, simple, reliable code is essential to ensure that the system works correctly and efficiently. Specifically:

  • All errors and edge cases must be handled.
  • Prefer simple solutions with proven run time and memory consumption characteristics over complex ones.
  • Long-running operations must accept a context.Context and respect its cancellation.
  • Release all resources (e.g., file descriptors, network connections) when they are no longer needed (lifetime context cancelled).
  • Avoid goroutine leaks by ensuring that all goroutines are properly terminated when they are no longer needed.
  • When reading from channels, always check that a channel is not closed and that the value read is valid (and not a zero value of some type).
  • All utility packages must have unit tests.

Code quality must not be compromised

  • Every change must build successfully and pass all tests (refer to Working inside the repository for details on how to run tests).
  • Code must be lint-free. Use make lint to check for linting issues.

Additional guidelines

Go language usage

Eliminate variable shadowing

  • When declaring a new variable, use a different name than the one used in the outer scope.

Avoid variable reuse (especially for errors)

  • If a function invokes multiple error-returning functions, use a different variable name for each error to avoid confusion.

Names of types, members and functions should reflect their PURPOSE

  • Names should reflect what things ARE and what they DO. They should be descriptive but concise. A developer reading code should be able to determine the purpose of a member/function/type from their name, without referring to the implementation.
  • Do not use meaningless, filler words such as "helper" or "fixture". For example, a component that creates sub-processes should be named subprocessLauncher, not subprocessHelper.

No single-line wrapper functions

Do not create "convenience" functions that merely wrap the underlying call to another function, without doing any additional work. Instead, call the target function directly.

Prefer extending existing interfaces over creating new ones

  • It's safe to extend existing interfaces when we need new functionality; we don't need to worry about breaking existing implementations because we control all of them. This also helps to keep the codebase simpler and more consistent.

Adhere to Code Placement Rules

Place new code in the correct location according to the project's structure:

  • API Definitions: Go in api/v1/.
  • Controller Logic: Goes in controllers/.
  • Integration Tests: Go in test/integration/.
  • Broadly Reusable Packages: Go in pkg/. These should be suitable for use in other projects.
  • Internal Packages: All other packages go in internal/. If in doubt, use internal/.

Errors and logging

  • Wrap inner errors with context using fmt.Errorf("context: %w", err) as appropriate.
  • Use lowercase for error messages to enable easy error composition.
  • When logging, start the log message with an uppercase letter.

File handling

  • Use OpenFile(), or (for temporary files) OpenTempFile() functions from github.com/microsoft/dcp/pkg/io package to open files. This function takes care of using appropriate file permissions in a cross-platform way.
  • Always close files after no longer needed, either by calling Close() from the method that opened the file (with defer statement), or when the lifetime context.Context of the file owner expires.

Code generation

  • Run make generate after making changes to API definitions (files under api/v1 folder).
  • Run make generate-grpc after making changes to protobuf definitions (files with .proto extension).

Test authoring

  • Every test function should have a 1-3 sentence documentation comment describing its purpose. Use the following template for the test comments: "Verifies that [name of a type/method/function] does A, B, and C". The name of the test function should reflect its purpose too. Both the test function name, and the documentation comment, should be updated as necessary if the test function implementation is changed substantially.
  • Unless a tight, specific timeout is ESSENTIAL for testing a specific function, avoid using hard-coded timeouts (e.g. obtained via time.After()). Instead, use test context (created via testutil.GetTestContext()) and test context Done() channel for timeouts in tests.

Commenting code

  • Try to keep comments terse and focused. 1-2 sentences for structs and public method descriptions, and 1 sentence for struct members is ideal, but do not use this guideline to omit information that is important for proper use of the type or member. If necessary, make a longer comment.
  • Comments on structs, struct members, and public methods should describe ONLY the purpose and how to use it. Do not describe how a struct or method is used in other parts of the codebase, and do not tell stories about how design or implementation evolved over time.
  • Comments inside code blocks should be reserved for describing the INTENT for the code IF AND ONLY IF the intent is not obvious from the code itself (for example: why certain API is called when it is seemingly not necessary, or why operations are done in certain order if it seems a different order might work even better). Do not add comments merely describing what the code does, or where the name of used members or methods indicates the intent (for example: do not attach "we are closing the socket" comment to a closeSocket() method call).

Working inside the repository

Running commands

  • Do not run make without a target. It does not do anything useful (just displays a list of available targets, in human-readable form).

Running tests

  • Before running tests, make sure test prerequisites are built by running make test-prereqs.
  • Use make test to run unit tests and integration tests.
  • Tests for specific packages can be run with go test -count 1 -parallel 32 <package> (after building prerequisites), where <package> indicates the package that was changed and needs to be tested. This is significantly faster than running all tests, and should be used when working on a specific code change. For final verification, run make test to ensure all tests pass.
  • If working on a change involving a lot of goroutine synchronization, channel operations, and locking, run tests with -race flag to enable race detection. This works on MacOS and Linux ONLY, do not try this when the current OS is Windows.
  • Our test context (obtained via GetTestContext function from pkg/testutil package) can be adjusted via an environment variable to use non-standard test timeout. Set TEST_CONTEXT_TIMEOUT environment variable to number of seconds that will be used as timeout value. For example, TEST_CONTEXT_TIMEOUT=30 will make the test context expire after 30 seconds. 30 seconds is a good value when running individual tests.
  • No single test (not even those classified as "advanced" e.g. tests using real container orchestrator) should take more than 3 minutes (180 seconds) to run. Use AT MOST 3 minutes as a timeout when running individual tests, or subset of tests, with "go test" command ("-timeout" flag).
  • When doing final change verification, leverage a container runtime, if available, to verify the change on Linux too. E.g. on a Windows or a Mac machine with Docker, Podman, or WSLC, do final test run (and any other, change-specific verification, as applicable) using a Linux container. One container-based test run is sufficient unless the change affects container runtime support in DCP; in the latter case, do a test run with all available container runtimes.

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.