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.
- commitSkill
- feature-specificationSkill
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
- Distinctive: line 30
All package versions are managed in Directory.Packages.props
- Very specific: line 32
When adding a new package: Add <PackageVersion Include="PackageName" Version="x.y.z" /> to Directory.Packages.props
- Distinctive: line 38
All projects automatically inherit settings from Directory.Build.props
- Very specific: line 55
Private fields: Use underscore prefix with camelCase (_myField)
- Very specific: line 57
Local variables: Use var for built-in types and when type is apparent
- Very specific: line 60
Code Blocks: Always use {} for blocks except single-line exits (e.g., return, throw)
- Very specific: line 67
Braces: Always use braces for control flow (csharp_prefer_braces = true)
- Very specific: line 75
Pattern matching: Prefer over is with cast and as with null check
- Distinctive: line 76
Expression-bodied members: Use for properties, indexers, accessors (but NOT for methods)
- Very specific: line 80
Run dotnet format to auto-format code according to conventions
- Distinctive: line 81
Use analyzers from Directory.Build.props to catch violations during build
- Distinctive: line 82
Consider using NSDepCop for architectural rules
- Very specific: line 86
Use appsettings.json for default configuration
- Very specific: line 87
Use appsettings.{Environment}.json for environment-specific overrides
- Very specific: line 88
Use IConfiguration and IOptions<T> for accessing configuration in code
- Distinctive: line 89
Create strongly-typed settings classes for complex configurations
- Very specific: line 90
Use User Secrets for sensitive data in development
- Distinctive: line 91
Never hardcode sensitive information in source code
- Very specific: line 95
Use Microsoft.Extensions.Logging for logging
- Distinctive: line 98
Use Structured logging where possible
- Distinctive: line 99
Avoid logging sensitive information
- Very specific: line 104
Use Ardalis.GuardClauses for input validation in non-UI code
- Very specific: line 105
Prefer FluentValidation for complex validation scenarios, especially in UI layers
- Distinctive: line 112
Follow OWASP guidelines for secure coding practices
- Distinctive: line 114
Use parameterized queries or ORM features to prevent SQL injection
- Distinctive: line 116
Use HTTPS for all communications
- Distinctive: line 120
Write unit testable code wherever possible
- Distinctive: line 122
Only test code that you control and that has business logic.
- Distinctive: line 123
Keep classes focused on a single responsibility
- Distinctive: line 124
Use Dependency Injection for managing dependencies
- Distinctive: line 125
Prefer composition over inheritance
- Distinctive: line 126
Use async/await for I/O-bound operations
- Distinctive: line 127
Keep methods short and focused.
- Distinctive: line 128
Keep argument lists short.
- Very specific: line 129
Prefer the REPR pattern for API design with FastEndpoints
- Distinctive: line 130
Use Domain-Driven Design (DDD) principles where applicable
- Very specific: line 131
Use *Request and *Response suffixes for API layer messages
- Very specific: line 132
Use *Command and *Query suffixes for use case layer messages
- Distinctive: line 133
Use DTOs for data transfer between layers.
- Very specific: line 134
Use *Details and *Summary suffixes for DTOs as appropriate to indicate level of detail
- Distinctive: line 135
Avoid locating interfaces and their implementations in the same project
- Very specific: line 141
When creating new projects in src/ or tests/:
- Very specific: line 144
Test projects should use xUnit.
- Very specific: line 161
Use xUnit for all tests
- Distinctive: line 162
Follow Arrange-Act-Assert pattern (but only with whitespace separation, no comments needed)
- Distinctive: line 164
Do not name test classes with "Tests" suffix.
- Very specific: line 166
Use [Fact] for simple tests, [Theory] with [InlineData] for parameterized tests
- Distinctive: line 172
If mocking is needed, prefer NSubstitute over alternatives.
- Distinctive: line 173
Prefer Shouldly for assertions.
- Distinctive: line 174
Avoid commercially licensed testing libraries (e.g.
- Distinctive: line 178
Use Markdown for all documentation files
- Very specific: line 179
Use headings (#, ##, ###) to organize content
- Distinctive: line 181
Run linting tools on documentation files to ensure consistency
≈ “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.
Files
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
.csprojfiles - 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
varfor 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
.csfiles - 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
iswith cast andaswith null check - Expression-bodied members: Use for properties, indexers, accessors (but NOT for methods)
Code Convention Enforcement
- Run
dotnet formatto 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.jsonfor default configuration - Use
appsettings.{Environment}.jsonfor environment-specific overrides - Use
IConfigurationandIOptions<T>for accessing configuration in code - Create strongly-typed settings classes for complex configurations
- Use
User Secretsfor sensitive data in development - Never hardcode sensitive information in source code
Logging
- Use
Microsoft.Extensions.Loggingfor 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.GuardClausesfor input validation in non-UI code - Prefer
FluentValidationfor 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
REPRpattern for API design with FastEndpoints - Use Domain-Driven Design (DDD) principles where applicable
- Use
*Requestand*Responsesuffixes for API layer messages - Use
*Commandand*Querysuffixes for use case layer messages - Use DTOs for data transfer between layers; avoid exposing domain entities directly
- Use
*Detailsand*Summarysuffixes 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/:
- Production projects go in
src/, test projects intests/. - 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 testTesting Conventions
- Use
xUnitfor 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
- Example:
- 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
- Example
- 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
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.

