/shiny:shiny-actorsfrom shiny
Generate code using Shiny.Actors — Orleans-style virtual actors without the ceremony, AOT/trim-clean, running anywhere .NET runs including .NET MAUI and Blazor WebAssembly. Covers actor interfaces and source-generated proxies, the ShinyActorBuilder (AddShinyActors), persistent state with ETags, named states and auto-save, event-sourced JournaledActor with snapshots, state and event migrations, typed streams (durable, implicit consumers), timers and persistent reminders (background jobs via Shiny.Jobs, on-time OS notifications via Shiny.Notifications), concurrency control ([Reentrant], [AlwaysInterleave], [ReadOnly], [StatelessWorker]), call filters and request context, OpenTelemetry traces and metrics, remoting over HTTP (Shiny.Net.HttpServer server, RemoteActorSystem client), mDNS discovery of actor servers, Shiny.DocumentDb storage (SQLite, PostgreSQL, IndexedDB...), and the ActorTestHost testing kit.
Ships in shiny. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are an expert in Shiny.Actors: Orleans-style virtual actors that run in one process (a phone, a browser tab, a server). Other processes and devices can call them over HTTP.
Documentation: https://shinylib.net/actors
Not for: Microsoft Orleans itself (a different library with similar names), Akka.NET, or Proto.Actor.
JsonTypeInfo from the app's own JsonSerializerContext. Every state type, event type, and type crossing a
remote call must be declared there with [JsonSerializable(typeof(...))]. Never use reflection-based
JsonSerializer overloads, Activator, or DispatchProxy.Task, Task<T>, ValueTask or ValueTask<T>. No
properties, generic methods, or ref/out/in parameters. An optional trailing CancellationToken flows to the actor.Actor, Actor<TState> or JournaledActor<TState, TEvent> and implement the
interface. They're never constructed by hand: actors.Get<IFoo>(id) returns a proxy.ConfigureAwait(false) inside an actor that
interleaves ([Reentrant], [AlwaysInterleave], [ReadOnly]): it leaves the actor's scheduler.AddShinyActors(x => ...). Add-on packages are extension methods on
ShinyActorBuilder. Never generate services.AddActors(...), AddActorReminderJob,
AddActorReminderNotifications or AddActorDocumentDbStorage; those don't exist.| Package | Adds | Builder method |
|---|---|---|
Shiny.Actors | Runtime, generator, remote client (RemoteActorSystem) | AddShinyActors |
Shiny.Actors.DocumentDb | State, reminders and event logs on Shiny.DocumentDb | UseDocumentDb(...) |
Shiny.Actors.HttpServer | Serve actors over Shiny.Net.HttpServer | ServeOverHttp(...) |
Shiny.Actors.Jobs | Fire reminders from OS background jobs | UseBackgroundReminders() |
Shiny.Actors.Notifications | Reminders become on-time OS notifications | UseReminderNotifications() |
Shiny.Actors.Discovery | Find actor servers on the LAN (mDNS) | UseDiscovery() |
Shiny.Actors.Testing | ActorTestHost | (test code) |
builder.Services.AddShinyActors(actors => actors
.UseDocumentDb(new SqliteDatabaseProvider($"Data Source={Path.Combine(FileSystem.AppDataDirectory, "app.db")}"))
.UseAutoSave() // write changed state after every call
.Configure(o => o.IdleTimeout = TimeSpan.FromMinutes(5)));
AddShinyActors twice adds to one configuration.AddCallFilter<T>(), UseStateProvider<T>() and AddReminderObserver<T>() are created
by the container.Configure((options, services) => ...) is for things that only exist once the container
is built.await using var actors = new ActorSystem(new ActorSystemOptions { ... });public interface ICart : IActor
{
Task Add(string sku, int quantity);
Task<IReadOnlyDictionary<string, int>> Items();
[OneWay] Task Clear(); // queued; the caller doesn't wait
}
public class CartState { public Dictionary<string, int> Items { get; set; } = []; }
public class CartActor(ILogger<CartActor> logger) : Actor<CartState>, ICart // constructor DI works
{
public async Task Add(string sku, int quantity)
{
this.State.Items[sku] = this.State.Items.GetValueOrDefault(sku) + quantity;
await this.WriteStateAsync(); // or [AutoSave] on the class
}
public Task<IReadOnlyDictionary<string, int>> Items() => Task.FromResult<IReadOnlyDictionary<string, int>>(this.State.Items);
public Task Clear() => this.ClearStateAsync().AsTask();
}
[JsonSerializable(typeof(CartState))]
[JsonSerializable(typeof(IReadOnlyDictionary<string, int>))] // crosses a remote call
public partial class AppJson : JsonSerializerContext;
var cart = actors.Get<ICart>("user-42"); // nothing activates until the first call
await cart.Add("coffee", 2);
OnActivateAsync, OnDeactivateAsync(reason), DeactivateOnIdle(), this.Id, this.Actors (to
call other actors), this.Logger, this.TimeProvider.[ActorName("cart")] pins the name that keys stored state; set it before shipping.Get<T>(Guid) / Get<T>(long) exist.[AutoSave]
public class WalletActor(
[ActorState("balance")] IActorState<Balance> balance, // named states, stored separately
[ActorState("history")] IActorState<History> history
) : Actor, IWallet
{
public Task Deposit(decimal amount) { balance.State.Amount += amount; return Task.CompletedTask; }
}
ActorStateConflictException,
and the actor deactivates and reloads on its next call. Don't catch and retry the write blindly.[AutoSave] (= AfterEachCall) saves changed state before the caller gets the result. A throwing call isn't
saved. [AutoSave(AutoSaveMode.OnDeactivate)] saves only on deactivation.UseFileStorage(dir), or UseDocumentDb(...). Per actor:
[StateProvider("name")]; per state: [ActorState("x", Provider = "name")].[StateVersion(2)] on the type, plus
actors.AddStateMigration<T>(fromVersion, json => ...).[AutoSave] // confirms raised events after each call
public class AccountActor : JournaledActor<AccountState, AccountEvent>, IAccount
{
protected override int SnapshotEvery => 100;
protected override void Apply(AccountState s, AccountEvent e) { /* deterministic */ }
public Task Deposit(decimal amount) { this.RaiseEvent(new Deposited(amount)); return Task.CompletedTask; }
}
[JsonPolymorphic, JsonDerivedType(typeof(Deposited), "deposited"), JsonDerivedType(typeof(Withdrawn), "withdrawn")]
public abstract record AccountEvent;
[JsonPolymorphic]/[JsonDerivedType] on the base. Both TState and TEvent go in
the JsonSerializerContext.ReadEventsAsync(). Stored events are never rewritten; old shapes are upcast on
read with AddStateMigration<TEvent>.await actors.GetStream<OrderPlaced>("store-1").PublishAsync(new OrderPlaced("coffee", 2));
await foreach (var o in actors.GetStream<OrderPlaced>("store-1").ReadAllAsync(ct)) { } // e.g. a view model
// inside an actor: each event is a turn of that actor; the subscription ends with the activation
this.Actors.GetStream<OrderPlaced>("store-1").Subscribe((o, ct) => { /* ... */ return default; });
// implicit: events on key "store-1" activate the actor whose id is "store-1"
public class StoreSales : Actor<Sales>, IStoreSales, IActorStreamConsumer<OrderPlaced> { /* OnNextAsync */ }
actors.AddDurableStream<T>(retain) keeps the last N events, numbered.
ReadFromAsync(afterSequence) replays them, then continues live; remote readers resume after reconnects.RegisterTimer(callback, due, period), called from inside the actor. Ticks run as turns, aren't
persisted, and stop at deactivation.IRemindable, and they activate it when due:await this.RegisterReminderAsync("invoice", TimeSpan.FromHours(1), TimeSpan.FromDays(1),
notification: new ReminderNotification("Invoice", "Ready to send")); // optional OS notification
actors.UseBackgroundReminders() fires them from OS jobs, every 15+ minutes and only roughly on time.
actors.UseReminderNotifications() shows the notification exactly on time, app running or not. A repeating reminder
keeps UpcomingOccurrences (default 3) scheduled. To react to a tap, implement IReminderNotificationHandler on
the actor class (OnReminderNotificationTappedAsync(ReminderNotificationTap tap, ct)); don't write an
INotificationDelegate that parses the payload by hand.UseDocumentDb/UseFileStorage); in-memory is empty
after the OS restarts the app.notification comes before the CancellationToken, so pass the token by name:
cancellationToken: ct.| Use | |
|---|---|
| default | One call at a time |
[Reentrant] (class) | Calls interleave at awaits; the actor can call itself |
[AlwaysInterleave] (method) | Status, cancel or health checks that must not queue behind long work |
[ReadOnly] (method) | Reads run together, never beside a write. Only mark methods that truly don't change state. |
[StatelessWorker(MaxLocalWorkers = n)] (class) | Parallel activations per id. No state or reminders (SACT011). |
ActorDeadlockException naming the path. Fix
it by restructuring, making a call [OneWay], or marking it [AlwaysInterleave]. Calls back into an actor from its
own OnActivateAsync/OnDeactivateAsync throw even when interleaving, so never call out-and-back from those.o.CallTimeout (default 30 s, wall-clock) throws TimeoutException to the caller and cancels the
call's token. Long-running work belongs in a [OneWay] call or a reminder, not a long ask; set
Timeout.InfiniteTimeSpan only deliberately.actors.AddCallFilter<T>() or AddCallFilter(instance). An IActorCallFilter sees ctx.Method,
ctx.Arguments, ctx.ActorId, and a settable ctx.Result. It runs for local and remote calls, asks and one-way.
An actor implementing IActorCallFilter filters its own calls.ActorRequestContext.Set("tenant", id) flows into calls, onward to other actors, and across
remote calls.actors.AddDeadLetterObserver<T>() (IActorDeadLetterObserver.OnDeadLetterAsync(ActorDeadLetter, ct))
hears about one-way calls and stream events that threw or never ran. Suggest one whenever the user relies on
[OneWay] for anything that matters.AddSource(ActorTelemetry.Name) / AddMeter(ActorTelemetry.Name). Traces stay connected across
actors and HTTP.// server - nothing is reachable unless exposed; put authentication in front
actors.ServeOverHttp(
expose => expose.Expose<ICart>().ExposeStream<OrderPlaced>(),
http => { /* address, AddAuthentication().AddApiKey(...), UseAuthentication/UseAuthorization */ },
authorizationPolicies: []);
// client - same IActorSystem; dispose it (it owns the HttpClient it made)
using var remote = new RemoteActorSystem(new Uri("http://192.168.1.20:8080/actors/")) { CallTimeout = TimeSpan.FromSeconds(10) };
Expose<T>(call => ...) (call.User, ActorId,
Method) and ExposeStream<T>(s => ...) (s.User, Key, Access = Publish/Subscribe). Default to a callback
whenever ids map to users.x-actor-context is client-controlled. If a filter checks
ActorRequestContext.Get("user"), the server must have expose.MapRequestContext("user", u => u.Identity?.Name).RemoteActorException.StatusCode is 400 (bad arguments, null for non-nullable), 401/403, 404 (not
exposed), 409 (deadlock, also across processes), 499 (caller gone), 500 (the actor threw; no details unless
IncludeExceptionDetails), 502 (a downstream remote call failed) or 504 (timeout).Address = IPAddress.Any); Shiny.Net.HttpServer
binds loopback by default.actors.UseDiscovery().AdvertiseOverMdns(name) advertises the server while it runs (or
mdns.PublishActorsAsync(name, port) by hand), and mdns.BrowseActorPeersAsync(ct) → peer.Connect(...) on the
client; dispose what Connect returns. Apple platforms need _shinyactors._tcp in
NSBonjourServices plus NSLocalNetworkUsageDescription.await using var host = new ActorTestHost(
services => services.AddSingleton<IClock, FakeClock>(),
actors => actors.UseReminderNotifications());
await host.SetStateAsync<CartActor, CartState>(new CartState { Items = { ["tea"] = 1 } }, id: "u1");
await host.Get<ICart>("u1").Add("coffee", 2);
await host.AdvanceAsync(TimeSpan.FromHours(1)); // timers, reminders, idle deactivation - no sleeps
Assert.Contains(host.Calls, c => c.Method == "Add");
SetStateAsync, SetReminderAsync<TActor>(name, dueAt, period?) and AppendEventsAsync<TActor, TEvent>;
inspect with GetStateAsync, GetRemindersAsync, GetEventsAsync. Seeded state goes through the same $v
stamping and migrations as the runtime.actors callback (UseDocumentDb(...)) replaces the in-memory default, and the helpers use it.| Code | Meaning |
|---|---|
| SACT001 | Interface member can't be proxied (property, generic method, ref/out/in) |
| SACT002 | Method isn't Task/ValueTask-returning |
| SACT003 | [OneWay] method returns a value |
| SACT004 | Class implements an actor interface but doesn't derive from Actor |
| SACT005 | Actor can't be constructed (generic, private, ambiguous constructors) |
| SACT006 | Warning: two classes implement one interface; choose with actors.AddActor<IFoo, Foo>() |
| SACT007 | Warning: a state or event type isn't on any JsonSerializerContext |
| SACT008 | Actor interface is generic or not reachable |
| SACT009 | Two actors share an [ActorName] |
| SACT010 | [ActorState] parameter isn't an IActorState<T> |
| SACT011 | [StatelessWorker] with persistent state |
| SACT012 | Two methods share a wire key (CancellationToken doesn't count) |
| SACT013 | Two actor interfaces share a wire name |
| SACT014 | Warning: [OneWay] method takes a CancellationToken |
| SACT015 | Info: wire type without JSON metadata |
SQLitePCLRaw.lib.e_sqlite3.android on Android, .ios on iOS, and the plain package elsewhere. Never add the
plain one to an Android target: its Linux .so crashes the app at startup.IndexedDbDocumentStore with options.MapActorDocuments(), then call
actors.UseDocumentDb() with no arguments.[AutoSave], or call DeactivateAllAsync() when the app sleeps; the OS kills
backgrounded apps without warning.What SKILL.md sets; muted values are Claude Code's defaults
57 skills in this plugin
/localizegenGenerate strongly-typed localization classes from .resx resource files using Shiny.Extensions.Localization.Generator for .NET applications/shiny-accessorysetupGenerate code using Shiny.BluetoothLE.AccessorySetup - the system accessory pairing sheet for BLE devices (AccessorySetupKit on iOS 18+, CompanionDeviceManager on Android) with no MFi, no location prompt and no general Bluetooth prompt on iOS; picked accessories open as Shiny.BluetoothLE peripherals, and Android adds background presence (device appeared / disappeared) events/shiny-agesignalsGenerate code using Shiny.AgeSignals to read the user's age range as the app store shares it - Apple Declared Age Range (iOS / macOS 26+) and Google Play Age Signals (Android) - for app store accountability laws (Texas SB 2420, Utah, Louisiana, California AB 1043) and age-gated features/shiny-aiconversationGenerate code for Shiny.AiConversation v3 - session-based AI conversations for .NET over Microsoft.Extensions.AI with persisted, resumable sessions (IAiSessionManager / IAiSession / IAiTurn), streaming replies, the built-in ask_user tool for typed questions and multiple-choice answers, interruption and supersession, usage and context-window pressure tracking, rolling context compaction, silent assistant memory, conversation search, session titles and long-term memory, session interceptors for tools and prompts, pluggable session/memory stores (in-memory or SQLite via Shiny.AiConversation.Stores.SqliteDocDb), and voice conversations via Shiny.AiConversation.Voice (wake word, push-to-talk, follow-up, quiet-word/barge-in interruption, sentence-streamed text-to-speech over Shiny.Speech, acknowledgement modes, sounds, voice selection tools), the MAUI chat UI via Shiny.AiConversation.Maui (AiChatView bound to a session with streaming bubbles, choice chips, push-to-talk and an AiMemoryView), image attachments with retention, and the use_camera tool via Shiny.AiConversation.Maui.Camera, and AG-UI via Shiny.AiConversation.AgUi (a session as an AG-UI event stream for the Shiny AgentView with ask_user questions as interrupts, the render_ui tool for A2UI surfaces, and a remote AG-UI agent as the chat client)/shiny-appdevicebridgeGenerate code using Shiny.AppDeviceBridge, device bridges on your app's own Shiny.Net.HttpServer that also host a web app (Blazor WebAssembly, React, Vue, any static build) inside a .NET MAUI app on Android, iOS, Mac Catalyst, Windows and the maui-labs macOS and Linux heads — served from a loopback HTTP server, updated over the air from a signed release server, GitHub releases or a provider of your own, and given device access through bridges with typed C# and TypeScript clients/shiny-appfunctionsGuide for exposing a .NET MAUI / .NET app's functions to Siri, Spotlight, Shortcuts and Apple Intelligence (App Intents) and to Gemini and other agents (Android AppFunctions) from one C# declaration using Shiny.AppFunctions - [AppFunction] records, typed handlers, [AppEntity] entities with queries, [AppShortcut] Siri phrases and delegatesnpx claudepluginhub shinyorg/skills --plugin shinyOther plugins' skills for the same job