Architecture test guidance for .NET using NetArchTest and ArchUnitNET. Use when enforcing architectural boundaries, testing module dependencies, validating layer constraints, or creating performance fitness functions. Includes code generation templates.
View on GitHubmelodic-software/claude-code-plugins
enterprise-architecture
plugins/enterprise-architecture/skills/fitness-functions/SKILL.md
January 21, 2026
Select agents to install to:
npx add-skill https://github.com/melodic-software/claude-code-plugins/blob/main/plugins/enterprise-architecture/skills/fitness-functions/SKILL.md -a claude-code --skill fitness-functionsInstallation paths:
.claude/skills/fitness-functions/# Fitness Functions
## When to Use This Skill
Use this skill when you need to:
- Enforce architectural boundaries between modules
- Test that dependencies follow prescribed rules
- Validate layer constraints (e.g., no UI → Domain)
- Create performance fitness functions
- Generate architecture test code
- Audit existing architecture for violations
**Keywords:** fitness functions, architecture tests, NetArchTest, ArchUnitNET, dependency rules, layer constraints, architectural boundaries, module isolation, architecture validation, performance tests
## What Are Fitness Functions?
Fitness functions are automated tests that validate architectural characteristics. They provide objective, repeatable verification that the system maintains desired properties as it evolves.
### Types of Fitness Functions
| Type | Validates | Example |
| --- | --- | --- |
| **Dependency** | Component relationships | "Domain cannot depend on Infrastructure" |
| **Layer** | Vertical slice rules | "Controllers only call Application layer" |
| **Naming** | Convention compliance | "Handlers must end with 'Handler'" |
| **Performance** | Runtime characteristics | "API response < 200ms at p95" |
| **Cyclomatic** | Code complexity | "No method > 10 cyclomatic complexity" |
## Quick Start
### 1. Install Required Package
```bash
# For NetArchTest (simpler, recommended for most cases)
dotnet add package NetArchTest.Rules
# For ArchUnitNET (more powerful, Java-like syntax)
dotnet add package ArchUnitNET
dotnet add package ArchUnitNET.xUnit # or .NUnit
```
### 2. Create Test Project
```bash
dotnet new xunit -n YourSolution.ArchitectureTests
dotnet add YourSolution.ArchitectureTests reference src/YourSolution.Domain
dotnet add YourSolution.ArchitectureTests reference src/YourSolution.Application
dotnet add YourSolution.ArchitectureTests reference src/YourSolution.Infrastructure
```
### 3. Write First Test
```csharp
public class DependencyTests
{
[Fact]
public void Domain_ShouldNotDep