akka-best-practices
Critical Akka.NET best practices including EventStream vs DistributedPubSub, supervision strategies, error handling, Props vs DependencyResolver, work…
Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering, persistence, Akka.Management integration, and Aspire orchestration patterns.
$ npx -y skills add aaronontheweb/dotnet-skills --skill akka-aspire-configuration --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/akka-aspire-configurationContext preview
The summary Claude sees to decide when to auto-load this skill.
Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering, persistence, Akka.Management integration, and Aspire orchestration patterns.
name: akka-net-aspire-configuration description: Configure Akka.NET with .NET Aspire for local development and production deployments. Covers actor system setup, clustering, persistence, Akka.Management integration, and Aspire orchestration patterns. invocable: false
Use this skill when:
1. **Configuration via Microsoft.Extensions.Configuration** - Use strongly-typed settings classes bound from appsettings.json (see `microsoft-extensions-configuration` skill) 2. **Akka.Hosting for DI Integration** - Use the Akka.Hosting library for seamless ASP.NET Core integration 3. **Aspire for Orchestration** - Let Aspire manage service dependencies, networking, and environment configuration 4. **Health Checks** - Always configure health checks for clustering, persistence, and readiness 5. **Separate Concerns** - Keep actor definitions, configuration, and Aspire orchestration in separate layers 6. **Validate Configuration at Startup** - Use `IValidateOptions<T>` and `.ValidateOnStart()` to fail fast on misconfiguration
YourSolution/ ├── src/ │ ├── YourApp.Actors/ # Actor definitions and business logic │ │ ├── YourActor.cs │ │ └── YourApp.Actors.csproj │ ├── YourApp/ # ASP.NET Core web application │ │ ├── Config/ │ │ │ ├── AkkaConfiguration.cs # Akka setup extension methods │ │ │ └── AkkaSettings.cs # Configuration model │ │ ├── Program.cs │ │ ├── appsettings.json │ │ └── YourApp.csproj │ └── YourApp.AppHost/ # Aspire orchestration │ ├── Program.cs │ ├── AkkaManagementExtensions.cs │ └── YourApp.AppHost.csproj
<ItemGroup> <PackageReference Include="Akka.Cluster.Hosting" /> <PackageReference Include="Akka.Streams" /> </ItemGroup>
<ItemGroup> <PackageReference Include="Akka.Hosting" /> <PackageReference Include="Akka.Cluster.Hosting" /> <PackageReference Include="Akka.Persistence.Sql.Hosting" /> <PackageReference Include="Akka.Management" /> <PackageReference Include="Akka.Management.Cluster.Bootstrap" /> <PackageReference Include="Akka.Discovery.KubernetesApi" /> <PackageReference Include="Akka.Discovery.Azure" /> <PackageReference Include="Akka.Discovery.Config.Hosting" /> <PackageReference Include="Petabridge.Cmd.Host" /> <PackageReference Include="Petabridge.Cmd.Cluster" /> </ItemGroup>
<Sdk Name="Aspire.AppHost.Sdk" Version="$(AspireVersion)" /> <ItemGroup> <PackageReference Include="Aspire.Hosting.AppHost" /> <PackageReference Include="Aspire.Hosting.Azure.Storage" /> <PackageReference Include="Aspire.Hosting.SqlServer" /> </ItemGroup>
Create a strongly-typed configuration class:
using System.Net;
using System.Security.Cryptography.X509Certificates;
using Akka.Cluster.Hosting;
using Akka.Remote.Hosting;
using Petabridge.Cmd.Host;
namespace YourApp.Config;
public class AkkaSettings
{
public string ActorSystemName { get; set; } = "YourSystem";
public bool LogConfigOnStart { get; set; } = false;
public RemoteOptions RemoteOptions { get; set; } = new()
{
PublicHostName = Dns.GetHostName(),
HostName = "0.0.0.0",
Port = 8081
};
public ClusterOptions ClusterOptions { get; set; } = new()
{
SeedNodes = [$"akka.tcp://YourSystem@{Dns.GetHostName()}:8081"],
Roles = ["your-role"]
};
public ShardOptions ShardOptions { get; set; } = new();
public AkkaManagementOptions? AkkaManagementOptions { get; set; }
public PetabridgeCmdOptions PbmOptions { get; set; } = new()
{
Host = "0.0.0.0",
Port = 9110
};
public TlsSettings? TlsSettings { get; set; }
}
public class TlsSettings
{
public bool Enabled { get; set; } = false;
public string? CertificatePath { get; set; }
public string? CertificatePassword { get; set; }
public bool ValidateCertificates { get; set; } = true;
public X509Certificate2? LoadCertificate()
{
if (string.IsNullOrWhiteSpace(CertificatePath))
return null;
if (!File.Exists(CertificatePath))
throw new FileNotFoundException($"Certificate file not found at: {CertificatePath}");
return !string.IsNullOrWhiteSpace(CertificatePassword)
? X509CertificateLoader.LoadPkcs12FromFile(CertificatePath, CertificatePassword)
: X509CertificateLoader.LoadCertificateFromFile(CertificatePath);
}
}
public class AkkaManagementOptions
{
public bool Enabled { get; set; }
public string? Hostname { get; set; }
public int Port { get; set; } = 8558;
public string ServiceName { get; set; } = "your-service";
public string PortName { get; set; } = "management";
public int RequiredContactPointsNr { get; set; } = 1;
public bool FilterOnFallbackPort { get; set; } = true;
public DiscoveryMethod DiscovA comprehensive AI coding plugin with 30 skills and 5 specialized agents for professional .NET development. Battle-tested patterns from production systems covering C#, Akka.NET, Aspire, EF Core, testing, and performance optimization.
Critical Akka.NET best practices including EventStream vs DistributedPubSub, supervision strategies, error handling, Props vs DependencyResolver, work…
Patterns for building entity actors with Akka.Hosting - GenericChildPerEntityParent, message extractors, cluster sharding abstraction, akka-reminders, and…
Akka.Management for cluster bootstrapping, service discovery (Kubernetes, Azure, Config), health checks, and dynamic cluster formation without static seed…
Write unit and integration tests for Akka.NET actors using modern Akka.Hosting.TestKit patterns. Covers dependency injection, TestProbes, persistence testing,…
Guidelines for making .NET libraries and applications trimming-safe and Native AOT compatible. Covers the trimming/AOT model, the MSBuild properties that…
Configure Aspire AppHost to emit explicit app config via environment variables; keep app code free of Aspire clients and service discovery.