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.
Inherits all available tools
Additional assets for this skill
This skill inherits all available tools. When active, it can use any tool Claude has access to.
Optimizing token efficiency and state management in xc-plugin
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:
Use this Skill when you need to:
Optimize Token Usage
Manage Cache State
Handle Configuration
Design Efficient Workflows
Principle: Show essentials first, provide details on-demand.
Instead of returning massive datasets that consume tokens, xc-plugin returns:
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)
The plugin uses deterministic caching for expensive operations:
Cache Key Generation:
cache_idCache Storage:
Cache-Friendly Operations:
list operations (device lists, app lists)build operations (build logs, test results)describe operations (accessibility trees)SuccessResult with Progressive Disclosure:
{
success: true,
data: {
summary: "31 devices available, 1 booted",
booted_devices: [...],
cache_id: "a1b2c3d4e5f6g7h8"
},
summary: "Device list retrieved successfully"
}
Follow-up Query Pattern:
{
operation: "get-details",
cache_id: "a1b2c3d4e5f6g7h8",
detail_type: "full-list"
}
Initial Query (Token-Efficient):
{
"operation": "list",
"parameters": {
"concise": true
}
}
Response:
{
"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):
{
"operation": "get-details",
"cache_id": "sim-list-xyz789",
"detail_type": "full-list"
}
Token Analysis:
Build Operation:
{
"operation": "build",
"scheme": "MyApp",
"configuration": "Debug",
"output_format": "summary"
}
Response with Cache:
{
"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:
{
"operation": "get-details",
"cache_id": "build-abc123",
"detail_type": "full-log"
}
Cache Invalidation Scenarios:
Query Current Configuration:
{
"operation": "cache",
"sub_operation": "get-config"
}
Response:
{
"cache_enabled": true,
"cache_ttl": 3600,
"max_cache_size": 100,
"persistence_enabled": false
}
Update Configuration:
{
"operation": "cache",
"sub_operation": "set-config",
"parameters": {
"cache_ttl": 7200,
"persistence_enabled": true
}
}
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:
Level 1: Summary (Always Returned)
{
"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)
{
"operation": "get-details",
"cache_id": "unique-identifier",
"detail_type": "full-data|errors-only|warnings-only|metadata"
}
Always Use For:
Skip For:
Summary Response:
{
"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:
{
"operation": "get-details",
"cache_id": "test-run-def456",
"detail_type": "full-log"
}
Token Efficiency:
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)// 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
}
Automatic Invalidation:
clean invalidates build cache)Manual Invalidation:
{
"operation": "cache",
"sub_operation": "clear",
"parameters": {
"cache_type": "simulator|project|response|all"
}
}
Smart Invalidation:
In-Memory Cache (Default):
Disk Cache (Optional):
Enable Disk Persistence:
{
"operation": "persistence",
"sub_operation": "enable",
"parameters": {
"cache_dir": "/tmp/xc-cache"
}
}
Query Build Settings:
{
"operation": "show-build-settings",
"scheme": "MyApp",
"configuration": "Debug"
}
Common Settings to Cache:
PRODUCT_BUNDLE_IDENTIFIERDEVELOPMENT_TEAMCODE_SIGN_IDENTITYSDKROOTARCHSUse Case:
Query Simulator Configuration:
{
"operation": "list",
"parameters": {
"runtime": "iOS 17.0",
"device_type": "iPhone"
}
}
Persist Simulator State:
Debug vs Release Configuration:
Debug:
{
"configuration": "Debug",
"options": {
"parallel": true,
"quiet": false
}
}
Release:
{
"configuration": "Release",
"options": {
"parallel": true,
"quiet": true
}
}
Set Test Environment:
{
"operation": "app-lifecycle",
"sub_operation": "launch",
"device_id": "iPhone 15",
"app_identifier": "com.example.MyApp",
"parameters": {
"environment": {
"API_URL": "https://staging.example.com",
"MOCK_DATA": "true",
"LOG_LEVEL": "debug"
}
}
}
Common Environment Variables:
API_URL - Backend endpointFEATURE_FLAGS - Enable/disable featuresTEST_MODE - Testing-specific behaviorLOG_LEVEL - Logging verbosityUse Progressive Disclosure:
// Good: Request summary first
{
"operation": "list",
"parameters": { "concise": true }
}
// Then query details only if needed
{
"operation": "get-details",
"cache_id": "sim-list-xyz"
}
Avoid Verbose Operations:
// Bad: Always verbose
{
"operation": "build",
"options": { "verbose": true }
}
// Good: Quiet by default, verbose on errors
{
"operation": "build",
"options": { "quiet": true }
}
Identify Expensive Operations:
build (20-120 seconds)test (10-300 seconds)list with large device sets (1-5 seconds)describe with complex UI (0.5-2 seconds)Cache Strategy:
// First call: Execute and cache
{
"operation": "list"
}
// Response includes cache_id
// Subsequent calls: Use cached data
{
"operation": "get-details",
"cache_id": "previous-cache-id"
}
Clean State Pattern:
1. Cache clear (all)
2. Simulator erase
3. App uninstall
4. Fresh app install
5. Launch with test environment
6. Run tests
7. Cache clear (response)
Why Each Step:
Detect Stale Cache:
// Check cache timestamp
if (cache_age > ttl) {
invalidateCache(cache_id);
refetch();
}
Recovery Strategy:
// If cache miss or stale:
{
"operation": "original-operation",
// Original parameters
}
// Plugin automatically refreshes cache
User Pattern:
Track Token Usage:
Summary responses: ~100-300 tokens
Full responses: ~1000-5000 tokens
Progressive disclosure savings: 80-95%
Optimization Checklist:
concise: true for list operationssummary output format for buildsquiet: true for non-debug buildsBuild Configuration:
{
"scheme": "MyApp",
"configurations": {
"debug": {
"configuration": "Debug",
"destination": "platform=iOS Simulator,name=iPhone 15",
"cache_strategy": "short_ttl",
"output_format": "summary"
},
"release": {
"configuration": "Release",
"destination": "generic/platform=iOS",
"cache_strategy": "long_ttl",
"output_format": "detailed"
}
}
}
Test Configuration:
{
"test_scheme": "MyAppTests",
"test_devices": [
"iPhone 15",
"iPad Pro (12.9-inch)"
],
"clean_state": true,
"cache_results": true,
"parallel_execution": false,
"environment": {
"TEST_MODE": "true",
"MOCK_NETWORK": "true"
}
}
Cache Configuration:
{
"cache": {
"enabled": true,
"ttl": {
"simulator_list": 1800,
"build_results": 3600,
"test_results": 3600,
"device_state": 60
},
"persistence": {
"enabled": true,
"path": "/tmp/xc-cache",
"max_size_mb": 500
},
"invalidation": {
"auto_invalidate_on_build": true,
"auto_invalidate_on_test": false
}
}
}
This Skill applies to all xc-plugin MCP tools:
Cache-Aware Tools:
xcodebuild-list - Returns cache_id for project dataxcodebuild-build - Returns cache_id for build logsxcodebuild-test - Returns cache_id for test resultssimctl-list - Returns cache_id for device listsidb-ui-describe - Returns cache_id for UI treesCache Management Tools:
xcodebuild-get-details - Query cached build datasimctl-get-details - Query cached simulator datacache - Manage cache configurationpersistence - Configure disk cachingxc://reference/cache-architecture - Cache implementation detailsxc://reference/token-optimization - Token efficiency guidexc://workflows/progressive-disclosure - Pattern documentationxc://reference/configuration - Configuration referenceRemember: Progressive disclosure first, full details only when needed. Cache expensive operations. Clear state between tests. 85-90% token savings are achievable with proper state management.