/shiny:shiny-contactstorefrom shiny
Generate code using Shiny.Contacts for cross-platform device contact access with CRUD, a fluent async query builder, and Shiny.Core permissions
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.Contacts, a cross-platform library for accessing device contacts on iOS, Mac Catalyst, macOS, and Android.
Invoke this skill when the user wants to:
GitHub: https://github.com/shinyorg/shiny
NuGet: Shiny.Contacts
Namespace: Shiny.Contacts
Shiny.Contacts provides:
AccessState modelPlatform backends: the Contacts framework (CNContactStore) on iOS, Mac Catalyst, and macOS -
one shared implementation - and the ContactsContract content provider on Android.
dotnet add package Shiny.Contacts
The app must call .UseShiny() (from Shiny.Hosting.Maui) so platform services like permissions are wired up.
using Shiny;
builder.UseShiny();
builder.Services.AddContactStore();
Android — Add to AndroidManifest.xml:
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.WRITE_CONTACTS" />
iOS / Mac Catalyst / macOS — Add to Info.plist:
<key>NSContactsUsageDescription</key>
<string>This app needs access to your contacts.</string>
Mac Catalyst / sandboxed macOS — the Info.plist key is not enough. The App Sandbox (which
Mac Catalyst enables by default) also requires the address book entitlement, or RequestAccess
returns Denied with no prompt ever appearing:
<CustomEntitlements Include="com.apple.security.personal-information.addressbook"
Type="Boolean" Value="true" />
Permissions use Shiny.Core's Shiny.AccessState model. IContactStore exposes two members:
// Request access (triggers OS prompt if needed)
var access = await contactStore.RequestAccess();
if (access != AccessState.Available)
{
// Handle denied / restricted
return;
}
// Check current state without prompting
var current = contactStore.GetCurrentAccess();
AccessState.Available — both read and write access grantedAccessState.Restricted — only read or only write granted (not both)AccessState.Denied — neither read nor write grantedAccessState.Available — contacts access authorizedAccessState.Denied — contacts access deniedAccessState.Restricted — contacts access restricted, or (iOS 18+ only) limited to the contacts the user pickedAccessState.Unknown — not yet determinedLimited access does not exist on Mac Catalyst or macOS — access there is all-or-nothing.
IContactStore.Changed is raised when contacts change on the device — edits from other apps, sync, or this store.
The native listener is attached only while something is subscribed, so unsubscribe when you stop showing the data.
The event carries no detail about what changed: re-query what you show. It can arrive on a background thread
and several times for one edit, so dispatch to the UI thread and debounce if the refresh is expensive.
store.Changed += (_, _) => dispatcher.Dispatch(async () => await this.Reload());
Backed by CNContactStoreDidChangeNotification (iOS/Mac Catalyst/macOS) and a ContentObserver on the ContactsContract provider (Android).
public interface IContactStore
{
AccessState GetCurrentAccess();
Task<AccessState> RequestAccess(CancellationToken ct = default);
Task<IReadOnlyList<Contact>> GetAll(CancellationToken ct = default);
Task<Contact?> GetById(string contactId, CancellationToken ct = default);
ContactQuery Query();
Task<string> Create(Contact contact, CancellationToken ct = default);
Task Update(Contact contact, CancellationToken ct = default);
Task Delete(string contactId, CancellationToken ct = default);
}
// Query extensions
Task<IReadOnlyList<char>> contactStore.GetFamilyNameFirstLetters(CancellationToken ct = default);
Query() returns a ContactQuery builder. It is lazy — nothing runs until ToListAsync /
FirstOrDefaultAsync / CountAsync, and the native read happens off the calling thread, so awaiting
it from a UI/view-model method is correct. There is no IQueryable — do not write
.Where(c => …).ToList() LINQ against Query().
public sealed class ContactQuery
{
ContactQuery Where(ContactField field, string value, ContactFilterOperation operation = ContactFilterOperation.Contains);
ContactQuery Where(Func<Contact, bool> predicate); // arbitrary, in-memory
ContactQuery Search(string text); // name/phone/email OR-search; sets Match(Any)
ContactQuery Match(ContactFilterMatch match); // All (default) | Any
ContactQuery OrderBy(ContactSortField field, bool descending = false);
ContactQuery ThenBy(ContactSortField field, bool descending = false);
ContactQuery Skip(int count);
ContactQuery Take(int count);
Task<IReadOnlyList<Contact>> ToListAsync(CancellationToken ct = default);
Task<Contact?> FirstOrDefaultAsync(CancellationToken ct = default);
Task<int> CountAsync(CancellationToken ct = default);
}
// Search box — matches given/family/display name, phone numbers, and emails
var results = await contactStore.Query()
.Search(searchText)
.OrderBy(ContactSortField.FamilyName)
.ThenBy(ContactSortField.GivenName)
.ToListAsync(ct);
// Filter by a specific field (Contains is the default operation)
var johns = await contactStore.Query()
.Where(ContactField.GivenName, "John")
.ToListAsync(ct);
// Multiple field filters are ANDed
var results = await contactStore.Query()
.Where(ContactField.GivenName, "J", ContactFilterOperation.StartsWith)
.Where(ContactField.FamilyName, "Smith")
.ToListAsync(ct);
// Anything the fields don't cover — plain predicate, applied in-memory
var withBirthdays = await contactStore.Query()
.Where(c => c.Dates.Any(d => d.Type == ContactDateType.Birthday))
.ToListAsync(ct);
// Paging
var page = await contactStore.Query()
.Where(ContactField.FamilyName, "A", ContactFilterOperation.StartsWith)
.OrderBy(ContactSortField.FamilyName)
.Skip(10)
.Take(20)
.ToListAsync(ct);
ContactField: GivenName, FamilyName, MiddleName, NamePrefix, NameSuffix, Nickname, DisplayName, Note, Company, JobTitle, Department, Phone, Email
ContactFilterOperation: Contains (default), StartsWith, EndsWith, Equals — all case-insensitive
ContactSortField: GivenName, FamilyName, DisplayName, Company
Natively translated: name fields, Phone and Email on Android; StartsWith/Equals on given/family/display name on Apple (in Match.All mode only). Everything else reads the full contact list and filters in-memory — correct, just slower. Field filters are always re-applied in-memory, so a filter never silently goes missing.
var contact = new Contact
{
GivenName = "John",
FamilyName = "Doe",
Note = "Met at conference"
};
contact.Phones.Add(new ContactPhone("555-1234", PhoneType.Mobile));
contact.Emails.Add(new ContactEmail("[email protected]", EmailType.Work));
string id = await contactStore.Create(contact);
var contact = await contactStore.GetById(id);
contact.GivenName = "Jane";
await contactStore.Update(contact);
await contactStore.Delete(contactId);
| Property | Type |
|---|---|
| Id | string? |
| NamePrefix | string? |
| GivenName | string? |
| MiddleName | string? |
| FamilyName | string? |
| NameSuffix | string? |
| Nickname | string? |
| DisplayName | string |
| Note | string? |
| Organization | ContactOrganization? |
| Photo | byte[]? (see note below) |
| Thumbnail | byte[]? |
| Phones | List<ContactPhone> |
| Emails | List<ContactEmail> |
| Addresses | List<ContactAddress> |
| Dates | List<ContactDate> |
| Relationships | List<ContactRelationship> |
| Websites | List<ContactWebsite> |
PhoneType: Home, Mobile, Work, FaxWork, FaxHome, Pager, Other, Custom
EmailType: Home, Work, Other, Custom
AddressType: Home, Work, Other, Custom
ContactDateType: Birthday, Anniversary, Other, Custom
RelationshipType: Father, Mother, Parent, Brother, Sister, Child, Friend, Spouse, Partner, Assistant, Manager, Other, Custom
GetAll() and Query() populate Thumbnail only; Photo (the full-resolution image) is null on these bulk reads. Decoding every contact's full photo into a byte[] at once spikes memory and can get the app OOM/jetsam-killed on a real device with many photo contacts. To get the full Photo, fetch the single contact with GetById(id) (which populates both Thumbnail and Photo). Bind list rows to Thumbnail and load Photo on a detail screen.
Reading Note and Relationships on iOS requires the com.apple.developer.contacts.notes entitlement. The library probes for access at runtime on every Apple platform, so
the same code runs unchanged on Mac Catalyst and macOS. If the probe fails, Note returns null and Relationships is empty.
await contactStore.RequestAccess() and check for AccessState.Available before any CRUD operationQuery() for filtering — prefer Query().Where(ContactField.…, …).ToListAsync(ct) (or .Search(text)) over GetAll() + LINQ, as it narrows the native readAccessState.Restricted means partial access (read-only or write-only)Thumbnail, not Photo — bulk reads (GetAll/Query) only load Thumbnail; get the full Photo from GetById on a detail screenIContactStore via primary constructorThe optional Shiny.Contacts.Extensions.AI package exposes IContactStore as Microsoft.Extensions.AI tool functions (AIFunctions) for LLM agents. You opt-in exactly which operations the model can see — a read/write allow-list you control on behalf of the agent (not an OS permission prompt; the platform contact permission must already be granted). Read-only by default; write is opt-in. AOT-compatible (hand-built schemas, JsonNode results — no reflection).
using Shiny.Contacts;
using Shiny.Contacts.Extensions.AI;
builder.Services.AddContactStore(); // registers IContactStore
builder.Services.AddContactsAITools(tools => tools
.AddContacts(ContactAICapabilities.ReadWrite) // Read is the default; ReadWrite adds create/update/delete
);
// resolve the bundle and pass the tools to any IChatClient
var tools = sp.GetRequiredService<ContactAITools>().Tools;
var response = await chatClient.GetResponseAsync(
messages,
new ChatOptions { Tools = [.. tools] }
);
Key types:
AddContactsAITools(Action<IContactAIToolBuilder>) — DI extension; throws if nothing is added.IContactAIToolBuilder — AddContacts(ContactAICapabilities).ContactAICapabilities [Flags] — None, Read (default), Write, ReadWrite.ContactAITools — resolve from DI; .Tools is IReadOnlyList<AITool>.Generated tools (only for opted-in capabilities): search_contacts (free-text over name/phone/email), get_contact (by id), create_contact, update_contact, delete_contact.
The AI tools assume permissions are already granted — they do not trigger the platform permission UI (needs a foreground activity). Call
IContactStore.RequestAccess(...)from the app before invoking the agent.delete_contactis irreversible — instruct the model to confirm with the user first.
Combine with the app's own functions:
Shiny.AppFunctions.Extensions.AI(AddAppFunctionAITools, see the shiny-appfunctions skill) exposes the[AppFunction]s Siri and Gemini call as tools in the same*AIToolsbundle shape - concatenate the.Toolslists into oneChatOptions.Tools.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub shinyorg/skills --plugin shiny57 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.Other plugins' skills for the same job