agentleFS
NimbleProsNimblePros/dotnet-codingagent-template/AGENTS.md

dotnet-codingagent-template

AGENTS.md15 starsChanged 6 months agoMITView on GitHub

This is a placeholder. Review the README.md and /src files for details about the repository purpose and structure and update this overview accordingly.

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 31,774 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

53 rules. About 0 are common, 30 are distinctive, and 23 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈30

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 23

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    All package versions are managed in Directory.Packages.props

    line 30
  2. Very specific:

    When adding a new package: Add <PackageVersion Include="PackageName" Version="x.y.z" /> to Directory.Packages.props

    line 32
  3. Distinctive:

    All projects automatically inherit settings from Directory.Build.props

    line 38
  4. Very specific:

    Private fields: Use underscore prefix with camelCase (_myField)

    line 55
  5. Very specific:

    Local variables: Use var for built-in types and when type is apparent

    line 57
  6. Very specific:

    Code Blocks: Always use {} for blocks except single-line exits (e.g., return, throw)

    line 60
  7. Very specific:

    Braces: Always use braces for control flow (csharp_prefer_braces = true)

    line 67
  8. Very specific:

    Pattern matching: Prefer over is with cast and as with null check

    line 75
  9. Distinctive:

    Expression-bodied members: Use for properties, indexers, accessors (but NOT for methods)

    line 76
  10. Very specific:

    Run dotnet format to auto-format code according to conventions

    line 80
  11. Distinctive:

    Use analyzers from Directory.Build.props to catch violations during build

    line 81
  12. Distinctive:

    Consider using NSDepCop for architectural rules

    line 82
  13. Very specific:

    Use appsettings.json for default configuration

    line 86
  14. Very specific:

    Use appsettings.{Environment}.json for environment-specific overrides

    line 87
  15. Very specific:

    Use IConfiguration and IOptions<T> for accessing configuration in code

    line 88
  16. Distinctive:

    Create strongly-typed settings classes for complex configurations

    line 89
  17. Very specific:

    Use User Secrets for sensitive data in development

    line 90
  18. Distinctive:

    Never hardcode sensitive information in source code

    line 91
  19. Very specific:

    Use Microsoft.Extensions.Logging for logging

    line 95
  20. Distinctive:

    Use Structured logging where possible

    line 98
  21. Distinctive:

    Avoid logging sensitive information

    line 99
  22. Very specific:

    Use Ardalis.GuardClauses for input validation in non-UI code

    line 104
  23. Very specific:

    Prefer FluentValidation for complex validation scenarios, especially in UI layers

    line 105
  24. Distinctive:

    Follow OWASP guidelines for secure coding practices

    line 112
  25. Distinctive:

    Use parameterized queries or ORM features to prevent SQL injection

    line 114
  26. Distinctive:

    Use HTTPS for all communications

    line 116
  27. Distinctive:

    Write unit testable code wherever possible

    line 120
  28. Distinctive:

    Only test code that you control and that has business logic.

    line 122
  29. Distinctive:

    Keep classes focused on a single responsibility

    line 123
  30. Distinctive:

    Use Dependency Injection for managing dependencies

    line 124
  31. Distinctive:

    Prefer composition over inheritance

    line 125
  32. Distinctive:

    Use async/await for I/O-bound operations

    line 126
  33. Distinctive:

    Keep methods short and focused.

    line 127
  34. Distinctive:

    Keep argument lists short.

    line 128
  35. Very specific:

    Prefer the REPR pattern for API design with FastEndpoints

    line 129
  36. Distinctive:

    Use Domain-Driven Design (DDD) principles where applicable

    line 130
  37. Very specific:

    Use *Request and *Response suffixes for API layer messages

    line 131
  38. Very specific:

    Use *Command and *Query suffixes for use case layer messages

    line 132
  39. Distinctive:

    Use DTOs for data transfer between layers.

    line 133
  40. Very specific:

    Use *Details and *Summary suffixes for DTOs as appropriate to indicate level of detail

    line 134
  41. Distinctive:

    Avoid locating interfaces and their implementations in the same project

    line 135
  42. Very specific:

    When creating new projects in src/ or tests/:

    line 141
  43. Very specific:

    Test projects should use xUnit.

    line 144
  44. Very specific:

    Use xUnit for all tests

    line 161
  45. Distinctive:

    Follow Arrange-Act-Assert pattern (but only with whitespace separation, no comments needed)

    line 162
  46. Distinctive:

    Do not name test classes with "Tests" suffix.

    line 164
  47. Very specific:

    Use [Fact] for simple tests, [Theory] with [InlineData] for parameterized tests

    line 166
  48. Distinctive:

    If mocking is needed, prefer NSubstitute over alternatives.

    line 172
  49. Distinctive:

    Prefer Shouldly for assertions.

    line 173
  50. Distinctive:

    Avoid commercially licensed testing libraries (e.g.

    line 174
  51. Distinctive:

    Use Markdown for all documentation files

    line 178
  52. Very specific:

    Use headings (#, ##, ###) to organize content

    line 179
  53. Distinctive:

    Run linting tools on documentation files to ensure consistency

    line 181

≈ “Common” is an estimate: at least 1 in 5 of the 40,246 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

Agent Instructions

Project Overview

This is a placeholder. Review the README.md and /src files for details about the repository purpose and structure and update this overview accordingly.

Target Framework & Language

  • Framework: .NET 10.0 (net10.0)
  • Language Version: Latest C# features enabled
  • Nullable Reference Types: Enabled project-wide
  • Implicit Usings: Enabled
  • Treat Warnings as Errors: Enabled globally

Project Structure

├── src/              # Source code projects
├── tests/            # Test projects
├── Directory.Build.props    # Shared properties for all projects
├── Directory.Packages.props # Central Package Management (CPM) configuration
└── Template.slnx            # Solution file (XML format)

Build Configuration

Central Package Management

  • Uses MSBuild Central Package Management (ManagePackageVersionsCentrally=true)
  • All package versions are managed in Directory.Packages.props
  • Individual projects reference packages WITHOUT version numbers in their .csproj files
  • When adding a new package: Add <PackageVersion Include="PackageName" Version="x.y.z" /> to Directory.Packages.props

Compiler Settings

  • Treat Warnings As Errors: Enabled (TreatWarningsAsErrors=true)
  • XML Documentation: Warning 1591 (missing XML comments) is suppressed via NoWarn
  • All projects automatically inherit settings from Directory.Build.props

Code Style Conventions

File-Scoped Namespaces (Enforced)

namespace MyProject.Feature;  // ✅ Use this (warning if not used)

// NOT this:
namespace MyProject.Feature   // ❌ Avoid
{
}

Naming Conventions

  • Private fields: Use underscore prefix with camelCase (_myField)
  • Constants: Use PascalCase
  • Local variables: Use var for built-in types and when type is apparent
  • Interfaces: Prefix interfaces with I (e.g., IRepository)
  • Async Methods: Suffix async methods with Async (e.g., GetByIdAsync)
  • Code Blocks: Always use {} for blocks except single-line exits (e.g., return, throw)

Code Formatting

  • Indentation: 2 spaces (not tabs) for all .cs files
  • Line endings: CRLF (Windows)
  • Encoding: UTF-8 with BOM for code files
  • Braces: Always use braces for control flow (csharp_prefer_braces = true)
  • Opening braces: On new line (Allman style - csharp_new_line_before_open_brace = all)
  • Namespace directives: File-scoped, outside namespace (enforced as warning)

Modern C# Preferences

  • Primary constructors: Preferred; ALWAYS assign to readonly fields
  • Top-level statements: Preferred for program entry points
  • Pattern matching: Prefer over is with cast and as with null check
  • Expression-bodied members: Use for properties, indexers, accessors (but NOT for methods)

Code Convention Enforcement

  • Run dotnet format to auto-format code according to conventions
  • Use analyzers from Directory.Build.props to catch violations during build
  • Consider using NSDepCop for architectural rules

Configuration Management

  • Use appsettings.json for default configuration
  • Use appsettings.{Environment}.json for environment-specific overrides
  • Use IConfiguration and IOptions<T> for accessing configuration in code
  • Create strongly-typed settings classes for complex configurations
  • Use User Secrets for sensitive data in development
  • Never hardcode sensitive information in source code

Logging

  • Use Microsoft.Extensions.Logging for logging
  • Log at appropriate levels: Trace, Debug, Information, Warning, Error, Critical
  • Include relevant context in log messages
  • Use Structured logging where possible
  • Avoid logging sensitive information
  • Include correlation IDs for tracing requests across services when possible

Guard Clauses

  • Use Ardalis.GuardClauses for input validation in non-UI code
  • Prefer FluentValidation for complex validation scenarios, especially in UI layers
  • Invalid inputs in UI layers should result in user-friendly error messages rather than exceptions
  • Invalid inputs in non-UI layers should throw appropriate exceptions using guard clauses
  • HTTP methods should return suitable status codes for non-success results (e.g., 400 Bad Request)

Security

  • Follow OWASP guidelines for secure coding practices
  • Validate and sanitize all user inputs
  • Use parameterized queries or ORM features to prevent SQL injection
  • Implement proper authentication and authorization mechanisms
  • Use HTTPS for all communications

Coding Practices

  • Write unit testable code wherever possible
  • Offer to add tests to generated code if applicable - place such tests in the tests/ folder
  • Only test code that you control and that has business logic; do not test framework code
  • Keep classes focused on a single responsibility
  • Use Dependency Injection for managing dependencies
  • Prefer composition over inheritance
  • Use async/await for I/O-bound operations
  • Keep methods short and focused; ideally under 20 lines
  • Keep argument lists short; consider using parameter objects if more than 4 parameters are needed
  • Prefer the REPR pattern for API design with FastEndpoints
  • Use Domain-Driven Design (DDD) principles where applicable
  • Use *Request and *Response suffixes for API layer messages
  • Use *Command and *Query suffixes for use case layer messages
  • Use DTOs for data transfer between layers; avoid exposing domain entities directly
  • Use *Details and *Summary suffixes for DTOs as appropriate to indicate level of detail
  • Avoid locating interfaces and their implementations in the same project

Development Workflow

Adding New Projects

When creating new projects in src/ or tests/:

  1. Production projects go in src/, test projects in tests/.
  2. Test projects should use xUnit.

Building & Running

# Build entire solution
dotnet build

# Run specific project
dotnet run --project src/YourProject/YourProject.csproj

# Run tests
dotnet test

Testing Conventions

  • Use xUnit for all tests
  • Follow Arrange-Act-Assert pattern (but only with whitespace separation, no comments needed)
  • Organize tests by feature in folders mirroring src/ structure
  • Do not name test classes with "Tests" suffix; do use "Tests" suffix for folder names if needed
    • Example: ProductServiceTests/ProductService_Constructor.cs
  • Use [Fact] for simple tests, [Theory] with [InlineData] for parameterized tests
  • Name test classes ClassName_MethodName.cs
  • Name test methods DoesSomething_GivenSomeCondition
  • Reading the full class name and method name should form a proper sentence describing the use case being tested.
    • Example ProductService_Constructor._ReturnsInstanceGivenValidInputs
  • Separate Unit Tests and Integration Tests into different projects or folders as appropriate
  • If mocking is needed, prefer NSubstitute over alternatives.
  • Prefer Shouldly for assertions.
  • Avoid commercially licensed testing libraries (e.g. FluentAssertions, Moq)

Documentation Conventions

  • Use Markdown for all documentation files
  • Use headings (#, ##, ###) to organize content
  • Include code snippets with proper syntax highlighting
  • Run linting tools on documentation files to ensure consistency
  • Lists and code listings should always have a blank line before and after them

Key Files to Reference

  • .editorconfig - Complete code style rules and formatting preferences (151 lines)
  • Directory.Build.props - Shared build properties and compiler settings
  • Directory.Packages.props - Centralized package version management
  • .gitignore - Standard Visual Studio ignore patterns

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.