state-management
Cache management, configuration best practices, and progressive disclosure patterns for efficient context window usage. Use when working with large responses, optimizing token costs, or managing plugin state across operations.
What this skill does
# State Management Skill
**Optimizing token efficiency and state management in xc-plugin**
## Overview
The xc-plugin implements sophisticated state management through caching, progressive disclosure, and configuration management. This Skill teaches how to leverage these patterns to minimize token usage, improve performance, and maintain clean state across operations.
**Key Benefits:**
- **85-90% token reduction** through progressive disclosure
- **Cache-friendly operations** avoid redundant work
- **Deterministic state** ensures reliable test results
- **Configuration consistency** across development workflows
## When to Use This Skill
Use this Skill when you need to:
1. **Optimize Token Usage**
- Working with large device lists or build logs
- Reducing context window consumption
- Implementing efficient query patterns
2. **Manage Cache State**
- Understanding when responses are cached
- Invalidating stale cache entries
- Querying cached data efficiently
3. **Handle Configuration**
- Setting up consistent build environments
- Managing simulator preferences
- Configuring test execution parameters
4. **Design Efficient Workflows**
- Implementing progressive disclosure patterns
- Avoiding expensive repeated operations
- Building cache-aware automation
## Key Concepts
### Progressive Disclosure Pattern
**Principle:** Show essentials first, provide details on-demand.
Instead of returning massive datasets that consume tokens, xc-plugin returns:
1. **Summary** - Key metrics and booted devices (~100 tokens)
2. **cache_id** - Reference to full dataset
3. **Follow-up query** - Retrieve complete details only if needed
**Token Efficiency:**
```
Traditional approach: 2000 tokens (full device list)
Progressive disclosure: 100 tokens (summary) + optional 2000 tokens (details)
Average savings: 95% (most queries don't need full details)
```
### Cache Architecture
The plugin uses deterministic caching for expensive operations:
**Cache Key Generation:**
- SHA-256 hash of operation + parameters
- First 16 characters used as `cache_id`
- Deterministic: Same input → Same cache_id
**Cache Storage:**
- In-memory for current session
- Optional disk persistence
- Automatic expiration (configurable TTL)
**Cache-Friendly Operations:**
- `list` operations (device lists, app lists)
- `build` operations (build logs, test results)
- `describe` operations (accessibility trees)
### Response Types
**SuccessResult with Progressive Disclosure:**
```typescript
{
success: true,
data: {
summary: "31 devices available, 1 booted",
booted_devices: [...],
cache_id: "a1b2c3d4e5f6g7h8"
},
summary: "Device list retrieved successfully"
}
```
**Follow-up Query Pattern:**
```typescript
{
operation: "get-details",
cache_id: "a1b2c3d4e5f6g7h8",
detail_type: "full-list"
}
```
## Workflows
### Workflow 1: Cache-Aware Device Listing
**Initial Query (Token-Efficient):**
```json
{
"operation": "list",
"parameters": {
"concise": true
}
}
```
**Response:**
```json
{
"success": true,
"data": {
"summary": {
"total_devices": 47,
"available_devices": 31,
"booted_devices": 1
},
"booted": [
{
"name": "iPhone 15",
"udid": "ABC123...",
"state": "Booted",
"runtime": "iOS 17.0"
}
],
"cache_id": "sim-list-xyz789"
}
}
```
**Follow-Up (Only If Needed):**
```json
{
"operation": "get-details",
"cache_id": "sim-list-xyz789",
"detail_type": "full-list"
}
```
**Token Analysis:**
- Initial query: ~150 tokens
- Follow-up (if needed): ~2000 tokens
- Traditional approach: ~2000 tokens always
- **Savings: 92% when details not needed**
### Workflow 2: Build Cache Management
**Build Operation:**
```json
{
"operation": "build",
"scheme": "MyApp",
"configuration": "Debug",
"output_format": "summary"
}
```
**Response with Cache:**
```json
{
"success": true,
"data": {
"message": "Build succeeded",
"build_time": "45.2s",
"warnings": 3,
"cache_id": "build-abc123"
},
"summary": "Build completed successfully with 3 warnings"
}
```
**Retrieve Full Logs:**
```json
{
"operation": "get-details",
"cache_id": "build-abc123",
"detail_type": "full-log"
}
```
**Cache Invalidation Scenarios:**
- Source code changes
- Scheme configuration changes
- Clean operation executed
- Manual cache clear
### Workflow 3: Configuration State Management
**Query Current Configuration:**
```json
{
"operation": "cache",
"sub_operation": "get-config"
}
```
**Response:**
```json
{
"cache_enabled": true,
"cache_ttl": 3600,
"max_cache_size": 100,
"persistence_enabled": false
}
```
**Update Configuration:**
```json
{
"operation": "cache",
"sub_operation": "set-config",
"parameters": {
"cache_ttl": 7200,
"persistence_enabled": true
}
}
```
### Workflow 4: State Cleanup Between Tests
**Pattern for Clean Test State:**
```
1. cache (clear: "all") → Remove all cached data
2. device-lifecycle (erase) → Reset simulator state
3. app-lifecycle (uninstall) → Remove app
4. app-lifecycle (install) → Fresh install
5. app-lifecycle (launch) → Start with clean state
6. (run tests) → Execute test suite
7. cache (clear: "response") → Clean response cache
```
**Why This Matters:**
- Eliminates test interdependencies
- Prevents cache poisoning
- Ensures reproducible results
- Catches state-dependent bugs
## Progressive Disclosure Pattern
### Pattern Structure
**Level 1: Summary (Always Returned)**
```json
{
"summary": {
"key_metric_1": "value",
"key_metric_2": "value",
"action_taken": "description"
},
"cache_id": "unique-identifier",
"next_steps": [
"Suggested action 1",
"Suggested action 2"
]
}
```
**Level 2: Detailed Query (On-Demand)**
```json
{
"operation": "get-details",
"cache_id": "unique-identifier",
"detail_type": "full-data|errors-only|warnings-only|metadata"
}
```
### When to Use Progressive Disclosure
**Always Use For:**
- Device lists (>5 devices)
- Build logs (>100 lines)
- Test results (>10 tests)
- Accessibility trees (>20 elements)
- App lists (>10 apps)
**Skip For:**
- Single device operations
- Error messages
- Quick status checks
- Configuration queries
### Example: Test Results
**Summary Response:**
```json
{
"success": false,
"data": {
"tests_run": 45,
"tests_passed": 43,
"tests_failed": 2,
"failed_tests": [
"MyAppTests.LoginTests.testInvalidPassword",
"MyAppTests.LoginTests.testEmptyCredentials"
],
"cache_id": "test-run-def456"
}
}
```
**Full Details Query:**
```json
{
"operation": "get-details",
"cache_id": "test-run-def456",
"detail_type": "full-log"
}
```
**Token Efficiency:**
- Summary: ~200 tokens
- Full log: ~3000 tokens
- **Savings: 93% for typical success cases**
## Caching Strategies
### Cache-Friendly Operations
**High Cache Value (Long TTL):**
- `list` operations (device list changes infrequently)
- `version` operations (Xcode version is stable)
- `show-build-settings` (project config changes rarely)
**Moderate Cache Value (Medium TTL):**
- `build` operations (results valid until code changes)
- `test` operations (results valid until code/tests change)
- `describe` operations (UI state changes moderately)
**Low Cache Value (Short TTL):**
- `device-lifecycle` (device state changes frequently)
- `app-lifecycle` (app state is dynamic)
- `input/tap` operations (UI interactions modify state)
### Cache TTL Guidelines
```typescript
// Recommended TTL values
{
simulator_list: 1800, // 30 minutes
device_state: 60, // 1 minute
build_results: 3600, // 1 hour
test_results: 3600, // 1 hour
xcode_version: 86400, // 24 hours
project_schemes: 3600, // 1 hour
accessibility_tree: 10 // 10 seconds
}
```
### Cache Invalidation Triggers
**Automatic Invalidation:**
- TTL expiration
- Memory pressure (LRU eviction)
- Conflicting operation (e.g., `clean` Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.