shinyorg/shiny/shiny-wearables

Claude Code and agent skill by shinyorg/shiny

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

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

Install

npx vskill@latest install shinyorg/shiny/shiny-wearables

SKILL.md

The same SKILL.md was published earlier as shinyorg/shiny/shiny-wearables.

Shiny Wearables

When to Use This Skill

Use this skill when the user needs to:

  • Send data or commands from a phone app to a companion Apple Watch or Wear OS app (or from a .NET Wear OS app to the phone)
  • Ask the watch something and await its reply
  • Share the latest state (settings, the current plan) with the watch
  • Queue data or files for the watch that must arrive even if it is out of range
  • Receive messages, context, transfers or files from the watch, including in the background
  • Check whether a watch is paired, has the companion app installed, and is reachable
  • Write the Swift (watchOS) or Kotlin (Wear OS) side so it speaks Shiny's wire format

Library Overview

ItemValue
NuGetShiny.Wearables
Primary NamespaceShiny.Wearables
Config NamespaceShiny (AddWearables extension on IServiceCollection)
PlatformsiOS (WatchConnectivity), Android (Wear OS Data Layer - phone or a .NET Wear OS app). Other targets register nothing.
The four shapes
ShapeAPINeeds reachable?Semantics
MessageSendMessage(path, data) → reply bytesYes - throws WearableException(NotReachable) otherwiseLive request/reply. ~64 KB on iOS, ~100 KB on Wear OS
ContextUpdateContext(data), GetContext(), GetReceivedContext()NoOnly the newest value is kept, each direction
TransferTransfer(path, data) → idNoQueued, in order, delivered once
FileTransferFile(path, filePath, metadata) → idNoQueued; the platform reads the file during transfer - don't delete it until OnTransferCompleted

Setup

csharp
// 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.

iOS
  • The WCSession is activated at startup (an IShinyStartupTask) so deliveries that arrived while the app was closed reach the delegate. Register during app startup.
  • iPad has no WatchConnectivity: IsSupported is false. Mac Catalyst/macOS/tvOS have no target.
  • iOS has one active watch; its node id is always watch and nodeId arguments are ignored.
Android / Wear OS
  • Phone and watch apps must share the application id and signing key.
  • The companion is discovered by the `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.
  • Inbound traffic arrives through ShinyWearableListenerService (declared by attributes; no manifest edits), bound by Play services for wear://*/shiny... - also when the app is not running.
  • No Wear OS app / Play services → 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.
  • A Wear OS node can be connected through the cloud when Bluetooth is out of range: IsConnected = true, IsNearby = false. Transfers and context still go through; it does not count toward IsReachable, because a live message would take seconds.

Showing watch status - paired vs. connected

Two different questions, and a UI needs both. Never use one flag for both.

QuestionFlagSurvives 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.IsReachableNo
Does this platform have a wearable API at all?status.IsSupportedn/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:

csharp
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.

Code Generation Instructions and Conventions

Sending
csharp
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);
}
}
  • Never build a JSON string (raw string literals, string interpolation, JsonSerializer.Serialize) to pass as a payload. Structured data is always key/values; the string overloads are for plain text only.
  • Paths are app-defined (sync, workout/start); slashes are trimmed; whitespace, ?, # throw ArgumentException.
  • Never hand-encode payloads. 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.
  • Dictionary values: null, string, bool, numbers, 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.
Receiving
csharp
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;
}
  • Reply semantics: delegates are asked in turn; the first non-null reply wins; a throwing delegate is logged and skipped; with no answer the watch gets an empty reply. message.ExpectsReply is false when the sender used a fire-and-forget send - the return value is discarded.
  • All other callbacks run on every registered delegate.
  • On Wear OS, OnTransferCompleted fires when the receiver deletes the data item (the delivery receipt), so result.Path is empty - track by Id. A transfer you cancel with CancelTransfer does not raise it.
Companion apps (wire format - WearableProtocol)

watchOS (Swift, WCSession)

  • Message: sendMessage(["path": String, "data": Data], replyHandler:); reply ["data": Data]. Messages from the phone always carry a reply handler - always call it.
  • Context: updateApplicationContext(["data": Data])
  • Transfer: transferUserInfo(["id": String, "path": String, "data": Data])
  • File: transferFile(url, metadata: ["id": String, "path": String, "name": String, "metadata": [String: String]])

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/shinyorg/shiny/shiny-wearables/badge)](https://verified-skill.com/skills/shinyorg/shiny/shiny-wearables)

Something wrong with this skill or its page? Tell us.