This file provides instructions for AI coding agents (Claude, Copilot, Cursor, etc.) working on this codebase.
# Restore and build entire solution
dotnet restore CoreIdent.sln
# Build (compile only)
dotnet build CoreIdent.sln
# Run all tests
dotnet test CoreIdent.sln
# Run tests with coverage (produces coverage.cobertura.xml)
dotnet test CoreIdent.sln --collect:"XPlat Code Coverage"
# Run single test project
dotnet test tests/CoreIdent.Core.Tests/CoreIdent.Core.Tests.csproj
# Run single test class
dotnet test tests/CoreIdent.Integration.Tests -v n --filter "FullyQualifiedName~TokenEndpointsTests"
# Watch mode (during development)
dotnet watch test --project tests/CoreIdent.Core.Tests
# Format code style
dotnet format
# Build a specific project
dotnet build src/CoreIdent.Core/CoreIdent.Core.csproj- Security first — Never log secrets, tokens, OTPs, or raw PII. Use redaction helpers for email/phone.
- Fail fast — Validate arguments early. Throw
ArgumentNullExceptionfor null required params. - One responsibility per class/method — Keep functions focused and small.
- Interface-driven design — All services have interfaces for testability. No
newfor services; inject via constructor.
- File-scoped namespaces:
namespace Foo;notnamespace Foo { } - Primary constructors where appropriate
- Target-typed new:
List<string> items = [];notnew List<string>() - Extension members for
ClaimsPrincipalutilities - Pattern matching — Prefer
ispatterns over type checks + casts
- Meaningful names; avoid abbreviations except well-known ones (
ctfor CancellationToken is fine) - Interfaces:
Iprefix (e.g.,ITokenService) - Records for DTOs/value objects: suffix with
Request,Response,Options, orResultas appropriate
- Nullable reference types enabled — Fix nullable warnings, don't suppress with
! - No type coercion (
as any,@ts-ignore,@ts-expect-error, etc.) - Prefer
recordtypes for DTOs and value objects - Use
CancellationTokenwith default value in async APIs
- Remove unused usings before committing
- Run
dotnet formatwhen touching many files - Follow existing style in the file you're editing
- Prefer
dotnet add packageover manual XML edits — This ensures consistent formatting and version resolution# Correct way to add a package dotnet add tests/CoreIdent.Testing/CoreIdent.Testing.csproj package Microsoft.Playwright # Avoid: Manually editing .csproj XML
- When manually adding packages is unavoidable, follow the existing
<PackageReference>formatting in the project - Never add comments inside
<ItemGroup>blocks that describe why a package is added (commit messages serve this purpose)
- No empty catch blocks — Always handle or log exceptions
- Use structured logging with
ILogger<T> - Include correlation context in logs
- All public APIs require XML docs (CS1591 is treated as error)
- User-facing APIs (DI/extension methods/endpoints): add practical guidance in
<remarks>
- Use Shouldly with explicit assertion messages:
result.ShouldNotBeNull("Token should be issued on successful authentication"); client.AllowedScopes.ShouldContain("openid", "OIDC scope must be allowed");
- Coverage gate: Changes to
src/CoreIdent.Core/require >= 90% normalized merged line coverage - Write tests before or alongside implementation, not after
- Never commit code that breaks existing tests
- One feature per commit — No multi-feature commits
- Atomic commits — Each commit should build and pass tests independently
- Conventional commits:
feat:,fix:,test:,docs:,chore:,refactor: - No AI co-authorship in commit messages
| Document | Purpose |
|---|---|
CLAUDE.md |
Primary — Complete development guidelines |
docs/DEVPLAN.md |
Task-level checklist and roadmap |
docs/Technical_Plan.md |
Technical specifications and RFC links |
docs/Project_Overview.md |
Architecture and vision |
index.md |
Component and folder overview |
- Read relevant sections of
DEVPLAN.mdandTechnical_Plan.md - Check existing patterns in similar files
- Write or outline tests first
- Run diagnostics:
lsp_diagnosticson changed files before completing
- Don't commit without tests
- Don't bundle multiple features in one commit
- Don't skip security validation "for now"
- Don't add dependencies without justification
- Don't delete or weaken existing tests
- Don't hardcode configuration values
- Don't log sensitive data
- Don't leave code in broken state