[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M79WH1D1MA8MSVJBMKT12N05":3,"skill-same:01M79WH1D1MA8MSVJBMKT12N05":47},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":24,"commitSha":25,"skillDirectory":26,"forksCount":27,"repositoryHtmlUrl":28,"repositoryHomepageUrl":6,"ownerHtmlUrl":29,"ownerBlogUrl":30,"ownerDescription":31,"updatedAt":32,"install":33,"resources":46},"01M79WH1D1MA8MSVJBMKT12N05","akka-hosting-actor-patterns",null,"Patterns for building entity actors with Akka.Hosting - GenericChildPerEntityParent, message extractors, cluster sharding abstraction, akka-reminders, and ITimeProvider. Supports both local testing and clustered production modes.","Blind-Striker\u002Fagent-skills-and-plugins","Blind-Striker","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F1965259?v=4","01M79WFXTE5PH0C1VB7B54ANMN","Deniz İrgin","01M79WFXV5KZ5GST1K8G035DM5",1,"MIT","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fcodex\u002Fdeniz-dotnet-akka\u002Fskills\u002Fakka-hosting-actor-patterns\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: akka-hosting-actor-patterns\ndescription: Patterns for building entity actors with Akka.Hosting -\n  GenericChildPerEntityParent, message extractors, cluster sharding abstraction,\n  akka-reminders, and ITimeProvider. Supports both local testing and clustered\n  production modes.\n---\n\n# Akka.Hosting Actor Patterns\n\n## When to Use This Skill\n\nUse this skill when:\n- Building entity actors that represent domain objects (users, orders, invoices, etc.)\n- Need actors that work in both unit tests (no clustering) and production (cluster sharding)\n- Setting up scheduled tasks with akka-reminders\n- Registering actors with Akka.Hosting extension methods\n- Creating reusable actor configuration patterns\n\n## Core Principles\n\n1. **Execution Mode Abstraction** - Same actor code runs locally (tests) or clustered (production)\n2. **GenericChildPerEntityParent for Local** - Mimics sharding semantics without cluster overhead\n3. **Message Extractors for Routing** - Reuse Akka.Cluster.Sharding's IMessageExtractor interface\n4. **Akka.Hosting Extension Methods** - Fluent configuration that composes well\n5. **ITimeProvider for Testability** - Use ActorSystem.Scheduler instead of DateTime.Now\n\n## Execution Modes\n\nDefine an enum to control actor behavior:\n\n```csharp\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Determines how Akka.NET should be configured\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic enum AkkaExecutionMode\n{\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Pure local actor system - no remoting, no clustering.\n    \u002F\u002F\u002F Use GenericChildPerEntityParent instead of ShardRegion.\n    \u002F\u002F\u002F Ideal for unit tests and simple scenarios.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    LocalTest,\n\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Full clustering with ShardRegion.\n    \u002F\u002F\u002F Use for integration testing and production.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    Clustered\n}\n```\n\n## GenericChildPerEntityParent\n\nA lightweight parent actor that routes messages to child entities, mimicking cluster sharding semantics without requiring a cluster:\n\n```csharp\nusing Akka.Actor;\nusing Akka.Cluster.Sharding;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F A generic \"child per entity\" parent actor.\n\u002F\u002F\u002F \u003C\u002Fsummary>\n\u002F\u002F\u002F \u003Cremarks>\n\u002F\u002F\u002F Reuses Akka.Cluster.Sharding's IMessageExtractor for consistent routing.\n\u002F\u002F\u002F Ideal for unit tests where clustering overhead is unnecessary.\n\u002F\u002F\u002F \u003C\u002Fremarks>\npublic sealed class GenericChildPerEntityParent : ReceiveActor\n{\n    public static Props CreateProps(\n        IMessageExtractor extractor,\n        Func\u003Cstring, Props> propsFactory)\n    {\n        return Props.Create(() =>\n            new GenericChildPerEntityParent(extractor, propsFactory));\n    }\n\n    private readonly IMessageExtractor _extractor;\n    private readonly Func\u003Cstring, Props> _propsFactory;\n\n    public GenericChildPerEntityParent(\n        IMessageExtractor extractor,\n        Func\u003Cstring, Props> propsFactory)\n    {\n        _extractor = extractor;\n        _propsFactory = propsFactory;\n\n        ReceiveAny(message =>\n        {\n            var entityId = _extractor.EntityId(message);\n            if (entityId is null) return;\n\n            \u002F\u002F Get existing child or create new one\n            Context.Child(entityId)\n                .GetOrElse(() => Context.ActorOf(_propsFactory(entityId), entityId))\n                .Forward(_extractor.EntityMessage(message));\n        });\n    }\n}\n```\n\n## Message Extractors\n\nCreate extractors that implement `IMessageExtractor` from Akka.Cluster.Sharding:\n\n```csharp\nusing Akka.Cluster.Sharding;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Routes messages to entity actors based on a strongly-typed ID.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class OrderMessageExtractor : HashCodeMessageExtractor\n{\n    public const int DefaultShardCount = 40;\n\n    public OrderMessageExtractor(int maxNumberOfShards = DefaultShardCount)\n        : base(maxNumberOfShards)\n    {\n    }\n\n    public override string? EntityId(object message)\n    {\n        return message switch\n        {\n            IWithOrderId msg => msg.OrderId.Value.ToString(),\n            _ => null\n        };\n    }\n}\n\n\u002F\u002F Define an interface for messages that target a specific entity\npublic interface IWithOrderId\n{\n    OrderId OrderId { get; }\n}\n\n\u002F\u002F Use strongly-typed IDs\npublic readonly record struct OrderId(Guid Value)\n{\n    public static OrderId New() => new(Guid.NewGuid());\n    public override string ToString() => Value.ToString();\n}\n```\n\n## Akka.Hosting Extension Methods\n\nCreate extension methods that abstract the execution mode:\n\n```csharp\nusing Akka.Cluster.Hosting;\nusing Akka.Cluster.Sharding;\nusing Akka.Hosting;\n\npublic static class OrderActorHostingExtensions\n{\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Adds OrderActor with support for both local and clustered modes.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    public static AkkaConfigurationBuilder WithOrderActor(\n        this AkkaConfigurationBuilder builder,\n        AkkaExecutionMode executionMode = AkkaExecutionMode.Clustered,\n        string? clusterRole = null)\n    {\n        if (executionMode == AkkaExecutionMode.LocalTest)\n        {\n            \u002F\u002F Non-clustered mode: Use GenericChildPerEntityParent\n            builder.WithActors((system, registry, resolver) =>\n            {\n                var parent = system.ActorOf(\n                    GenericChildPerEntityParent.CreateProps(\n                        new OrderMessageExtractor(),\n                        entityId => resolver.Props\u003COrderActor>(entityId)),\n                    \"orders\");\n\n                registry.Register\u003COrderActor>(parent);\n            });\n        }\n        else\n        {\n            \u002F\u002F Clustered mode: Use ShardRegion\n            builder.WithShardRegion\u003COrderActor>(\n                \"orders\",\n                (system, registry, resolver) =>\n                    entityId => resolver.Props\u003COrderActor>(entityId),\n                new OrderMessageExtractor(),\n                new ShardOptions\n                {\n                    StateStoreMode = StateStoreMode.DData,\n                    Role = clusterRole\n                });\n        }\n\n        return builder;\n    }\n}\n```\n\n## Composing Multiple Actors\n\nCreate a convenience method that registers all domain actors:\n\n```csharp\npublic static class DomainActorHostingExtensions\n{\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Adds all order domain actors with sharding support.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    public static AkkaConfigurationBuilder WithOrderDomainActors(\n        this AkkaConfigurationBuilder builder,\n        AkkaExecutionMode executionMode = AkkaExecutionMode.Clustered,\n        string? clusterRole = null)\n    {\n        return builder\n            .WithOrderActor(executionMode, clusterRole)\n            .WithPaymentActor(executionMode, clusterRole)\n            .WithShipmentActor(executionMode, clusterRole)\n            .WithNotificationActor(); \u002F\u002F Singleton, no sharding needed\n    }\n}\n```\n\n## Using ITimeProvider for Scheduling\n\nRegister the ActorSystem's Scheduler as an `ITimeProvider` for testable time-based logic:\n\n```csharp\npublic static class SharedAkkaHostingExtensions\n{\n    public static IServiceCollection AddAkkaWithTimeProvider(\n        this IServiceCollection services,\n        Action\u003CAkkaConfigurationBuilder, IServiceProvider> configure)\n    {\n        \u002F\u002F Register ITimeProvider using the ActorSystem's Scheduler\n        services.AddSingleton\u003CITimeProvider>(sp =>\n            sp.GetRequiredService\u003CActorSystem>().Scheduler);\n\n        return services.ConfigureAkka((builder, sp) =>\n        {\n            configure(builder, sp);\n        });\n    }\n}\n\n\u002F\u002F In your actor, inject ITimeProvider\npublic class SubscriptionActor : ReceiveActor\n{\n    private readonly ITimeProvider _timeProvider;\n\n    public SubscriptionActor(ITimeProvider timeProvider)\n    {\n        _timeProvider = timeProvider;\n\n        \u002F\u002F Use _timeProvider.GetUtcNow() instead of DateTime.UtcNow\n        \u002F\u002F This allows tests to control time\n    }\n}\n```\n\n## Akka.Reminders Integration\n\nFor durable scheduled tasks that survive restarts, use akka-reminders:\n\n```csharp\nusing Akka.Reminders;\nusing Akka.Reminders.Sql;\nusing Akka.Reminders.Sql.Configuration;\nusing Akka.Reminders.Storage;\n\npublic static class ReminderHostingExtensions\n{\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Configures akka-reminders with PostgreSQL storage.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    public static AkkaConfigurationBuilder WithPostgresReminders(\n        this AkkaConfigurationBuilder builder,\n        string connectionString,\n        string schemaName = \"reminders\",\n        string tableName = \"scheduled_reminders\",\n        bool autoInitialize = true)\n    {\n        return builder.WithLocalReminders(reminders => reminders\n            .WithResolver(sys => new GenericChildPerEntityResolver(sys))\n            .WithStorage(system =>\n            {\n                var settings = SqlReminderStorageSettings.CreatePostgreSql(\n                    connectionString,\n                    schemaName,\n                    tableName,\n                    autoInitialize);\n                return new SqlReminderStorage(settings, system);\n            })\n            .WithSettings(new ReminderSettings\n            {\n                MaxSlippage = TimeSpan.FromSeconds(30),\n                MaxDeliveryAttempts = 3,\n                RetryBackoffBase = TimeSpan.FromSeconds(10)\n            }));\n    }\n\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Configures akka-reminders with in-memory storage for testing.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    public static AkkaConfigurationBuilder WithInMemoryReminders(\n        this AkkaConfigurationBuilder builder)\n    {\n        return builder.WithLocalReminders(reminders => reminders\n            .WithResolver(sys => new GenericChildPerEntityResolver(sys))\n            .WithStorage(system => new InMemoryReminderStorage())\n            .WithSettings(new ReminderSettings\n            {\n                MaxSlippage = TimeSpan.FromSeconds(1),\n                MaxDeliveryAttempts = 3,\n                RetryBackoffBase = TimeSpan.FromMilliseconds(100)\n            }));\n    }\n}\n```\n\n### Custom Reminder Resolver for Child-Per-Entity\n\nRoute reminder callbacks to GenericChildPerEntityParent actors:\n\n```csharp\nusing Akka.Actor;\nusing Akka.Hosting;\nusing Akka.Reminders;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Resolves reminder targets to GenericChildPerEntityParent actors.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class GenericChildPerEntityResolver : IReminderActorResolver\n{\n    private readonly ActorSystem _system;\n\n    public GenericChildPerEntityResolver(ActorSystem system)\n    {\n        _system = system;\n    }\n\n    public IActorRef ResolveActorRef(ReminderEntry entry)\n    {\n        var registry = ActorRegistry.For(_system);\n\n        return entry.Key switch\n        {\n            var k when k.StartsWith(\"order-\") =>\n                registry.Get\u003COrderActor>(),\n            var k when k.StartsWith(\"subscription-\") =>\n                registry.Get\u003CSubscriptionActor>(),\n            _ => throw new InvalidOperationException(\n                $\"Unknown reminder key format: {entry.Key}\")\n        };\n    }\n}\n```\n\n## Singleton Actors (Not Sharded)\n\nFor actors that should only have one instance:\n\n```csharp\npublic static AkkaConfigurationBuilder WithEmailSenderActor(\n    this AkkaConfigurationBuilder builder)\n{\n    return builder.WithActors((system, registry, resolver) =>\n    {\n        var actor = system.ActorOf(\n            resolver.Props\u003CEmailSenderActor>(),\n            \"email-sender\");\n        registry.Register\u003CEmailSenderActor>(actor);\n    });\n}\n```\n\n## Marker Types for Registry\n\nWhen you need to reference actors that are registered as parents:\n\n```csharp\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Marker type for ActorRegistry to retrieve the order manager\n\u002F\u002F\u002F (GenericChildPerEntityParent for OrderActors).\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class OrderManagerActor;\n\n\u002F\u002F Usage in extension method\nregistry.Register\u003COrderManagerActor>(parent);\n\n\u002F\u002F Usage in controller\u002Fservice\npublic class OrderService\n{\n    private readonly IActorRef _orderManager;\n\n    public OrderService(IRequiredActor\u003COrderManagerActor> orderManager)\n    {\n        _orderManager = orderManager.ActorRef;\n    }\n\n    public async Task\u003COrderResponse> CreateOrder(CreateOrderCommand cmd)\n    {\n        return await _orderManager.Ask\u003COrderResponse>(cmd);\n    }\n}\n```\n\n## DI Scope Management in Actors\n\n**Actors don't have automatic DI scopes.** Unlike ASP.NET controllers (where each HTTP request creates a scope), actors are long-lived. If you need scoped services (like `DbContext`), inject `IServiceProvider` and create scopes manually.\n\n### Pattern: Scope Per Message\n\n```csharp\npublic sealed class OrderProcessingActor : ReceiveActor\n{\n    private readonly IServiceProvider _serviceProvider;\n    private readonly IActorRef _notificationActor;\n\n    public OrderProcessingActor(\n        IServiceProvider serviceProvider,\n        IRequiredActor\u003CNotificationActor> notificationActor)\n    {\n        _serviceProvider = serviceProvider;\n        _notificationActor = notificationActor.ActorRef;\n\n        ReceiveAsync\u003CProcessOrder>(HandleProcessOrder);\n    }\n\n    private async Task HandleProcessOrder(ProcessOrder msg)\n    {\n        \u002F\u002F Create scope for this message - disposed after processing\n        using var scope = _serviceProvider.CreateScope();\n\n        \u002F\u002F Resolve scoped services within the scope\n        var orderRepository = scope.ServiceProvider.GetRequiredService\u003CIOrderRepository>();\n        var paymentService = scope.ServiceProvider.GetRequiredService\u003CIPaymentService>();\n        var emailComposer = scope.ServiceProvider.GetRequiredService\u003CIOrderEmailComposer>();\n\n        \u002F\u002F Do work with scoped services\n        var order = await orderRepository.GetByIdAsync(msg.OrderId);\n        var payment = await paymentService.ProcessAsync(order);\n\n        \u002F\u002F DbContext changes committed when scope disposes\n    }\n}\n```\n\n### Why This Pattern\n\n| Benefit | Explanation |\n|---------|-------------|\n| **Fresh DbContext per message** | No stale entity tracking between messages |\n| **Proper disposal** | Database connections released after each message |\n| **Isolation** | One message's errors don't corrupt another's state |\n| **Testable** | Can inject mock IServiceProvider in tests |\n\n### Singleton Services - Direct Injection\n\nFor stateless, thread-safe services, inject directly (no scope needed):\n\n```csharp\npublic sealed class NotificationActor : ReceiveActor\n{\n    private readonly IEmailLinkGenerator _linkGenerator;  \u002F\u002F Singleton - OK!\n    private readonly IMjmlTemplateRenderer _renderer;     \u002F\u002F Singleton - OK!\n\n    public NotificationActor(\n        IEmailLinkGenerator linkGenerator,\n        IMjmlTemplateRenderer renderer)\n    {\n        _linkGenerator = linkGenerator;\n        _renderer = renderer;\n\n        Receive\u003CSendWelcomeEmail>(Handle);\n    }\n}\n```\n\n### Common Mistake: Injecting Scoped Services Directly\n\n```csharp\n\u002F\u002F BAD: Scoped service injected into long-lived actor\npublic sealed class BadActor : ReceiveActor\n{\n    private readonly IOrderRepository _repo;  \u002F\u002F Scoped! DbContext lives forever!\n\n    public BadActor(IOrderRepository repo)  \u002F\u002F Captured at actor creation\n    {\n        _repo = repo;  \u002F\u002F This DbContext will become stale\n    }\n}\n\n\u002F\u002F GOOD: Inject IServiceProvider, create scope per message\npublic sealed class GoodActor : ReceiveActor\n{\n    private readonly IServiceProvider _sp;\n\n    public GoodActor(IServiceProvider sp)\n    {\n        _sp = sp;\n        ReceiveAsync\u003CProcessOrder>(async msg =>\n        {\n            using var scope = _sp.CreateScope();\n            var repo = scope.ServiceProvider.GetRequiredService\u003CIOrderRepository>();\n            \u002F\u002F Fresh DbContext for this message\n        });\n    }\n}\n```\n\nFor more on DI lifetimes and scope management, see `$deniz-dotnet-general:dependency-injection-patterns` skill.\n\n---\n\n## Cluster Sharding Configuration\n\n### RememberEntities: Almost Always False\n\n`RememberEntities` controls whether the shard region remembers and automatically restarts all entities that were ever created. **This should almost always be `false`.**\n\n```csharp\nbuilder.WithShardRegion\u003COrderActor>(\n    \"orders\",\n    (system, registry, resolver) => entityId => resolver.Props\u003COrderActor>(entityId),\n    new OrderMessageExtractor(),\n    new ShardOptions\n    {\n        StateStoreMode = StateStoreMode.DData,\n        RememberEntities = false,  \u002F\u002F DEFAULT - almost always correct\n        Role = clusterRole\n    });\n```\n\n**When `RememberEntities = true` causes problems:**\n\n| Problem | Explanation |\n|---------|-------------|\n| **Unbounded memory growth** | Every entity ever created gets remembered and restarted forever |\n| **Slow cluster startup** | Cluster must restart thousands\u002Fmillions of entities on boot |\n| **Stale entity resurrection** | Expired sessions, sent emails, old orders all get restarted |\n| **No passivation** | Idle entities consume memory indefinitely (passivation is disabled) |\n\n### When to Use Each Setting\n\n| Entity Type | RememberEntities | Reason |\n|-------------|------------------|--------|\n| `UserSessionActor` | **false** | Sessions expire, created on login |\n| `DraftActor` | **false** | Drafts are sent\u002Fdiscarded, ephemeral |\n| `EmailSenderActor` | **false** | Fire-and-forget operations |\n| `OrderActor` | **false** | Orders complete, new ones created constantly |\n| `ShoppingCartActor` | **false** | Carts expire, abandoned carts common |\n| `TenantActor` | *maybe true* | Fixed set of tenants, always needed |\n| `AccountActor` | *maybe true* | Bounded set of accounts, long-lived |\n\n**Rule of thumb:** Use `RememberEntities = true` only for:\n1. **Bounded** entity sets (known upper limit)\n2. **Long-lived** domain entities that should always be available\n3. Entities where the **cost of remembering \u003C cost of lazy creation**\n\n### Marker Types with WithShardRegion\u003CT>\n\nWhen using `WithShardRegion\u003CT>`, the generic parameter `T` serves as a marker type for the `ActorRegistry`. Use a dedicated marker type (not the actor class itself) for consistent registry access:\n\n```csharp\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Marker type for ActorRegistry. Use this to retrieve the OrderActor shard region.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class OrderActorRegion;\n\n\u002F\u002F Registration - use marker type as generic parameter\nbuilder.WithShardRegion\u003COrderActorRegion>(\n    \"orders\",\n    (system, registry, resolver) => entityId => resolver.Props\u003COrderActor>(entityId),\n    new OrderMessageExtractor(),\n    new ShardOptions { StateStoreMode = StateStoreMode.DData });\n\n\u002F\u002F Retrieval - same marker type\nvar orderRegion = ActorRegistry.Get\u003COrderActorRegion>();\norderRegion.Tell(new CreateOrder(orderId, amount));\n```\n\n**Why marker types?**\n- `WithShardRegion\u003CT>` auto-registers the shard region under type `T`\n- Using the actor class directly can cause confusion (registry returns region, not actor)\n- Marker types make the intent explicit and work consistently in both LocalTest and Clustered modes\n\n### Avoiding Redundant Registry Calls\n\n`WithShardRegion\u003CT>` automatically registers the shard region in the `ActorRegistry`. Don't call `registry.Register\u003CT>()` again:\n\n```csharp\n\u002F\u002F BAD - redundant registration\nbuilder.WithShardRegion\u003COrderActorRegion>(\"orders\", ...)\n    .WithActors((system, registry, resolver) =>\n    {\n        var region = registry.Get\u003COrderActorRegion>();\n        registry.Register\u003COrderActorRegion>(region);  \u002F\u002F UNNECESSARY!\n    });\n\n\u002F\u002F GOOD - WithShardRegion already registers\nbuilder.WithShardRegion\u003COrderActorRegion>(\"orders\", ...);\n\u002F\u002F That's it - OrderActorRegion is now in the registry\n```\n\n---\n\n## Best Practices\n\n1. **Always support both execution modes** - Makes testing easy without code changes\n2. **Use strongly-typed IDs** - `OrderId` instead of `string` or `Guid`\n3. **Interface-based message routing** - `IWithOrderId` for type-safe extraction\n4. **Register parent, not children** - For child-per-entity, register the parent in ActorRegistry\n5. **Marker types for clarity** - Use empty marker classes for registry lookups\n6. **Composition over inheritance** - Chain extension methods, don't create deep hierarchies\n7. **ITimeProvider for scheduling** - Never use `DateTime.Now` directly in actors\n8. **akka-reminders for durability** - Use for scheduled tasks that must survive restarts\n9. **RememberEntities = false by default** - Only set to true for bounded, long-lived entities\n","# Akka.Hosting Actor Patterns\n\n## When to Use This Skill\n\nUse this skill when:\n- Building entity actors that represent domain objects (users, orders, invoices, etc.)\n- Need actors that work in both unit tests (no clustering) and production (cluster sharding)\n- Setting up scheduled tasks with akka-reminders\n- Registering actors with Akka.Hosting extension methods\n- Creating reusable actor configuration patterns\n\n## Core Principles\n\n1. **Execution Mode Abstraction** - Same actor code runs locally (tests) or clustered (production)\n2. **GenericChildPerEntityParent for Local** - Mimics sharding semantics without cluster overhead\n3. **Message Extractors for Routing** - Reuse Akka.Cluster.Sharding's IMessageExtractor interface\n4. **Akka.Hosting Extension Methods** - Fluent configuration that composes well\n5. **ITimeProvider for Testability** - Use ActorSystem.Scheduler instead of DateTime.Now\n\n## Execution Modes\n\nDefine an enum to control actor behavior:\n\n```csharp\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Determines how Akka.NET should be configured\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic enum AkkaExecutionMode\n{\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Pure local actor system - no remoting, no clustering.\n    \u002F\u002F\u002F Use GenericChildPerEntityParent instead of ShardRegion.\n    \u002F\u002F\u002F Ideal for unit tests and simple scenarios.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    LocalTest,\n\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Full clustering with ShardRegion.\n    \u002F\u002F\u002F Use for integration testing and production.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    Clustered\n}\n```\n\n## GenericChildPerEntityParent\n\nA lightweight parent actor that routes messages to child entities, mimicking cluster sharding semantics without requiring a cluster:\n\n```csharp\nusing Akka.Actor;\nusing Akka.Cluster.Sharding;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F A generic \"child per entity\" parent actor.\n\u002F\u002F\u002F \u003C\u002Fsummary>\n\u002F\u002F\u002F \u003Cremarks>\n\u002F\u002F\u002F Reuses Akka.Cluster.Sharding's IMessageExtractor for consistent routing.\n\u002F\u002F\u002F Ideal for unit tests where clustering overhead is unnecessary.\n\u002F\u002F\u002F \u003C\u002Fremarks>\npublic sealed class GenericChildPerEntityParent : ReceiveActor\n{\n    public static Props CreateProps(\n        IMessageExtractor extractor,\n        Func\u003Cstring, Props> propsFactory)\n    {\n        return Props.Create(() =>\n            new GenericChildPerEntityParent(extractor, propsFactory));\n    }\n\n    private readonly IMessageExtractor _extractor;\n    private readonly Func\u003Cstring, Props> _propsFactory;\n\n    public GenericChildPerEntityParent(\n        IMessageExtractor extractor,\n        Func\u003Cstring, Props> propsFactory)\n    {\n        _extractor = extractor;\n        _propsFactory = propsFactory;\n\n        ReceiveAny(message =>\n        {\n            var entityId = _extractor.EntityId(message);\n            if (entityId is null) return;\n\n            \u002F\u002F Get existing child or create new one\n            Context.Child(entityId)\n                .GetOrElse(() => Context.ActorOf(_propsFactory(entityId), entityId))\n                .Forward(_extractor.EntityMessage(message));\n        });\n    }\n}\n```\n\n## Message Extractors\n\nCreate extractors that implement `IMessageExtractor` from Akka.Cluster.Sharding:\n\n```csharp\nusing Akka.Cluster.Sharding;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Routes messages to entity actors based on a strongly-typed ID.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class OrderMessageExtractor : HashCodeMessageExtractor\n{\n    public const int DefaultShardCount = 40;\n\n    public OrderMessageExtractor(int maxNumberOfShards = DefaultShardCount)\n        : base(maxNumberOfShards)\n    {\n    }\n\n    public override string? EntityId(object message)\n    {\n        return message switch\n        {\n            IWithOrderId msg => msg.OrderId.Value.ToString(),\n            _ => null\n        };\n    }\n}\n\n\u002F\u002F Define an interface for messages that target a specific entity\npublic interface IWithOrderId\n{\n    OrderId OrderId { get; }\n}\n\n\u002F\u002F Use strongly-typed IDs\npublic readonly record struct OrderId(Guid Value)\n{\n    public static OrderId New() => new(Guid.NewGuid());\n    public override string ToString() => Value.ToString();\n}\n```\n\n## Akka.Hosting Extension Methods\n\nCreate extension methods that abstract the execution mode:\n\n```csharp\nusing Akka.Cluster.Hosting;\nusing Akka.Cluster.Sharding;\nusing Akka.Hosting;\n\npublic static class OrderActorHostingExtensions\n{\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Adds OrderActor with support for both local and clustered modes.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    public static AkkaConfigurationBuilder WithOrderActor(\n        this AkkaConfigurationBuilder builder,\n        AkkaExecutionMode executionMode = AkkaExecutionMode.Clustered,\n        string? clusterRole = null)\n    {\n        if (executionMode == AkkaExecutionMode.LocalTest)\n        {\n            \u002F\u002F Non-clustered mode: Use GenericChildPerEntityParent\n            builder.WithActors((system, registry, resolver) =>\n            {\n                var parent = system.ActorOf(\n                    GenericChildPerEntityParent.CreateProps(\n                        new OrderMessageExtractor(),\n                        entityId => resolver.Props\u003COrderActor>(entityId)),\n                    \"orders\");\n\n                registry.Register\u003COrderActor>(parent);\n            });\n        }\n        else\n        {\n            \u002F\u002F Clustered mode: Use ShardRegion\n            builder.WithShardRegion\u003COrderActor>(\n                \"orders\",\n                (system, registry, resolver) =>\n                    entityId => resolver.Props\u003COrderActor>(entityId),\n                new OrderMessageExtractor(),\n                new ShardOptions\n                {\n                    StateStoreMode = StateStoreMode.DData,\n                    Role = clusterRole\n                });\n        }\n\n        return builder;\n    }\n}\n```\n\n## Composing Multiple Actors\n\nCreate a convenience method that registers all domain actors:\n\n```csharp\npublic static class DomainActorHostingExtensions\n{\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Adds all order domain actors with sharding support.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    public static AkkaConfigurationBuilder WithOrderDomainActors(\n        this AkkaConfigurationBuilder builder,\n        AkkaExecutionMode executionMode = AkkaExecutionMode.Clustered,\n        string? clusterRole = null)\n    {\n        return builder\n            .WithOrderActor(executionMode, clusterRole)\n            .WithPaymentActor(executionMode, clusterRole)\n            .WithShipmentActor(executionMode, clusterRole)\n            .WithNotificationActor(); \u002F\u002F Singleton, no sharding needed\n    }\n}\n```\n\n## Using ITimeProvider for Scheduling\n\nRegister the ActorSystem's Scheduler as an `ITimeProvider` for testable time-based logic:\n\n```csharp\npublic static class SharedAkkaHostingExtensions\n{\n    public static IServiceCollection AddAkkaWithTimeProvider(\n        this IServiceCollection services,\n        Action\u003CAkkaConfigurationBuilder, IServiceProvider> configure)\n    {\n        \u002F\u002F Register ITimeProvider using the ActorSystem's Scheduler\n        services.AddSingleton\u003CITimeProvider>(sp =>\n            sp.GetRequiredService\u003CActorSystem>().Scheduler);\n\n        return services.ConfigureAkka((builder, sp) =>\n        {\n            configure(builder, sp);\n        });\n    }\n}\n\n\u002F\u002F In your actor, inject ITimeProvider\npublic class SubscriptionActor : ReceiveActor\n{\n    private readonly ITimeProvider _timeProvider;\n\n    public SubscriptionActor(ITimeProvider timeProvider)\n    {\n        _timeProvider = timeProvider;\n\n        \u002F\u002F Use _timeProvider.GetUtcNow() instead of DateTime.UtcNow\n        \u002F\u002F This allows tests to control time\n    }\n}\n```\n\n## Akka.Reminders Integration\n\nFor durable scheduled tasks that survive restarts, use akka-reminders:\n\n```csharp\nusing Akka.Reminders;\nusing Akka.Reminders.Sql;\nusing Akka.Reminders.Sql.Configuration;\nusing Akka.Reminders.Storage;\n\npublic static class ReminderHostingExtensions\n{\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Configures akka-reminders with PostgreSQL storage.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    public static AkkaConfigurationBuilder WithPostgresReminders(\n        this AkkaConfigurationBuilder builder,\n        string connectionString,\n        string schemaName = \"reminders\",\n        string tableName = \"scheduled_reminders\",\n        bool autoInitialize = true)\n    {\n        return builder.WithLocalReminders(reminders => reminders\n            .WithResolver(sys => new GenericChildPerEntityResolver(sys))\n            .WithStorage(system =>\n            {\n                var settings = SqlReminderStorageSettings.CreatePostgreSql(\n                    connectionString,\n                    schemaName,\n                    tableName,\n                    autoInitialize);\n                return new SqlReminderStorage(settings, system);\n            })\n            .WithSettings(new ReminderSettings\n            {\n                MaxSlippage = TimeSpan.FromSeconds(30),\n                MaxDeliveryAttempts = 3,\n                RetryBackoffBase = TimeSpan.FromSeconds(10)\n            }));\n    }\n\n    \u002F\u002F\u002F \u003Csummary>\n    \u002F\u002F\u002F Configures akka-reminders with in-memory storage for testing.\n    \u002F\u002F\u002F \u003C\u002Fsummary>\n    public static AkkaConfigurationBuilder WithInMemoryReminders(\n        this AkkaConfigurationBuilder builder)\n    {\n        return builder.WithLocalReminders(reminders => reminders\n            .WithResolver(sys => new GenericChildPerEntityResolver(sys))\n            .WithStorage(system => new InMemoryReminderStorage())\n            .WithSettings(new ReminderSettings\n            {\n                MaxSlippage = TimeSpan.FromSeconds(1),\n                MaxDeliveryAttempts = 3,\n                RetryBackoffBase = TimeSpan.FromMilliseconds(100)\n            }));\n    }\n}\n```\n\n### Custom Reminder Resolver for Child-Per-Entity\n\nRoute reminder callbacks to GenericChildPerEntityParent actors:\n\n```csharp\nusing Akka.Actor;\nusing Akka.Hosting;\nusing Akka.Reminders;\n\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Resolves reminder targets to GenericChildPerEntityParent actors.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class GenericChildPerEntityResolver : IReminderActorResolver\n{\n    private readonly ActorSystem _system;\n\n    public GenericChildPerEntityResolver(ActorSystem system)\n    {\n        _system = system;\n    }\n\n    public IActorRef ResolveActorRef(ReminderEntry entry)\n    {\n        var registry = ActorRegistry.For(_system);\n\n        return entry.Key switch\n        {\n            var k when k.StartsWith(\"order-\") =>\n                registry.Get\u003COrderActor>(),\n            var k when k.StartsWith(\"subscription-\") =>\n                registry.Get\u003CSubscriptionActor>(),\n            _ => throw new InvalidOperationException(\n                $\"Unknown reminder key format: {entry.Key}\")\n        };\n    }\n}\n```\n\n## Singleton Actors (Not Sharded)\n\nFor actors that should only have one instance:\n\n```csharp\npublic static AkkaConfigurationBuilder WithEmailSenderActor(\n    this AkkaConfigurationBuilder builder)\n{\n    return builder.WithActors((system, registry, resolver) =>\n    {\n        var actor = system.ActorOf(\n            resolver.Props\u003CEmailSenderActor>(),\n            \"email-sender\");\n        registry.Register\u003CEmailSenderActor>(actor);\n    });\n}\n```\n\n## Marker Types for Registry\n\nWhen you need to reference actors that are registered as parents:\n\n```csharp\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Marker type for ActorRegistry to retrieve the order manager\n\u002F\u002F\u002F (GenericChildPerEntityParent for OrderActors).\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class OrderManagerActor;\n\n\u002F\u002F Usage in extension method\nregistry.Register\u003COrderManagerActor>(parent);\n\n\u002F\u002F Usage in controller\u002Fservice\npublic class OrderService\n{\n    private readonly IActorRef _orderManager;\n\n    public OrderService(IRequiredActor\u003COrderManagerActor> orderManager)\n    {\n        _orderManager = orderManager.ActorRef;\n    }\n\n    public async Task\u003COrderResponse> CreateOrder(CreateOrderCommand cmd)\n    {\n        return await _orderManager.Ask\u003COrderResponse>(cmd);\n    }\n}\n```\n\n## DI Scope Management in Actors\n\n**Actors don't have automatic DI scopes.** Unlike ASP.NET controllers (where each HTTP request creates a scope), actors are long-lived. If you need scoped services (like `DbContext`), inject `IServiceProvider` and create scopes manually.\n\n### Pattern: Scope Per Message\n\n```csharp\npublic sealed class OrderProcessingActor : ReceiveActor\n{\n    private readonly IServiceProvider _serviceProvider;\n    private readonly IActorRef _notificationActor;\n\n    public OrderProcessingActor(\n        IServiceProvider serviceProvider,\n        IRequiredActor\u003CNotificationActor> notificationActor)\n    {\n        _serviceProvider = serviceProvider;\n        _notificationActor = notificationActor.ActorRef;\n\n        ReceiveAsync\u003CProcessOrder>(HandleProcessOrder);\n    }\n\n    private async Task HandleProcessOrder(ProcessOrder msg)\n    {\n        \u002F\u002F Create scope for this message - disposed after processing\n        using var scope = _serviceProvider.CreateScope();\n\n        \u002F\u002F Resolve scoped services within the scope\n        var orderRepository = scope.ServiceProvider.GetRequiredService\u003CIOrderRepository>();\n        var paymentService = scope.ServiceProvider.GetRequiredService\u003CIPaymentService>();\n        var emailComposer = scope.ServiceProvider.GetRequiredService\u003CIOrderEmailComposer>();\n\n        \u002F\u002F Do work with scoped services\n        var order = await orderRepository.GetByIdAsync(msg.OrderId);\n        var payment = await paymentService.ProcessAsync(order);\n\n        \u002F\u002F DbContext changes committed when scope disposes\n    }\n}\n```\n\n### Why This Pattern\n\n| Benefit | Explanation |\n|---------|-------------|\n| **Fresh DbContext per message** | No stale entity tracking between messages |\n| **Proper disposal** | Database connections released after each message |\n| **Isolation** | One message's errors don't corrupt another's state |\n| **Testable** | Can inject mock IServiceProvider in tests |\n\n### Singleton Services - Direct Injection\n\nFor stateless, thread-safe services, inject directly (no scope needed):\n\n```csharp\npublic sealed class NotificationActor : ReceiveActor\n{\n    private readonly IEmailLinkGenerator _linkGenerator;  \u002F\u002F Singleton - OK!\n    private readonly IMjmlTemplateRenderer _renderer;     \u002F\u002F Singleton - OK!\n\n    public NotificationActor(\n        IEmailLinkGenerator linkGenerator,\n        IMjmlTemplateRenderer renderer)\n    {\n        _linkGenerator = linkGenerator;\n        _renderer = renderer;\n\n        Receive\u003CSendWelcomeEmail>(Handle);\n    }\n}\n```\n\n### Common Mistake: Injecting Scoped Services Directly\n\n```csharp\n\u002F\u002F BAD: Scoped service injected into long-lived actor\npublic sealed class BadActor : ReceiveActor\n{\n    private readonly IOrderRepository _repo;  \u002F\u002F Scoped! DbContext lives forever!\n\n    public BadActor(IOrderRepository repo)  \u002F\u002F Captured at actor creation\n    {\n        _repo = repo;  \u002F\u002F This DbContext will become stale\n    }\n}\n\n\u002F\u002F GOOD: Inject IServiceProvider, create scope per message\npublic sealed class GoodActor : ReceiveActor\n{\n    private readonly IServiceProvider _sp;\n\n    public GoodActor(IServiceProvider sp)\n    {\n        _sp = sp;\n        ReceiveAsync\u003CProcessOrder>(async msg =>\n        {\n            using var scope = _sp.CreateScope();\n            var repo = scope.ServiceProvider.GetRequiredService\u003CIOrderRepository>();\n            \u002F\u002F Fresh DbContext for this message\n        });\n    }\n}\n```\n\nFor more on DI lifetimes and scope management, see `$deniz-dotnet-general:dependency-injection-patterns` skill.\n\n---\n\n## Cluster Sharding Configuration\n\n### RememberEntities: Almost Always False\n\n`RememberEntities` controls whether the shard region remembers and automatically restarts all entities that were ever created. **This should almost always be `false`.**\n\n```csharp\nbuilder.WithShardRegion\u003COrderActor>(\n    \"orders\",\n    (system, registry, resolver) => entityId => resolver.Props\u003COrderActor>(entityId),\n    new OrderMessageExtractor(),\n    new ShardOptions\n    {\n        StateStoreMode = StateStoreMode.DData,\n        RememberEntities = false,  \u002F\u002F DEFAULT - almost always correct\n        Role = clusterRole\n    });\n```\n\n**When `RememberEntities = true` causes problems:**\n\n| Problem | Explanation |\n|---------|-------------|\n| **Unbounded memory growth** | Every entity ever created gets remembered and restarted forever |\n| **Slow cluster startup** | Cluster must restart thousands\u002Fmillions of entities on boot |\n| **Stale entity resurrection** | Expired sessions, sent emails, old orders all get restarted |\n| **No passivation** | Idle entities consume memory indefinitely (passivation is disabled) |\n\n### When to Use Each Setting\n\n| Entity Type | RememberEntities | Reason |\n|-------------|------------------|--------|\n| `UserSessionActor` | **false** | Sessions expire, created on login |\n| `DraftActor` | **false** | Drafts are sent\u002Fdiscarded, ephemeral |\n| `EmailSenderActor` | **false** | Fire-and-forget operations |\n| `OrderActor` | **false** | Orders complete, new ones created constantly |\n| `ShoppingCartActor` | **false** | Carts expire, abandoned carts common |\n| `TenantActor` | *maybe true* | Fixed set of tenants, always needed |\n| `AccountActor` | *maybe true* | Bounded set of accounts, long-lived |\n\n**Rule of thumb:** Use `RememberEntities = true` only for:\n1. **Bounded** entity sets (known upper limit)\n2. **Long-lived** domain entities that should always be available\n3. Entities where the **cost of remembering \u003C cost of lazy creation**\n\n### Marker Types with WithShardRegion\u003CT>\n\nWhen using `WithShardRegion\u003CT>`, the generic parameter `T` serves as a marker type for the `ActorRegistry`. Use a dedicated marker type (not the actor class itself) for consistent registry access:\n\n```csharp\n\u002F\u002F\u002F \u003Csummary>\n\u002F\u002F\u002F Marker type for ActorRegistry. Use this to retrieve the OrderActor shard region.\n\u002F\u002F\u002F \u003C\u002Fsummary>\npublic sealed class OrderActorRegion;\n\n\u002F\u002F Registration - use marker type as generic parameter\nbuilder.WithShardRegion\u003COrderActorRegion>(\n    \"orders\",\n    (system, registry, resolver) => entityId => resolver.Props\u003COrderActor>(entityId),\n    new OrderMessageExtractor(),\n    new ShardOptions { StateStoreMode = StateStoreMode.DData });\n\n\u002F\u002F Retrieval - same marker type\nvar orderRegion = ActorRegistry.Get\u003COrderActorRegion>();\norderRegion.Tell(new CreateOrder(orderId, amount));\n```\n\n**Why marker types?**\n- `WithShardRegion\u003CT>` auto-registers the shard region under type `T`\n- Using the actor class directly can cause confusion (registry returns region, not actor)\n- Marker types make the intent explicit and work consistently in both LocalTest and Clustered modes\n\n### Avoiding Redundant Registry Calls\n\n`WithShardRegion\u003CT>` automatically registers the shard region in the `ActorRegistry`. Don't call `registry.Register\u003CT>()` again:\n\n```csharp\n\u002F\u002F BAD - redundant registration\nbuilder.WithShardRegion\u003COrderActorRegion>(\"orders\", ...)\n    .WithActors((system, registry, resolver) =>\n    {\n        var region = registry.Get\u003COrderActorRegion>();\n        registry.Register\u003COrderActorRegion>(region);  \u002F\u002F UNNECESSARY!\n    });\n\n\u002F\u002F GOOD - WithShardRegion already registers\nbuilder.WithShardRegion\u003COrderActorRegion>(\"orders\", ...);\n\u002F\u002F That's it - OrderActorRegion is now in the registry\n```\n\n---\n\n## Best Practices\n\n1. **Always support both execution modes** - Makes testing easy without code changes\n2. **Use strongly-typed IDs** - `OrderId` instead of `string` or `Guid`\n3. **Interface-based message routing** - `IWithOrderId` for type-safe extraction\n4. **Register parent, not children** - For child-per-entity, register the parent in ActorRegistry\n5. **Marker types for clarity** - Use empty marker classes for registry lookups\n6. **Composition over inheritance** - Chain extension methods, don't create deep hierarchies\n7. **ITimeProvider for scheduling** - Never use `DateTime.Now` directly in actors\n8. **akka-reminders for durability** - Use for scheduled tasks that must survive restarts\n9. **RememberEntities = false by default** - Only set to true for bounded, long-lived entities\n",{"name":5,"description":7},"master","b30b1c1908dbc56a8184128f18803053d762ccb5","codex\u002Fdeniz-dotnet-akka\u002Fskills\u002Fakka-hosting-actor-patterns",0,"https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins","https:\u002F\u002Fgithub.com\u002FBlind-Striker","denizirgin.com","VP of Engineering - \r\n@armutcom @homeruntech @prontopro\r\n |  Speaker \r\n@CodeFiction\r\n, http:\u002F\u002Fcodefiction.tech | Developer, gamer, blogger, maiden iron fan","2026-11-13 00:23:18",{"source":8,"skillName":5,"commands":34,"prompt":44,"zipAvailable":45},[35,38,41],{"tool":36,"command":37},"npx","npx skills add Blind-Striker\u002Fagent-skills-and-plugins --skill akka-hosting-actor-patterns",{"tool":39,"command":40},"bunx","bunx skills add Blind-Striker\u002Fagent-skills-and-plugins --skill akka-hosting-actor-patterns",{"tool":42,"command":43},"pnpm","pnpm dlx skills add Blind-Striker\u002Fagent-skills-and-plugins --skill akka-hosting-actor-patterns","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fcodex\u002Fdeniz-dotnet-akka\u002Fskills\u002Fakka-hosting-actor-patterns\u002FSKILL.md",true,[],[48,55,62,69,76,83],{"skillNo":49,"name":50,"nameZh":6,"description":51,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M79YGWBJ52PHMSTKJ3RJ3AWR","writing-tunit-tests","Write tests in TUnit — the attributes, the async assertion model, data-driven cases, lifecycle hooks, and the parallelism rules. USE FOR writing or fixing a test in a TUnit project, translating a test idea into TUnit syntax, or reviewing TUnit test code for API mistakes. DO NOT USE FOR deciding what to test, judging whether a test is any good, or running tests.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-dotnet-general\u002Fwriting-tunit-tests\u002FSKILL.md",[],[],{"skillNo":56,"name":57,"nameZh":6,"description":58,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":59,"categories":60,"keywords":61,"publishedAt":19},"01M79YGR3Y9RCRS6TD71D0KKP8","dotnet-walls","Walls for a .NET change in a repository without its own quality gates — pinned, ephemeral analyzer, format, clone and scanner commands for the verify step, their identity ratchet, and the build traps. Use during a walls preflight, or when a worker's verify step needs .NET quality gates.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-dotnet-general\u002Fdotnet-walls\u002FSKILL.md",[],[],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":19},"01M79YGFNJBST7D803NQW3SBYM","csharp-15","Write, review and modernize C# 15 (.NET 11) code correctly. Covers every C# 15 feature - collection expression arguments (`[with(...), ...]`), union types (`union`, `[Union]`, `IUnion`, custom unions), closed class hierarchies (`closed`), extension indexers, labeled `break`\u002F`continue`, non-virtual static interface members on runtimes without default interface methods, and the preview memory-safety model (`unsafe(expr)`, `safe`, requires-unsafe members). Use when code targets net11.0 or LangVersion 15\u002Fpreview, when the user mentions any of these features, when replacing marker interfaces, OneOf-style results, `goto`\u002Fflag loop exits or capacity\u002Fcomparer boilerplate, or when the build reports CS8121, CS8509, CS8655, CS8510, CS0121\u002FCS0411 on a `with(...)` element, CS9370, CS9380 or CS9363.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-dotnet-general\u002Fcsharp-15\u002FSKILL.md",[],[],{"skillNo":70,"name":71,"nameZh":6,"description":72,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":73,"categories":74,"keywords":75,"publishedAt":19},"01M79YGAV031473HSX6FN87ENH","verified-waves","Run one task as verified multi-agent waves. Plans the fan-out, sends findings to fresh skeptics, keeps a ledger, and reports N of M done; small tasks stay solo.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-coordination\u002Fverified-waves\u002FSKILL.md",[],[],{"skillNo":77,"name":78,"nameZh":6,"description":79,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M79YG6QXNND4WRPP3GATSY8J","harness","The bundled dispatch harness, which runs a task file on worker models through OpenCode or Codex, fences their writes, escalates their asks to the operator, settles each result from git and its verify commands, and records every step in a ledger. Its commands, task file, modes and write fence, configuration, runs and their recovery, ledger and exit codes.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-coordination\u002Fharness\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":87,"categories":88,"keywords":89,"publishedAt":19},"01M79YG2P5S91SDTA5912XJ4FV","delegating-to-worker-models","Use when you hand off implementation, a plan, research a decision will rely on, or a review, and you brief the worker and check what comes back. A subagent that searches, reads in parallel, or keeps your context small is ordinary tool use. Covers what stays with you, the mechanism, assigning work by strength, the walls preflight, prompts without contradictions, the worker contract and model profiles, evidence from your own run, review, and the fix-up loop.","https:\u002F\u002Fgithub.com\u002FBlind-Striker\u002Fagent-skills-and-plugins\u002Fblob\u002Fmaster\u002Fskills\u002Fdeniz-coordination\u002Fdelegating-to-worker-models\u002FSKILL.md",[],[]]