skills/self-adaptive-systems/SKILL.md
Engineering methodology for building software systems that autonomously manage themselves through explicit architectural separation and formal guarantees
npx skillsauth add curiositech/windags-skills self-adaptive-systemsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Engineering methodology for building software systems that autonomously manage themselves through explicit architectural separation and formal guarantees.
| System Property | Choose Strategy | Implementation | |-----------------|----------------|----------------| | Single goal, predictable dynamics | Simple feedback control (PID-style) | Monitor → Calculate error → Proportional/Integral/Derivative response | | Multiple conflicting goals | Formal goal specifications with utility functions | Define weighted objectives → Multi-objective optimization → Synthesize controller | | >10 interacting components | Hierarchical feedback loops | Reactive (ms-s) → Deliberative (min-hr) → Reflective (days) layers | | High environmental uncertainty | Probabilistic models + runtime updates | Maintain confidence intervals → Detect model drift → Trigger re-identification | | Millisecond adaptation required | Pre-computed policy tables | Offline synthesis → Lookup-based execution → Background policy updates |
IF confidence > 90% AND drift < threshold
THEN incremental model update (recursive least squares)
ELSE IF abrupt change detected OR confidence < 50%
THEN trigger re-identification experiments
ELSE IF formal guarantees required
THEN use model checking on policies before deployment
ELSE
THEN fallback to conservative policy + alert operators
Does current system have scattered adaptation logic?
├─ YES → Extract to explicit managing/managed separation
│ └─ Can you draw clear boundary between domain logic and adaptation logic?
│ ├─ NO → Refactor with MAPE-K pattern first
│ └─ YES → Proceed with formal goal specification
└─ NO → Is this new system design?
└─ YES → Start with single feedback layer
└─ Expected to grow beyond 10 components?
├─ YES → Design hierarchical from start
└─ NO → Single layer, plan evolution path
Detection Rule: If system alternates between opposing states (scale up → scale down → scale up) with increasing frequency Symptom: Thrashing behavior, degrading performance despite "working" adaptation Root Cause: Controller gain too aggressive OR conflicting timescales in single layer Fix: Reduce proportional gain by 50%, add derivative term to dampen, OR separate into reactive/deliberative layers
Detection Rule: If adaptation confidence remains constant despite changing conditions OR no confidence tracking exists Symptom: Mysterious failures in production, adaptation working in test but not reality Root Cause: Models assume certainty, no drift detection, point estimates treated as truth Fix: Add probabilistic models with confidence intervals → Track model prediction accuracy → Trigger re-learning when confidence drops below threshold
Detection Rule: If team debates "is the adaptation working?" OR cannot define success criteria OR has conflicting informal goals Symptom: Endless tuning, stakeholder disagreements, no objective success metrics Root Cause: Informal goals ("fast and reliable") cannot drive automated decisions Fix: Formalize as executable specifications: P≥0.95[responseTime ≤ 200ms] AND cost ≤ $X/hour → Verify policies against formal goals before deployment
Detection Rule: If adaptation component has >1000 lines OR >20 configuration parameters OR debugging requires system-wide tracing Symptom: Adding adaptation features breaks existing ones, emergent behaviors, impossible to predict changes Root Cause: Forcing different timescales into single control loop Fix: Decompose into hierarchical layers: Reactive handles immediate responses, Deliberative optimizes patterns, Reflective evolves strategy
Detection Rule: If adaptation policies deployed based on intuition OR testing only happy path scenarios OR discovering issues only in production Symptom: "It worked in staging but failed in production", unpredictable behavior under load Root Cause: Adaptation space is exponential, manual testing insufficient Fix: Model check policies before deployment → Use statistical verification for probabilistic properties → Runtime monitoring of guarantee violations
Scenario: Online retailer needs adaptive resource management balancing response time (<200ms for 95% requests), availability (99.9% uptime), and cost (<$500/hour infrastructure).
Step 1: Architecture Decision
Step 2: Formal Goal Specification
Primary: P≥0.95[responseTime ≤ 200ms]
Secondary: availability ≥ 99.9%
Constraint: cost ≤ $500/hour
Step 3: Hierarchical Design
Step 4: Controller Synthesis
Deliberative layer models relationship: responseTime = f(activeServers, requestRate, cpuUtilization)
From experimental data: responseTime ≈ 50 + (requestRate/activeServers) * 0.8 + cpuNoise
Synthesize controller: targetServers = requestRate/targetThroughputPerServer + safetyMargin
Expert vs Novice Differences:
Result: System maintains goals under 3x traffic spikes, reduces cost 40% during low-traffic periods, provides formal guarantees on response time distribution.
Task complete when all conditions verified:
Do NOT use this skill for:
event-driven-architecture insteadresilient-system-design for simpler fault tolerancereal-time-systems insteadDelegate to other skills:
control-theory-for-softwareformal-methodssoftware-architecture-patternssystem-observabilitydata-ai
license: Apache-2.0 NOT for unrelated tasks outside this domain.
development
Use when designing caching strategies (cache-aside, write-through, write-behind), implementing distributed locks, building rate limiters, leaderboards, real-time streams (XADD/consumer groups), pub/sub, or tuning eviction policies. Triggers: thundering-herd on cache miss, dogpile on key expiry, Redlock vs SET-NX-PX choice, sliding-window rate limiter, hot-key on a single cluster slot, big-key blowup, MULTI/EXEC across slots, KEYS in production. NOT for Redis Cluster operations/admin (different domain), embedded KV (SQLite, leveldb), in-process LRU caches, or Memcached.
tools
Drawing the `'use client'` boundary correctly in React Server Components apps (Next.js App Router, RSC frameworks) — leaf-pushing, slot composition, serialization rules, and environment poisoning prevention. Grounded in react.dev and Next.js 16 docs.
development
Use when designing rate limiting for an API, choosing between token bucket / sliding window / leaky bucket / fixed window, implementing it in Redis, deciding edge (Cloudflare/Upstash) vs origin enforcement, sizing per-user vs per-IP vs per-endpoint quotas, returning the right 429 response with Retry-After, or fixing the boundary-burst bug in fixed-window limiters. Triggers: 429 too many requests, INCR + EXPIRE, ZADD + ZREMRANGEBYSCORE + ZCARD, X-RateLimit-Remaining header, Cloudflare WAF rate limiting rules, Upstash @upstash/ratelimit, leaky bucket shaping vs policing, distributed rate limiter consistency. NOT for DDoS mitigation specifically (different scale), CAPTCHA / bot management, full WAF design, or per-user quota billing.