This document defines the repository-wide architectural and coding rules. For Avalonia-specific UI guidance, see src/KubeUI.Avalonia/AGENTS.md.
.Net Core SDK installed based on global.json
Docker
- Single Responsibility: every class has exactly one reason to change.
- Open/Closed: extend behavior via composition and interfaces; avoid modifying stable code paths when adding features.
- Liskov Substitution: derived types must be safely substitutable without altering expected behavior or contract.
- Interface Segregation: prefer small, focused interfaces; avoid "god" interfaces.
- Dependency Inversion: depend on abstractions; wire concrete types in the composition root only.
- KubeUI.Kubernetes: all non-UI Kubernetes/runtime/shared contracts
- KubeUI.Avalonia: all Avalonia UI, view models, resource configs, shell glue
- KubeUI.Desktop: executable host and composition root
- KubeUI.Desktop depends on KubeUI.Avalonia depends on KubeUI.Kubernetes
- Configure services in a single composition root (App startup).
- Use
AddSingleton,AddScoped,AddTransientcorrectly. - Never resolve scoped services from singletons without creating a scope.
- Do not dispose services resolved from the container manually.
- Prefer allocation-free APIs where practical.
- Avoid LINQ in hot paths; use loops and pre-sized collections.
- Minimize boxing, virtual dispatch in tight loops, and avoid unnecessary allocations in render/update loops.
- Profile before and after optimizations; document expected gains.
- Avoid reflection whenever possible.
- Prefer source generators before any reflection-based approach.
- If reflection is the only viable option, ask the user explicitly before introducing it.
- All production code must be covered by unit tests; xUnit is required for unit testing.
- Use integration tests for parsing, IO, and docking layout persistence.
- Avalonia UI tests and headless UI guidance live in
src/KubeUI.Avalonia/AGENTS.md. - For Avalonia UI bugs, write the failing headless regression test first, confirm the failure reproduces, then implement the fix and rerun the same test before widening scope.
- Avoid static state except truly immutable constants.
- Prefer explicit types where clarity is improved; avoid
varin public APIs. - All public APIs must be documented and unit-tested.
- No hacks or weird workarounds; if you think you need one, ask for guidance.