/shiny:shiny-wearablesfrom shiny
Guide for talking to a companion Apple Watch (WatchConnectivity) or Wear OS (Data Layer) app from .NET MAUI / .NET using Shiny.Wearables - live messages with replies, shared context, queued data and file transfers, and background delivery through a delegate
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.
Read when SKILL.md points to them.
Use this skill when the user needs to:
| Item | Value |
|---|---|
| NuGet | Shiny.Wearables |
| Primary Namespace | Shiny.Wearables |
| Config Namespace | Shiny (AddWearables extension on IServiceCollection) |
| Platforms | iOS (WatchConnectivity), Android (Wear OS Data Layer - phone or a .NET Wear OS app). Other targets register nothing. |
| Shape | API | Needs reachable? | Semantics |
|---|---|---|---|
| Message | SendMessage(path, data) → reply bytes | Yes - throws WearableException(NotReachable) otherwise | Live request/reply. ~64 KB on iOS, ~100 KB on Wear OS |
| Context | UpdateContext(data), GetContext(), GetReceivedContext() | No | Only the newest value is kept, each direction |
| Transfer | Transfer(path, data) → id | No | Queued, in order, delivered once |
| File | TransferFile(path, filePath, metadata) → id | No | Queued; the platform reads the file during transfer - don't delete it until OnTransferCompleted |
// MauiProgram.cs
builder.Services.AddWearables<MyWearableDelegate>(); // manager + delegate
// or
builder.Services.AddWearables(); // manager only
AddWearables<TDelegate>() can be called once per delegate; every delegate runs. On targets other than iOS/Android no IWearableManager is registered - in shared code resolve it optionally (services.GetService<IWearableManager>()) or check GetStatus().IsSupported.
WCSession is activated at startup (an IShinyStartupTask) so deliveries that arrived while the app was closed reach the delegate. Register during app startup.IsSupported is false. Mac Catalyst/macOS/tvOS have no target.watch and nodeId arguments are ignored.shiny_wearable capability (WearableProtocol.Capability). Shiny advertises it for this app at startup; a Kotlin companion declares it in res/values/wear.xml (android_wear_capabilities). A .NET Wear OS app using Shiny.Wearables advertises it automatically too.ShinyWearableListenerService (declared by attributes; no manifest edits), bound by Play services for wear://*/shiny... - also when the app is not running.IsSupported is false.IsPaired and IsAppInstalled survive the watch going away - a paired watch that is off or out of range is still listed (IsConnected = false), found through the capability rather than the connected-node list. The one thing Wear OS cannot see is a paired watch that has never had the companion app installed and is currently away - the Data Layer exposes nothing that reports it.IsConnected = true, IsNearby = false. Transfers and context still go through; it does not count toward IsReachable, because a live message would take seconds.Two different questions, and a UI needs both. Never use one flag for both.
| Question | Flag | Survives the watch being off / out of range? |
|---|---|---|
| Does this user have a watch set up? (show the "send to watch" feature at all) | status.IsConfigured (= IsPaired && IsAppInstalled) | Yes |
| Is the watch here right now? (a "connected" dot, live messages) | status.IsReachable | No |
| Does this platform have a wearable API at all? | status.IsSupported | n/a - fixed per device |
IsSupported is not "a watch is set up". It is false only where there is no wearable API (not iOS/Android, an iPad, Android without Play services). A phone with no watch reports IsSupported = true. Gate features on IsConfigured.
Gating a feature on IsReachable makes it appear and disappear as the user walks around the house. Gating a "connected" indicator on IsConfigured claims the watch is receiving while it is charging in another room.
GetStatus() is async and there is no event on IWearableManager - changes arrive through IWearableDelegate.OnStatusChanged, raised on pair/unpair, app installed/removed, and reachability changes. Cache the last status there and bind to that:
public class WatchStatusDelegate(WatchStatusState state) : WearableDelegate
{
public override Task OnStatusChanged(WearableStatus status)
{
state.Update(status); // the delegate runs off the UI thread - marshal inside Update
return Task.CompletedTask;
}
}
public class WatchStatusState : INotifyPropertyChanged
{
public bool HasWatch { get; private set; } // IsConfigured - stays true while away
public bool IsConnected { get; private set; } // IsReachable - live
public string? WatchName { get; private set; }
public void Update(WearableStatus status) => MainThread.BeginInvokeOnMainThread(() =>
{
this.HasWatch = status.IsConfigured;
this.IsConnected = status.IsReachable;
// a paired-but-away watch is still listed, so it can still be named
this.WatchName = status.Nodes.FirstOrDefault(x => x.HasApp)?.DisplayName;
this.PropertyChanged?.Invoke(this, new(null));
});
public event PropertyChangedEventHandler? PropertyChanged;
}
// register both
services.AddSingleton<WatchStatusState>();
services.AddWearables<WatchStatusDelegate>();
// seed once at startup - OnStatusChanged fires on change, and on Android nothing changes until a capability does
state.Update(await wearables.GetStatus());
Per node, WearableNode carries IsConnected (reachable at all - Bluetooth or cloud), IsNearby (direct Bluetooth) and HasApp. On iOS IsConnected and IsNearby are the same flag - WatchConnectivity has no cloud route.
public class WatchService(IWearableManager wearables)
{
public async Task StartWorkout()
{
var status = await wearables.GetStatus();
if (!status.IsSupported || !status.IsAppInstalled)
return;
if (status.IsReachable)
{
try
{
// key/values go as a JSON object; the reply comes back as key/values
var reply = await wearables.SendMessage("workout/start", new Dictionary<string, object?> { ["kind"] = "run", ["km"] = 5 });
var accepted = reply["accepted"].GetBoolean();
}
catch (WearableException ex) when (ex.Code == WearableErrorCode.NotReachable)
{
// fall back to a queued transfer
await wearables.Transfer("workout/start", new Dictionary<string, object?> { ["kind"] = "run", ["km"] = 5 });
}
}
// plain text goes as UTF-8; the reply comes back as text
string pong = await wearables.SendMessage("ping", "hello");
await wearables.UpdateContext(new Dictionary<string, object?> { ["plan"] = "5k" });
var fileId = await wearables.TransferFile("maps/offline", localPath, new Dictionary<string, string> { ["zoom"] = "14" });
IReadOnlyList<WearableTransferInfo> pending = await wearables.GetPendingTransfers();
bool cancelled = await wearables.CancelTransfer(fileId);
}
}
JsonSerializer.Serialize) to pass as a payload. Structured data is always key/values; the string overloads are for plain text only.sync, workout/start); slashes are trimmed; whitespace, ?, # throw ArgumentException.SendMessage, UpdateContext and Transfer have extension overloads (WearableManagerExtensions, namespace Shiny.Wearables) taking a string (plain text, sent as UTF-8) or an IReadOnlyDictionary<string, TValue> (sent as a JSON object; Dictionary<string, object?> and Dictionary<string, string> both work). The string SendMessage returns the reply as a string; the dictionary one returns IReadOnlyDictionary<string, JsonElement> (empty for an empty reply, JsonException if the reply is not a JSON object). The byte[] members remain for binary payloads.DateTime/DateTimeOffset/TimeSpan/Guid/Uri, enums (by name), byte[] (base64), JsonElement, nested string-keyed dictionaries and lists/arrays. Anything else throws NotSupportedException - break it into a nested dictionary or list. No reflection, so it is trim/AOT safe.public class MyWearableDelegate : WearableDelegate
{
// return value = the reply the watch gets; null lets another delegate answer
// the body reads as message.GetString() or message.GetValues(); WearableData.FromString / FromValues build a reply
public override Task<byte[]?> OnMessageReceived(WearableMessage message) => message.Path switch
{
"ping" => Task.FromResult<byte[]?>(WearableData.FromString("pong")),
"workout/start" => Task.FromResult<byte[]?>(WearableData.FromValues(new Dictionary<string, object?>
{
["accepted"] = message.GetValues()["kind"].GetString() == "run"
})),
_ => Task.FromResult<byte[]?>(null)
};
public override Task OnContextReceived(WearableContext context)
{
var plan = context.GetValues()["plan"].GetString(); // or context.GetString()
return Task.CompletedTask;
}
public override Task OnTransferReceived(WearableTransfer transfer) => Task.CompletedTask; // transfer.GetString() / GetValues()
// file already moved to {AppData}/Shiny.Wearables/{id}/{name}; the delegate owns it
public override Task OnFileReceived(WearableFile file) => Task.CompletedTask;
public override Task OnTransferCompleted(WearableTransferResult result) => Task.CompletedTask; // result.Succeeded / Error
public override Task OnStatusChanged(WearableStatus status) => Task.CompletedTask;
}
message.ExpectsReply is false when the sender used a fire-and-forget send - the return value is discarded.OnTransferCompleted fires when the receiver deletes the data item (the delivery receipt), so result.Path is empty - track by Id.WearableProtocol)watchOS (Swift, WCSession)
sendMessage(["path": String, "data": Data], replyHandler:); reply ["data": Data]. Messages from the phone always carry a reply handler - always call it.updateApplicationContext(["data": Data])transferUserInfo(["id": String, "path": String, "data": Data])transferFile(url, metadata: ["id": String, "path": String, "name": String, "metadata": [String: String]])WCSession.default.sendMessage(["path": "sync", "data": json],
replyHandler: { reply in let data = reply["data"] as? Data },
errorHandler: { print($0) })
func session(_ s: WCSession, didReceiveMessage m: [String: Any], replyHandler: @escaping ([String: Any]) -> Void) {
replyHandler(["data": handle(m["path"] as? String ?? "", m["data"] as? Data ?? Data())])
}
Wear OS (Kotlin, Data Layer)
MessageClient.sendRequest(nodeId, "/shiny/message/{path}", bytes); answer the phone in WearableListenerService.onRequest (or MessageClient.addRpcService) with Tasks.forResult(replyBytes)./shiny/context with byte array data (each node writes its own)./shiny/transfer/{id} with id, path, data; the receiver deletes it after handling (that is the sender's receipt)./shiny/file/{id} with id, path, name, metadata (DataMap of strings), asset file; deleted by the receiver.MESSAGE_RECEIVED, REQUEST_RECEIVED, DATA_CHANGED; scheme wear, host *, path prefix /shiny.val node = Wearable.getCapabilityClient(ctx)
.getCapability("shiny_wearable", CapabilityClient.FILTER_REACHABLE).await().nodes.first()
val reply = Wearable.getMessageClient(ctx).sendRequest(node.id, "/shiny/message/sync", bytes).await()
class PhoneListener : WearableListenerService() {
override fun onRequest(nodeId: String, path: String, request: ByteArray): Task<ByteArray>? =
Tasks.forResult(handle(path.removePrefix("/shiny/message/"), request))
}
WearableStatus, WearableMessage, WearableContext etc. are common names - if another library (e.g. Shiny.AppDeviceBridge.Wearables.Client) defines contracts with the same names, alias one namespace (using Native = Shiny.Wearables;).GetStatus() before live messages; prefer Transfer/UpdateContext for anything that must arrive eventually.IsConfigured and a "connected" indicator on IsReachable - never IsSupported for either.UpdateContext for state, not events - intermediate values are dropped.TransferFile for anything large.TransferFile until OnTransferCompleted reports its id.OnFileReceived - they accumulate under AppData/Shiny.Wearables otherwise.OnMessageReceived: the watch is waiting and WatchConnectivity times out.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-actorsGenerate 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.npx claudepluginhub shinyorg/skills --plugin shinyOther plugins' skills for the same job