mindforge-cc 10.0.2 → 10.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.mindforge/config.json +73 -2
- package/.mindforge/engine/autonomous/cross-iteration-bridge.md +96 -0
- package/.mindforge/engine/cost-tracking/budget-enforcer.md +68 -0
- package/.mindforge/engine/cost-tracking/router.md +58 -0
- package/.mindforge/engine/cost-tracking/token-ledger.md +77 -0
- package/.mindforge/engine/council/council-protocol.md +96 -0
- package/.mindforge/engine/council/council-templates.md +85 -0
- package/.mindforge/engine/council/synthesis-engine.md +71 -0
- package/.mindforge/engine/cross-model-eval.md +74 -0
- package/.mindforge/engine/instincts/capture-engine.md +63 -0
- package/.mindforge/engine/instincts/instinct-schema.md +76 -0
- package/.mindforge/engine/instincts/promotion-engine.md +77 -0
- package/.mindforge/engine/proactive/signal-detector.md +60 -0
- package/.mindforge/engine/proactive/suggestion-engine.md +100 -0
- package/.mindforge/engine/skills/composition.md +83 -0
- package/.mindforge/engine/skills/loader.md +16 -0
- package/.mindforge/personas/agent-architect.md +57 -0
- package/.mindforge/personas/agent-evaluator.md +162 -0
- package/.mindforge/personas/agent-memory-designer.md +157 -0
- package/.mindforge/personas/agent-ops-engineer.md +120 -0
- package/.mindforge/personas/agent-orchestrator.md +112 -0
- package/.mindforge/personas/ai-economist.md +57 -0
- package/.mindforge/personas/ai-safety-engineer.md +57 -0
- package/.mindforge/personas/analytics-engineer.md +57 -0
- package/.mindforge/personas/anti-pattern-hunter.md +61 -0
- package/.mindforge/personas/api-gateway-designer.md +132 -0
- package/.mindforge/personas/auth-engineer.md +112 -0
- package/.mindforge/personas/build-engineer.md +57 -0
- package/.mindforge/personas/business-analyst.md +56 -0
- package/.mindforge/personas/cache-architect.md +100 -0
- package/.mindforge/personas/causal-scientist.md +57 -0
- package/.mindforge/personas/cdn-architect.md +118 -0
- package/.mindforge/personas/change-agent.md +104 -0
- package/.mindforge/personas/code-narrator.md +52 -0
- package/.mindforge/personas/codegen-specialist.md +68 -0
- package/.mindforge/personas/communication-architect.md +102 -0
- package/.mindforge/personas/compliance-engineer.md +96 -0
- package/.mindforge/personas/consensus-engineer.md +116 -0
- package/.mindforge/personas/contract-tester.md +60 -192
- package/.mindforge/personas/cost-optimizer.md +71 -0
- package/.mindforge/personas/council-architect.md +66 -0
- package/.mindforge/personas/council-critic.md +67 -0
- package/.mindforge/personas/council-pragmatist.md +71 -0
- package/.mindforge/personas/council-skeptic.md +73 -0
- package/.mindforge/personas/data-architect.md +108 -0
- package/.mindforge/personas/data-mesh-architect.md +57 -0
- package/.mindforge/personas/data-pipeline-architect.md +120 -0
- package/.mindforge/personas/de-sloppifier.md +60 -0
- package/.mindforge/personas/debt-manager.md +66 -0
- package/.mindforge/personas/decision-architect.md +82 -51
- package/.mindforge/personas/deployment-captain.md +74 -0
- package/.mindforge/personas/design-system-lead.md +112 -0
- package/.mindforge/personas/dmux-orchestrator.md +75 -0
- package/.mindforge/personas/doc-auditor.md +84 -0
- package/.mindforge/personas/dx-engineer.md +96 -0
- package/.mindforge/personas/ecommerce-engineer.md +57 -0
- package/.mindforge/personas/edge-engineer.md +94 -0
- package/.mindforge/personas/edtech-architect.md +106 -0
- package/.mindforge/personas/embedding-architect.md +57 -0
- package/.mindforge/personas/environment-engineer.md +57 -0
- package/.mindforge/personas/eval-judge.md +55 -0
- package/.mindforge/personas/event-architect.md +102 -0
- package/.mindforge/personas/experiment-designer.md +138 -0
- package/.mindforge/personas/feature-store-engineer.md +57 -0
- package/.mindforge/personas/finops-analyst.md +66 -0
- package/.mindforge/personas/fintech-architect.md +57 -0
- package/.mindforge/personas/flutter-engineer.md +104 -0
- package/.mindforge/personas/gaming-engineer.md +57 -0
- package/.mindforge/personas/graphql-designer.md +73 -0
- package/.mindforge/personas/healthcare-engineer.md +57 -0
- package/.mindforge/personas/hiring-strategist.md +105 -0
- package/.mindforge/personas/hitl-architect.md +165 -0
- package/.mindforge/personas/i18n-architect.md +69 -0
- package/.mindforge/personas/instinct-curator.md +83 -0
- package/.mindforge/personas/iot-architect.md +105 -0
- package/.mindforge/personas/knowledge-curator.md +139 -0
- package/.mindforge/personas/knowledge-engineer.md +57 -0
- package/.mindforge/personas/lakehouse-architect.md +57 -0
- package/.mindforge/personas/llm-orchestrator.md +57 -0
- package/.mindforge/personas/logistics-architect.md +106 -0
- package/.mindforge/personas/market-analyst.md +53 -0
- package/.mindforge/personas/marketplace-engineer.md +105 -0
- package/.mindforge/personas/mcp-designer.md +54 -0
- package/.mindforge/personas/meeting-designer.md +104 -0
- package/.mindforge/personas/mentorship-lead.md +106 -0
- package/.mindforge/personas/migration-architect.md +57 -0
- package/.mindforge/personas/ml-ops-engineer.md +101 -0
- package/.mindforge/personas/mobile-architect.md +105 -0
- package/.mindforge/personas/mobile-security-engineer.md +106 -0
- package/.mindforge/personas/multi-model-bridge.md +86 -0
- package/.mindforge/personas/multi-tenancy-architect.md +71 -0
- package/.mindforge/personas/multimodal-engineer.md +57 -0
- package/.mindforge/personas/offline-specialist.md +105 -0
- package/.mindforge/personas/onboarding-navigator.md +63 -0
- package/.mindforge/personas/payments-engineer.md +135 -0
- package/.mindforge/personas/pipeline-engineer.md +115 -0
- package/.mindforge/personas/platform-engineer.md +97 -0
- package/.mindforge/personas/platform-lead.md +57 -0
- package/.mindforge/personas/privacy-engineer.md +57 -0
- package/.mindforge/personas/product-owner.md +56 -0
- package/.mindforge/personas/productivity-analyst.md +57 -0
- package/.mindforge/personas/prompt-architect.md +101 -0
- package/.mindforge/personas/proofreader.md +53 -0
- package/.mindforge/personas/pwa-architect.md +105 -0
- package/.mindforge/personas/quality-scorer.md +63 -0
- package/.mindforge/personas/react-native-engineer.md +106 -0
- package/.mindforge/personas/resilience-engineer.md +69 -0
- package/.mindforge/personas/rfc-architect.md +64 -0
- package/.mindforge/personas/saga-orchestrator.md +80 -0
- package/.mindforge/personas/secrets-engineer.md +57 -0
- package/.mindforge/personas/skill-smith.md +79 -0
- package/.mindforge/personas/sre-lead.md +107 -0
- package/.mindforge/personas/stream-engineer.md +57 -0
- package/.mindforge/personas/streaming-engineer.md +64 -0
- package/.mindforge/personas/swarm-templates.json +695 -38
- package/.mindforge/personas/system-designer.md +57 -0
- package/.mindforge/personas/team-coach.md +120 -0
- package/.mindforge/personas/tech-lead-coach.md +103 -0
- package/.mindforge/personas/technical-writer-lead.md +111 -0
- package/.mindforge/personas/threat-modeler.md +82 -0
- package/.mindforge/personas/vibe-checker.md +75 -0
- package/.mindforge/personas/worktree-manager.md +56 -0
- package/.mindforge/personas/zero-trust-engineer.md +113 -0
- package/.mindforge/skills/a11y-testing/SKILL.md +143 -0
- package/.mindforge/skills/agent-evaluation-framework/SKILL.md +227 -0
- package/.mindforge/skills/agent-introspection-debugging/SKILL.md +88 -0
- package/.mindforge/skills/agent-loops/SKILL.md +84 -0
- package/.mindforge/skills/agent-memory-design/SKILL.md +199 -0
- package/.mindforge/skills/agent-orchestration-patterns/SKILL.md +129 -0
- package/.mindforge/skills/agent-tool-selection/SKILL.md +204 -0
- package/.mindforge/skills/ai-agent-deployment/SKILL.md +176 -0
- package/.mindforge/skills/ai-cost-management/SKILL.md +57 -0
- package/.mindforge/skills/ai-safety-alignment/SKILL.md +53 -0
- package/.mindforge/skills/analytics-instrumentation/SKILL.md +172 -0
- package/.mindforge/skills/api-gateway-patterns/SKILL.md +177 -0
- package/.mindforge/skills/api-marketplace/SKILL.md +56 -0
- package/.mindforge/skills/api-versioning/SKILL.md +100 -0
- package/.mindforge/skills/app-store-deployment/SKILL.md +44 -0
- package/.mindforge/skills/architecture-tradeoff-analysis/SKILL.md +97 -0
- package/.mindforge/skills/audit-logging/SKILL.md +140 -0
- package/.mindforge/skills/auth-patterns/SKILL.md +148 -0
- package/.mindforge/skills/autonomous-agent-harness/SKILL.md +218 -0
- package/.mindforge/skills/autonomous-agents/SKILL.md +59 -0
- package/.mindforge/skills/autonomous-loops/SKILL.md +105 -0
- package/.mindforge/skills/build-system-optimization/SKILL.md +54 -0
- package/.mindforge/skills/build-vs-buy/SKILL.md +80 -0
- package/.mindforge/skills/bundle-optimization/SKILL.md +174 -0
- package/.mindforge/skills/business-analyst/SKILL.md +82 -0
- package/.mindforge/skills/caching-strategies/SKILL.md +132 -0
- package/.mindforge/skills/capacity-planning/SKILL.md +96 -0
- package/.mindforge/skills/causal-inference/SKILL.md +42 -0
- package/.mindforge/skills/cdn-optimization/SKILL.md +212 -0
- package/.mindforge/skills/change-management/SKILL.md +106 -0
- package/.mindforge/skills/chaos-engineering/SKILL.md +99 -0
- package/.mindforge/skills/ci-cd-pipeline/SKILL.md +118 -0
- package/.mindforge/skills/cli-design/SKILL.md +118 -0
- package/.mindforge/skills/code-generation-patterns/SKILL.md +92 -0
- package/.mindforge/skills/code-review-methodology/SKILL.md +180 -0
- package/.mindforge/skills/code-tour/SKILL.md +145 -0
- package/.mindforge/skills/codebase-onboarding/SKILL.md +95 -0
- package/.mindforge/skills/compliance-as-code/SKILL.md +195 -0
- package/.mindforge/skills/conflict-resolution/SKILL.md +87 -0
- package/.mindforge/skills/connection-pooling/SKILL.md +151 -0
- package/.mindforge/skills/container-security/SKILL.md +151 -0
- package/.mindforge/skills/context-engineering/SKILL.md +114 -0
- package/.mindforge/skills/continuous-learning/SKILL.md +84 -0
- package/.mindforge/skills/contract-testing/SKILL.md +85 -0
- package/.mindforge/skills/cost-aware-routing/SKILL.md +83 -0
- package/.mindforge/skills/cost-estimation/SKILL.md +82 -0
- package/.mindforge/skills/council/SKILL.md +68 -0
- package/.mindforge/skills/cqrs-event-sourcing/SKILL.md +95 -0
- package/.mindforge/skills/cross-platform-testing/SKILL.md +43 -0
- package/.mindforge/skills/data-governance/SKILL.md +42 -0
- package/.mindforge/skills/data-lakehouse/SKILL.md +42 -0
- package/.mindforge/skills/data-mesh/SKILL.md +42 -0
- package/.mindforge/skills/data-modeling/SKILL.md +107 -0
- package/.mindforge/skills/data-pipeline-design/SKILL.md +171 -0
- package/.mindforge/skills/data-privacy-engineering/SKILL.md +42 -0
- package/.mindforge/skills/database-performance/SKILL.md +174 -0
- package/.mindforge/skills/database-sharding-advanced/SKILL.md +206 -0
- package/.mindforge/skills/de-sloppify/SKILL.md +120 -0
- package/.mindforge/skills/defense-in-depth/SKILL.md +84 -0
- package/.mindforge/skills/delegation-patterns/SKILL.md +123 -0
- package/.mindforge/skills/dependency-management/SKILL.md +94 -0
- package/.mindforge/skills/deployment-workflow/SKILL.md +135 -0
- package/.mindforge/skills/design-system/SKILL.md +113 -0
- package/.mindforge/skills/developer-onboarding/SKILL.md +99 -0
- package/.mindforge/skills/developer-productivity-metrics/SKILL.md +59 -0
- package/.mindforge/skills/distributed-consensus/SKILL.md +141 -0
- package/.mindforge/skills/dmux-workflows/SKILL.md +141 -0
- package/.mindforge/skills/dns-architecture/SKILL.md +167 -0
- package/.mindforge/skills/doc-health-audit/SKILL.md +102 -0
- package/.mindforge/skills/ecommerce-architecture/SKILL.md +41 -0
- package/.mindforge/skills/edge-computing/SKILL.md +91 -0
- package/.mindforge/skills/edtech-platform/SKILL.md +41 -0
- package/.mindforge/skills/email-deliverability/SKILL.md +177 -0
- package/.mindforge/skills/embedding-systems/SKILL.md +55 -0
- package/.mindforge/skills/environment-management/SKILL.md +54 -0
- package/.mindforge/skills/error-handling-architecture/SKILL.md +118 -0
- package/.mindforge/skills/estimation-techniques/SKILL.md +113 -0
- package/.mindforge/skills/eval-harness/SKILL.md +180 -0
- package/.mindforge/skills/event-driven-architecture/SKILL.md +162 -0
- package/.mindforge/skills/experiment-design/SKILL.md +139 -0
- package/.mindforge/skills/experiment-platform/SKILL.md +43 -0
- package/.mindforge/skills/feature-engineering/SKILL.md +42 -0
- package/.mindforge/skills/feature-flag-management/SKILL.md +183 -0
- package/.mindforge/skills/fine-tuning-workflow/SKILL.md +189 -0
- package/.mindforge/skills/fintech-patterns/SKILL.md +41 -0
- package/.mindforge/skills/flutter-architecture/SKILL.md +42 -0
- package/.mindforge/skills/gaming-backend/SKILL.md +41 -0
- package/.mindforge/skills/git-workflow-design/SKILL.md +129 -0
- package/.mindforge/skills/graceful-degradation/SKILL.md +95 -0
- package/.mindforge/skills/graphql-patterns/SKILL.md +243 -0
- package/.mindforge/skills/guardrails-and-safety/SKILL.md +137 -0
- package/.mindforge/skills/healthcare-systems/SKILL.md +40 -0
- package/.mindforge/skills/hiring-engineering/SKILL.md +119 -0
- package/.mindforge/skills/human-in-the-loop-design/SKILL.md +234 -0
- package/.mindforge/skills/i18n-architecture/SKILL.md +147 -0
- package/.mindforge/skills/idempotency-patterns/SKILL.md +84 -0
- package/.mindforge/skills/incident-communication/SKILL.md +96 -0
- package/.mindforge/skills/incident-management/SKILL.md +97 -0
- package/.mindforge/skills/infrastructure-as-code/SKILL.md +98 -0
- package/.mindforge/skills/instinct-clustering/SKILL.md +190 -0
- package/.mindforge/skills/internal-developer-platform/SKILL.md +51 -0
- package/.mindforge/skills/iot-platform/SKILL.md +41 -0
- package/.mindforge/skills/k8s-deployment/SKILL.md +358 -0
- package/.mindforge/skills/knowledge-graphs/SKILL.md +56 -0
- package/.mindforge/skills/knowledge-sharing-systems/SKILL.md +112 -0
- package/.mindforge/skills/llm-cost-optimization/SKILL.md +198 -0
- package/.mindforge/skills/llm-orchestration/SKILL.md +56 -0
- package/.mindforge/skills/load-testing/SKILL.md +84 -0
- package/.mindforge/skills/logistics-optimization/SKILL.md +40 -0
- package/.mindforge/skills/market-researcher/SKILL.md +99 -0
- package/.mindforge/skills/marketplace-trust/SKILL.md +40 -0
- package/.mindforge/skills/mcp-server-patterns/SKILL.md +264 -0
- package/.mindforge/skills/media-streaming/SKILL.md +41 -0
- package/.mindforge/skills/meeting-architecture/SKILL.md +146 -0
- package/.mindforge/skills/mentoring-patterns/SKILL.md +77 -0
- package/.mindforge/skills/microservices-patterns/SKILL.md +83 -0
- package/.mindforge/skills/migration-platform/SKILL.md +61 -0
- package/.mindforge/skills/migration-strategies/SKILL.md +129 -0
- package/.mindforge/skills/ml-feature-store/SKILL.md +56 -0
- package/.mindforge/skills/ml-monitoring/SKILL.md +42 -0
- package/.mindforge/skills/mobile-performance/SKILL.md +44 -0
- package/.mindforge/skills/mobile-security/SKILL.md +45 -0
- package/.mindforge/skills/model-evaluation/SKILL.md +53 -0
- package/.mindforge/skills/monorepo-management/SKILL.md +100 -0
- package/.mindforge/skills/multi-llm-consult/SKILL.md +75 -0
- package/.mindforge/skills/multi-tenancy-patterns/SKILL.md +145 -0
- package/.mindforge/skills/multi-turn-conversation-design/SKILL.md +206 -0
- package/.mindforge/skills/multimodal-ai/SKILL.md +51 -0
- package/.mindforge/skills/mutation-testing/SKILL.md +97 -0
- package/.mindforge/skills/notification-system-design/SKILL.md +168 -0
- package/.mindforge/skills/observability-stack/SKILL.md +136 -0
- package/.mindforge/skills/offline-first-design/SKILL.md +43 -0
- package/.mindforge/skills/on-call-design/SKILL.md +111 -0
- package/.mindforge/skills/pagination-patterns/SKILL.md +230 -0
- package/.mindforge/skills/payment-integration/SKILL.md +176 -0
- package/.mindforge/skills/performance-reviews/SKILL.md +140 -0
- package/.mindforge/skills/platform-observability/SKILL.md +58 -0
- package/.mindforge/skills/platform-reliability/SKILL.md +52 -0
- package/.mindforge/skills/post-incident-learning/SKILL.md +96 -0
- package/.mindforge/skills/product-manager/SKILL.md +104 -0
- package/.mindforge/skills/progressive-web-app/SKILL.md +44 -0
- package/.mindforge/skills/prompt-engineering/SKILL.md +94 -0
- package/.mindforge/skills/proofreader/SKILL.md +158 -0
- package/.mindforge/skills/push-notification-architecture/SKILL.md +45 -0
- package/.mindforge/skills/python-performance/SKILL.md +183 -0
- package/.mindforge/skills/quality-audit/SKILL.md +171 -0
- package/.mindforge/skills/queue-design/SKILL.md +85 -0
- package/.mindforge/skills/rag-architecture/SKILL.md +176 -0
- package/.mindforge/skills/rate-limiting-design/SKILL.md +94 -0
- package/.mindforge/skills/react-native-patterns/SKILL.md +42 -0
- package/.mindforge/skills/react-performance/SKILL.md +229 -0
- package/.mindforge/skills/real-time-analytics/SKILL.md +42 -0
- package/.mindforge/skills/real-time-sync/SKILL.md +83 -0
- package/.mindforge/skills/responsive-native/SKILL.md +44 -0
- package/.mindforge/skills/responsive-patterns/SKILL.md +141 -0
- package/.mindforge/skills/rfc-pipeline/SKILL.md +114 -0
- package/.mindforge/skills/saas-multi-tenant/SKILL.md +41 -0
- package/.mindforge/skills/santa-method/SKILL.md +134 -0
- package/.mindforge/skills/search-implementation/SKILL.md +98 -0
- package/.mindforge/skills/secrets-platform/SKILL.md +56 -0
- package/.mindforge/skills/secrets-rotation/SKILL.md +173 -0
- package/.mindforge/skills/self-serve-infrastructure/SKILL.md +51 -0
- package/.mindforge/skills/serverless-patterns/SKILL.md +119 -0
- package/.mindforge/skills/skill-creator-meta/SKILL.md +146 -0
- package/.mindforge/skills/sprint-retrospective-facilitation/SKILL.md +112 -0
- package/.mindforge/skills/stakeholder-communication/SKILL.md +85 -0
- package/.mindforge/skills/state-management/SKILL.md +104 -0
- package/.mindforge/skills/stream-processing/SKILL.md +43 -0
- package/.mindforge/skills/streaming-architecture/SKILL.md +81 -0
- package/.mindforge/skills/supply-chain-security/SKILL.md +145 -0
- package/.mindforge/skills/synthetic-data-generation/SKILL.md +52 -0
- package/.mindforge/skills/system-design/SKILL.md +88 -0
- package/.mindforge/skills/team-topology-design/SKILL.md +107 -0
- package/.mindforge/skills/technical-debt-management/SKILL.md +86 -0
- package/.mindforge/skills/technical-interview-design/SKILL.md +98 -0
- package/.mindforge/skills/technical-leadership/SKILL.md +75 -0
- package/.mindforge/skills/technical-writing/SKILL.md +237 -0
- package/.mindforge/skills/technology-radar/SKILL.md +88 -0
- package/.mindforge/skills/testing-anti-patterns/SKILL.md +288 -0
- package/.mindforge/skills/threat-modeling/SKILL.md +109 -0
- package/.mindforge/skills/tool-design/SKILL.md +138 -0
- package/.mindforge/skills/typescript-advanced/SKILL.md +198 -0
- package/.mindforge/skills/using-git-worktrees/SKILL.md +139 -0
- package/.mindforge/skills/verification-loop/SKILL.md +97 -0
- package/.mindforge/skills/vibe-security/SKILL.md +165 -0
- package/.mindforge/skills/visual-regression-testing/SKILL.md +97 -0
- package/.mindforge/skills/websocket-patterns/SKILL.md +203 -0
- package/.mindforge/skills/writing-plans/SKILL.md +170 -0
- package/.mindforge/skills/writing-skills/SKILL.md +216 -0
- package/.mindforge/skills/zero-trust-architecture/SKILL.md +166 -0
- package/CHANGELOG.md +195 -0
- package/MINDFORGE.md +4 -4
- package/README.md +2 -2
- package/RELEASENOTES.md +66 -0
- package/bin/installer-core.js +1 -1
- package/bin/wizard/theme.js +2 -2
- package/docs/commands-reference.md +18 -1
- package/package.json +2 -2
- package/.mindforge/personas/data-privacy-engineer.md +0 -187
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: observability-stack
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 10.0.7
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: observability stack, structured logging, distributed tracing, OpenTelemetry setup, RED method metrics, USE method metrics, alerting threshold design, dashboard design, correlation ID, metrics collection strategy, log aggregation, trace context propagation
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Observability Stack
|
|
10
|
+
|
|
11
|
+
## When this skill activates
|
|
12
|
+
|
|
13
|
+
This skill activates when designing, implementing, or reviewing observability infrastructure for production systems. It covers the three pillars (logs, traces, metrics), alerting strategy, dashboard design, and correlation techniques. Use this skill whenever you need to ensure a system can be understood, debugged, and monitored in production.
|
|
14
|
+
|
|
15
|
+
## Mandatory actions when this skill is active
|
|
16
|
+
|
|
17
|
+
### Before
|
|
18
|
+
|
|
19
|
+
1. **Identify observability goals** — What questions must you answer? "Why is this request slow?" (traces), "What's the error rate?" (metrics), "What happened at 3:42am?" (logs).
|
|
20
|
+
2. **Assess current state** — What instrumentation exists? What gaps cause blind spots? Never add observability without understanding what's already there.
|
|
21
|
+
3. **Define SLIs/SLOs** — Service Level Indicators (what to measure) and Service Level Objectives (acceptable thresholds) must exist before alerting makes sense.
|
|
22
|
+
4. **Choose the stack** — Select instrumentation (OpenTelemetry), storage (Prometheus/Loki/Tempo, Datadog, Grafana Cloud), and visualization (Grafana, Datadog) based on team expertise and budget.
|
|
23
|
+
|
|
24
|
+
### During
|
|
25
|
+
|
|
26
|
+
#### Pillar 1: Structured Logging
|
|
27
|
+
|
|
28
|
+
**Format** — Always structured JSON with fields: timestamp, level, message, service, trace_id, span_id, correlation_id, error_code, duration_ms, metadata.
|
|
29
|
+
|
|
30
|
+
**Severity levels:**
|
|
31
|
+
- `DEBUG` — Development-only detail. Never enable in production by default.
|
|
32
|
+
- `INFO` — Normal operations: request received, task completed, state transitions.
|
|
33
|
+
- `WARN` — Degraded but functional: retry succeeded, fallback activated, approaching limit.
|
|
34
|
+
- `ERROR` — Operation failed: request could not be fulfilled, exception caught.
|
|
35
|
+
- `FATAL` — System cannot continue: startup failure, unrecoverable state, crash.
|
|
36
|
+
|
|
37
|
+
**Correlation IDs:**
|
|
38
|
+
- Generate at the edge (API gateway). Propagate via `X-Correlation-ID` header through all services.
|
|
39
|
+
- Include in every log line. Distinct from trace_id but can be linked.
|
|
40
|
+
|
|
41
|
+
**Logging rules:**
|
|
42
|
+
- Log at service boundaries (incoming requests, outgoing calls).
|
|
43
|
+
- Log state transitions (order created, payment confirmed, email sent).
|
|
44
|
+
- Log errors with full context (what was attempted, what failed, what the input was).
|
|
45
|
+
- NEVER log secrets, tokens, passwords, or full credit card numbers.
|
|
46
|
+
- NEVER log PII without a documented legal basis and redaction strategy.
|
|
47
|
+
|
|
48
|
+
#### Pillar 2: Distributed Tracing
|
|
49
|
+
|
|
50
|
+
**Span design:**
|
|
51
|
+
- Create spans for: HTTP requests (in/out), database queries, cache operations, external API calls, queue publish/consume, significant business logic.
|
|
52
|
+
- DO NOT span: trivial operations, tight loops, in-memory calculations.
|
|
53
|
+
- Name spans with: `verb.noun` format: `process.payment`, `query.users`, `send.email`.
|
|
54
|
+
|
|
55
|
+
**Context propagation:**
|
|
56
|
+
- Use W3C Trace Context standard (`traceparent` header) for cross-service propagation.
|
|
57
|
+
- Ensure all HTTP clients and message queues propagate context automatically.
|
|
58
|
+
- Test propagation: a trace should span from the edge to the deepest downstream call.
|
|
59
|
+
|
|
60
|
+
**Sampling strategy:**
|
|
61
|
+
- 100% sampling in development and staging.
|
|
62
|
+
- Production: tail-based sampling (keep all errors + slow requests + 1-10% of normal traffic).
|
|
63
|
+
- Never sample at 100% in high-traffic production. Storage costs scale linearly.
|
|
64
|
+
- Always keep traces for errors regardless of sampling rate.
|
|
65
|
+
|
|
66
|
+
#### Pillar 3: Metrics
|
|
67
|
+
|
|
68
|
+
**RED Method (for services/endpoints):**
|
|
69
|
+
- **Rate** — Requests per second. Indicates load.
|
|
70
|
+
- **Errors** — Failed requests per second (and error rate as %). Indicates reliability.
|
|
71
|
+
- **Duration** — Latency distribution (p50, p95, p99). Indicates performance.
|
|
72
|
+
|
|
73
|
+
**USE Method (for resources: CPU, memory, disk, network):**
|
|
74
|
+
- **Utilization** — Percentage of resource capacity in use.
|
|
75
|
+
- **Saturation** — Work queued waiting for the resource.
|
|
76
|
+
- **Errors** — Resource-level errors (disk I/O errors, network drops).
|
|
77
|
+
|
|
78
|
+
**Metric types:**
|
|
79
|
+
- **Counter** — Monotonically increasing value. Use for: total requests, errors, bytes transferred.
|
|
80
|
+
- **Gauge** — Point-in-time value that can go up/down. Use for: active connections, queue depth, temperature.
|
|
81
|
+
- **Histogram** — Distribution of values. Use for: request latency, payload sizes.
|
|
82
|
+
|
|
83
|
+
**Naming convention:** `<service>_<component>_<metric>_<unit>` (e.g., `payment_api_request_duration_seconds`).
|
|
84
|
+
|
|
85
|
+
**Cardinality discipline:**
|
|
86
|
+
- Never use unbounded values as label/tag keys (user IDs, request IDs, timestamps).
|
|
87
|
+
- Maximum 10-20 unique values per label. High cardinality kills metric storage.
|
|
88
|
+
- Safe labels: HTTP method, status code, endpoint path (grouped), environment, region.
|
|
89
|
+
|
|
90
|
+
#### Alerting Design
|
|
91
|
+
|
|
92
|
+
**Principles:**
|
|
93
|
+
- Alert on symptoms (user impact), not causes (CPU spike). Users don't care about CPU; they care about latency.
|
|
94
|
+
- Every alert must be actionable. If no one can do anything about it at 3am, it should not page.
|
|
95
|
+
- Use SLO-based alerting: alert when the error budget burn rate exceeds safe levels.
|
|
96
|
+
|
|
97
|
+
**Threshold design:**
|
|
98
|
+
- Static thresholds: set at baseline + 2 standard deviations (for stable metrics).
|
|
99
|
+
- Anomaly detection: use ML-based for metrics with seasonal patterns (traffic).
|
|
100
|
+
- Burn rate: alert when 1-hour burn rate > 14x (consumes 24hr budget in 1hr).
|
|
101
|
+
|
|
102
|
+
**Alert severity:**
|
|
103
|
+
- **Critical (page)** — User-facing impact right now. Revenue loss. Data loss.
|
|
104
|
+
- **Warning (ticket)** — Degraded performance. Will become critical if unaddressed. Handle next business day.
|
|
105
|
+
- **Info (log)** — Notable but not impactful. For awareness only.
|
|
106
|
+
|
|
107
|
+
**Anti-patterns:**
|
|
108
|
+
- Alert fatigue: >5 alerts/day/team = too many. Tune or eliminate.
|
|
109
|
+
- Flapping alerts: add hysteresis (alert fires at threshold, clears at threshold - 10%).
|
|
110
|
+
- Duplicate alerts: one incident should fire one alert, not one per symptom.
|
|
111
|
+
|
|
112
|
+
#### Dashboard Design
|
|
113
|
+
|
|
114
|
+
**Layout:** Row 1: Traffic, Error rate, Latency (p50/p95/p99). Row 2: Saturation (CPU, memory, connections), Active alerts. Row 3: Deployment markers, SLO burn-down.
|
|
115
|
+
|
|
116
|
+
**Principles:** Top = current health (red/yellow/green). Middle = golden signal time-series. Bottom = drill-down investigation panels. NO vanity metrics. Consistent time ranges, default 1 hour.
|
|
117
|
+
|
|
118
|
+
### After
|
|
119
|
+
|
|
120
|
+
1. **Verify correlation** — Generate a test request and verify it can be traced from edge to database across all services via correlation ID and trace ID.
|
|
121
|
+
2. **Validate alerting** — Trigger each alert condition deliberately. Verify it fires, routes correctly, and auto-resolves.
|
|
122
|
+
3. **Load test observability** — Ensure the observability stack itself handles production load without becoming a bottleneck.
|
|
123
|
+
4. **Document runbooks** — Every alert needs a runbook: what it means, how to diagnose, how to mitigate.
|
|
124
|
+
|
|
125
|
+
## Self-check before task completion
|
|
126
|
+
|
|
127
|
+
- [ ] All logs are structured JSON with correlation IDs, timestamps, and severity levels
|
|
128
|
+
- [ ] Distributed traces span from edge to deepest downstream call with proper context propagation
|
|
129
|
+
- [ ] RED metrics (Rate, Errors, Duration) are collected for every service endpoint
|
|
130
|
+
- [ ] USE metrics (Utilization, Saturation, Errors) are collected for critical resources
|
|
131
|
+
- [ ] Metric label cardinality is bounded (no unbounded labels like user IDs)
|
|
132
|
+
- [ ] Alerts are symptom-based, actionable, and severity-appropriate
|
|
133
|
+
- [ ] Dashboard shows golden signals with drill-down capability
|
|
134
|
+
- [ ] No secrets or unbounded PII appear in logs
|
|
135
|
+
- [ ] Sampling strategy is defined for production tracing
|
|
136
|
+
- [ ] Runbooks exist for every critical alert
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: offline-first-design
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 10.4.0
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: offline-first architecture, conflict resolution sync, sync protocol design, local-first data, CRDT implementation, offline data persistence, background sync, offline queue pattern, network reconnection handling, eventual consistency mobile, offline cache strategy, optimistic offline update
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
# Skill — Offline-First Design & Sync Architecture
|
|
10
|
+
|
|
11
|
+
## When this skill activates
|
|
12
|
+
This skill activates when designing offline-capable mobile or web applications, including conflict resolution strategies, sync protocols, local-first data patterns, or CRDT-based collaborative features.
|
|
13
|
+
|
|
14
|
+
## Mandatory actions when this skill is active
|
|
15
|
+
|
|
16
|
+
### Before writing any code
|
|
17
|
+
1. Define conflict resolution strategy (last-write-wins, CRDT, operational transformation, or custom merge logic)
|
|
18
|
+
2. Choose local storage solution appropriate for data volume and query patterns (SQLite, Realm, WatermelonDB, IndexedDB)
|
|
19
|
+
3. Design sync protocol with idempotency, versioning, and resumable transfers for unreliable networks
|
|
20
|
+
4. Establish data model with conflict-free properties where possible (append-only logs, tombstone deletions)
|
|
21
|
+
|
|
22
|
+
### During implementation
|
|
23
|
+
- Implement optimistic UI updates with rollback capability — show immediate feedback, reconcile on sync
|
|
24
|
+
- Use operation queues with exponential backoff for failed network requests, persist queue to survive app restarts
|
|
25
|
+
- Store vector clocks, lamport timestamps, or hybrid logical clocks to track causality across devices
|
|
26
|
+
- Implement delta sync to minimize bandwidth — send only changed fields, not entire documents
|
|
27
|
+
- Handle edge cases: simultaneous edits on multiple devices, partial sync failures, stale read after write
|
|
28
|
+
- Use CRDTs (Automerge, Yjs, or custom implementations) for collaborative editing with automatic conflict resolution
|
|
29
|
+
- Implement sync status indicators and manual sync triggers for user transparency
|
|
30
|
+
|
|
31
|
+
### After implementation
|
|
32
|
+
- Test offline scenarios exhaustively: airplane mode, flaky networks, background app termination during sync
|
|
33
|
+
- Simulate conflict scenarios with multiple devices editing same data simultaneously
|
|
34
|
+
- Verify data integrity after sync — no duplicate records, no lost updates, correct conflict resolution
|
|
35
|
+
- Measure sync performance: time to sync after reconnection, battery impact, bandwidth usage
|
|
36
|
+
|
|
37
|
+
## Self-check before task completion
|
|
38
|
+
- [ ] App remains functional offline with clear UI indication of sync status
|
|
39
|
+
- [ ] Conflicts are resolved correctly according to business rules, with audit trail if needed
|
|
40
|
+
- [ ] Sync protocol is idempotent — replaying operations produces same result
|
|
41
|
+
- [ ] Local data persists correctly across app restarts and OS updates
|
|
42
|
+
- [ ] Background sync works within platform constraints (iOS background fetch, Android WorkManager)
|
|
43
|
+
- [ ] Edge cases handled: clock skew, partial sync, corrupted local data, schema migrations during offline period
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: on-call-design
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 10.1.0
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: on-call design, rotation fairness, escalation SLA, runbook coverage, toil budget, on-call compensation, burnout prevention, page frequency, on-call rotation schedule, alert fatigue, on-call handbook, incident response time
|
|
7
|
+
compose: incident-management
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# On-Call Design
|
|
11
|
+
|
|
12
|
+
## When this skill activates
|
|
13
|
+
|
|
14
|
+
This skill activates when designing, evaluating, or improving on-call rotations,
|
|
15
|
+
escalation policies, alerting strategies, and the operational sustainability of
|
|
16
|
+
incident response. It addresses rotation fairness, alert fatigue prevention,
|
|
17
|
+
runbook coverage, and burnout prevention to create a humane and effective on-call
|
|
18
|
+
system.
|
|
19
|
+
|
|
20
|
+
## Mandatory actions when this skill is active
|
|
21
|
+
|
|
22
|
+
### Before
|
|
23
|
+
|
|
24
|
+
1. **Audit current state** — How many pages per week per person? What percentage have
|
|
25
|
+
runbooks? What is the false-positive rate? How is on-call currently compensated?
|
|
26
|
+
2. **Identify pain points** — Survey on-call participants: What is most frustrating?
|
|
27
|
+
What causes the most stress? What pages feel unnecessary?
|
|
28
|
+
3. **Define service level objectives** — What response times does the business actually
|
|
29
|
+
need? Not everything requires a 2 AM page.
|
|
30
|
+
|
|
31
|
+
### During
|
|
32
|
+
|
|
33
|
+
4. **Rotation design principles:**
|
|
34
|
+
- Minimum 2 people in rotation at all times (primary + secondary)
|
|
35
|
+
- Maximum 1 week per rotation (longer causes burnout)
|
|
36
|
+
- Follow-the-sun for global teams (no one gets paged at 3 AM regularly)
|
|
37
|
+
- Handoff includes: active incidents, known issues, upcoming risky changes
|
|
38
|
+
- New team members shadow for 2 rotations before going primary
|
|
39
|
+
- Easy swap mechanism for personal conflicts
|
|
40
|
+
|
|
41
|
+
5. **Fairness and compensation:**
|
|
42
|
+
- Equal distribution of on-call burden across all eligible engineers
|
|
43
|
+
- Track after-hours pages per person — redistribute if imbalanced
|
|
44
|
+
- Compensate on-call time (stipend for carrying the pager, additional compensation
|
|
45
|
+
for after-hours pages)
|
|
46
|
+
- Swap-friendly policy — no guilt for requesting swaps
|
|
47
|
+
- On-call load counts toward sprint capacity (reduce story points by 20-30%)
|
|
48
|
+
- Never mandate on-call for people who did not agree to it at hiring
|
|
49
|
+
|
|
50
|
+
6. **Escalation SLAs:**
|
|
51
|
+
- **Acknowledge** — 5 minutes (confirm human is aware)
|
|
52
|
+
- **Triage** — 15 minutes (assess severity, determine if action needed now)
|
|
53
|
+
- **Resolve or escalate** — 60 minutes (either fix it or pull in help)
|
|
54
|
+
- Clear escalation path: primary → secondary → team lead → engineering manager
|
|
55
|
+
- Automatic escalation if acknowledgment SLA is missed
|
|
56
|
+
- No shame in escalating — better to involve help early than struggle alone
|
|
57
|
+
|
|
58
|
+
7. **Runbook coverage requirements:**
|
|
59
|
+
- Every alert MUST have a corresponding runbook
|
|
60
|
+
- Runbook contains: what the alert means, impact if ignored, diagnostic steps,
|
|
61
|
+
resolution steps, escalation criteria
|
|
62
|
+
- If no runbook exists for an alert, the alert should not page — it is toil
|
|
63
|
+
- Runbooks must be tested quarterly (can a new engineer follow them successfully?)
|
|
64
|
+
- Runbook updates are mandatory after any incident where the runbook was insufficient
|
|
65
|
+
|
|
66
|
+
8. **Toil budget management:**
|
|
67
|
+
- Define toil: repetitive, automatable, reactive work with no lasting value
|
|
68
|
+
- If >30% of on-call time is toil, invest in automation
|
|
69
|
+
- Track toil hours separately from incident response hours
|
|
70
|
+
- Dedicate engineering time each sprint to reducing top toil sources
|
|
71
|
+
- Toil that persists for >3 months without investment is a leadership failure
|
|
72
|
+
|
|
73
|
+
9. **Alert fatigue prevention:**
|
|
74
|
+
- If an alert does not require human action within 5 minutes, delete it
|
|
75
|
+
- Target: fewer than 5 pages per week per person
|
|
76
|
+
- Review all alerts quarterly: keep, tune, or delete
|
|
77
|
+
- Silence non-actionable alerts aggressively (log them, don't page for them)
|
|
78
|
+
- Group related alerts to prevent page storms (one page for a cascading failure,
|
|
79
|
+
not 50)
|
|
80
|
+
- Every page that did not need human intervention is a bug in your alerting
|
|
81
|
+
|
|
82
|
+
10. **Burnout prevention:**
|
|
83
|
+
- Monitor page frequency trends — rising trends require immediate action
|
|
84
|
+
- After a high-severity incident with extended resolution, give the responder
|
|
85
|
+
compensatory time off
|
|
86
|
+
- Regular check-ins on on-call stress (not just "how many pages" but "how do you
|
|
87
|
+
feel about on-call?")
|
|
88
|
+
- Option to temporarily step out of rotation for personal reasons without stigma
|
|
89
|
+
- Celebrate good on-call: quiet weeks are victories, not luck
|
|
90
|
+
|
|
91
|
+
### After
|
|
92
|
+
|
|
93
|
+
11. **Publish on-call handbook** — Document all policies, rotations, escalation paths,
|
|
94
|
+
compensation, and expectations in one discoverable location.
|
|
95
|
+
12. **Review quarterly** — Analyze page frequency, response times, toil percentage,
|
|
96
|
+
fairness distribution, and team satisfaction.
|
|
97
|
+
13. **Iterate on alerts** — After every on-call rotation, the outgoing person reviews
|
|
98
|
+
alerts received and recommends: keep as-is, tune threshold, add runbook, or delete.
|
|
99
|
+
|
|
100
|
+
## Self-check before task completion
|
|
101
|
+
|
|
102
|
+
- [ ] Rotation has minimum 2 people with maximum 1-week shifts
|
|
103
|
+
- [ ] Compensation model defined for on-call time and after-hours pages
|
|
104
|
+
- [ ] Escalation SLAs documented (acknowledge: 5min, triage: 15min, resolve: 60min)
|
|
105
|
+
- [ ] Every alert has a corresponding runbook (or is deleted/silenced)
|
|
106
|
+
- [ ] Page frequency target set (<5/week/person) with current baseline measured
|
|
107
|
+
- [ ] Toil budget defined (<30%) with automation investment plan for top sources
|
|
108
|
+
- [ ] Alert review cadence established (quarterly minimum)
|
|
109
|
+
- [ ] Burnout prevention measures in place (comp time, swap policy, check-ins)
|
|
110
|
+
- [ ] On-call handbook published and discoverable
|
|
111
|
+
- [ ] Fairness tracking mechanism active (pages per person distribution)
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: pagination-patterns
|
|
3
|
+
version: 1.0.0
|
|
4
|
+
min_mindforge_version: 0.3.0
|
|
5
|
+
status: stable
|
|
6
|
+
triggers: pagination pattern, cursor pagination, offset pagination, keyset pagination, total count strategy, infinite scroll, deep pagination, page token, relay connection, pagination performance, next page token, pagination API design
|
|
7
|
+
compose: api-design
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Skill — Pagination Patterns
|
|
11
|
+
|
|
12
|
+
## When this skill activates
|
|
13
|
+
Any task involving list endpoint pagination, cursor vs offset strategies, infinite
|
|
14
|
+
scroll implementation, total count optimization, or pagination API design.
|
|
15
|
+
|
|
16
|
+
## Mandatory actions when this skill is active
|
|
17
|
+
|
|
18
|
+
### Before implementing pagination
|
|
19
|
+
1. Determine the access pattern (jump to page N vs sequential browsing).
|
|
20
|
+
2. Assess data volume and write frequency (affects consistency).
|
|
21
|
+
3. Choose the strategy based on trade-offs, not convention.
|
|
22
|
+
|
|
23
|
+
### Offset pagination
|
|
24
|
+
|
|
25
|
+
**Implementation:**
|
|
26
|
+
```sql
|
|
27
|
+
SELECT * FROM orders
|
|
28
|
+
WHERE tenant_id = 'abc'
|
|
29
|
+
ORDER BY created_at DESC
|
|
30
|
+
LIMIT 20 OFFSET 40; -- page 3
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**API design:**
|
|
34
|
+
```json
|
|
35
|
+
GET /orders?page=3&per_page=20
|
|
36
|
+
|
|
37
|
+
{
|
|
38
|
+
"data": [...],
|
|
39
|
+
"meta": {
|
|
40
|
+
"page": 3,
|
|
41
|
+
"per_page": 20,
|
|
42
|
+
"total": 1542,
|
|
43
|
+
"total_pages": 78
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
**Pros:**
|
|
49
|
+
- Simple to implement and understand.
|
|
50
|
+
- Allows jumping to any page directly.
|
|
51
|
+
- Total count and page numbers are intuitive for users.
|
|
52
|
+
|
|
53
|
+
**Cons:**
|
|
54
|
+
- Performance degrades on deep pages (OFFSET 10000 still scans 10000 rows).
|
|
55
|
+
- Inconsistent during writes (rows shift between pages as new data is inserted).
|
|
56
|
+
- Total count is expensive on large tables (separate COUNT query).
|
|
57
|
+
|
|
58
|
+
**Best for:** admin panels, back-office UIs, small datasets (< 100K rows).
|
|
59
|
+
|
|
60
|
+
### Cursor/Keyset pagination
|
|
61
|
+
|
|
62
|
+
**Implementation:**
|
|
63
|
+
```sql
|
|
64
|
+
-- First page
|
|
65
|
+
SELECT * FROM orders
|
|
66
|
+
WHERE tenant_id = 'abc'
|
|
67
|
+
ORDER BY created_at DESC, id DESC
|
|
68
|
+
LIMIT 20;
|
|
69
|
+
|
|
70
|
+
-- Next page (cursor = last seen created_at + id)
|
|
71
|
+
SELECT * FROM orders
|
|
72
|
+
WHERE tenant_id = 'abc'
|
|
73
|
+
AND (created_at, id) < ('2025-01-15T10:00:00Z', 'order-xyz')
|
|
74
|
+
ORDER BY created_at DESC, id DESC
|
|
75
|
+
LIMIT 20;
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**API design:**
|
|
79
|
+
```json
|
|
80
|
+
GET /orders?limit=20&after=eyJjcmVhdGVkX2F0IjoiMjAyNS0wMS0xNVQxMDowMDowMFoiLCJpZCI6Im9yZGVyLXh5eiJ9
|
|
81
|
+
|
|
82
|
+
{
|
|
83
|
+
"data": [...],
|
|
84
|
+
"meta": {
|
|
85
|
+
"has_next": true,
|
|
86
|
+
"next_cursor": "eyJjcmVhdGVkX...",
|
|
87
|
+
"has_previous": true,
|
|
88
|
+
"previous_cursor": "eyJjcmVhdGVk..."
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
**Pros:**
|
|
94
|
+
- Constant performance regardless of depth (no OFFSET scan).
|
|
95
|
+
- Consistent results during writes (no row shifting).
|
|
96
|
+
- Works well at any scale.
|
|
97
|
+
|
|
98
|
+
**Cons:**
|
|
99
|
+
- Cannot jump to arbitrary page N.
|
|
100
|
+
- Cursor is opaque — clients cannot construct cursors manually.
|
|
101
|
+
- Requires a unique, sequential ordering key (composite if not unique).
|
|
102
|
+
|
|
103
|
+
**Best for:** feeds, timelines, infinite scroll, large datasets, real-time data.
|
|
104
|
+
|
|
105
|
+
### Cursor encoding
|
|
106
|
+
|
|
107
|
+
**Rules:**
|
|
108
|
+
- Cursor is opaque to the client (base64-encode the actual values).
|
|
109
|
+
- Include all ORDER BY columns in the cursor (for deterministic positioning).
|
|
110
|
+
- Add a tiebreaker (id) when the sort column is not unique.
|
|
111
|
+
- Validate cursors server-side (prevent injection via crafted cursors).
|
|
112
|
+
|
|
113
|
+
**Example encoding:**
|
|
114
|
+
```javascript
|
|
115
|
+
// Encode
|
|
116
|
+
const cursor = Buffer.from(JSON.stringify({
|
|
117
|
+
created_at: lastItem.createdAt,
|
|
118
|
+
id: lastItem.id
|
|
119
|
+
})).toString('base64url');
|
|
120
|
+
|
|
121
|
+
// Decode
|
|
122
|
+
const { created_at, id } = JSON.parse(Buffer.from(cursor, 'base64url').toString());
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Relay Connection specification
|
|
126
|
+
|
|
127
|
+
```graphql
|
|
128
|
+
type OrderConnection {
|
|
129
|
+
edges: [OrderEdge!]!
|
|
130
|
+
pageInfo: PageInfo!
|
|
131
|
+
totalCount: Int # nullable — expensive to compute
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
type OrderEdge {
|
|
135
|
+
node: Order!
|
|
136
|
+
cursor: String!
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
type PageInfo {
|
|
140
|
+
hasNextPage: Boolean!
|
|
141
|
+
hasPreviousPage: Boolean!
|
|
142
|
+
startCursor: String
|
|
143
|
+
endCursor: String
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Usage:**
|
|
148
|
+
- `first: 20, after: "cursor"` — forward pagination.
|
|
149
|
+
- `last: 20, before: "cursor"` — backward pagination.
|
|
150
|
+
- Standardized across the entire GraphQL schema.
|
|
151
|
+
|
|
152
|
+
### Total count strategies
|
|
153
|
+
|
|
154
|
+
**Problem:** `SELECT COUNT(*) FROM large_table` is slow (full table scan in PostgreSQL).
|
|
155
|
+
|
|
156
|
+
**Solutions:**
|
|
157
|
+
|
|
158
|
+
| Strategy | Accuracy | Performance | Use case |
|
|
159
|
+
|----------|----------|-------------|----------|
|
|
160
|
+
| Exact count (separate query) | 100% | Slow (large tables) | Admin UIs, small datasets |
|
|
161
|
+
| Estimated count (`pg_stat_user_tables.reltuples`) | ~95% | Instant | "About X results" display |
|
|
162
|
+
| Count with cap (`COUNT(*) ... LIMIT 1001`) | Exact up to cap | Fast | "1000+ results" |
|
|
163
|
+
| Cached count (materialized/Redis) | Stale by TTL | Instant | Dashboards, frequently queried |
|
|
164
|
+
| No count (cursor only) | N/A | N/A | Infinite scroll, feeds |
|
|
165
|
+
|
|
166
|
+
**Recommendation:** Make totalCount optional in the API. Let clients request it only when needed.
|
|
167
|
+
|
|
168
|
+
### Infinite scroll implementation
|
|
169
|
+
|
|
170
|
+
**Frontend pattern:**
|
|
171
|
+
```javascript
|
|
172
|
+
function useInfiniteList(fetchPage) {
|
|
173
|
+
const [pages, setPages] = useState([]);
|
|
174
|
+
const [cursor, setCursor] = useState(null);
|
|
175
|
+
const [hasMore, setHasMore] = useState(true);
|
|
176
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
177
|
+
|
|
178
|
+
const loadMore = async () => {
|
|
179
|
+
if (isLoading || !hasMore) return;
|
|
180
|
+
setIsLoading(true);
|
|
181
|
+
const result = await fetchPage(cursor);
|
|
182
|
+
setPages(prev => [...prev, result.data]);
|
|
183
|
+
setCursor(result.nextCursor);
|
|
184
|
+
setHasMore(result.hasNext);
|
|
185
|
+
setIsLoading(false);
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
// Trigger loadMore on scroll near bottom
|
|
189
|
+
// Virtualize rendered list for performance
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
**Rules:**
|
|
194
|
+
- Use cursor-based pagination (offset causes duplicates on insert).
|
|
195
|
+
- Prefetch next page when user is near the bottom (IntersectionObserver).
|
|
196
|
+
- Virtualize the rendered list (react-window, tanstack-virtual) for DOM performance.
|
|
197
|
+
- Show loading skeleton, not spinner, for smoother experience.
|
|
198
|
+
- Handle "back to top" — maintain scroll position on return navigation.
|
|
199
|
+
|
|
200
|
+
### Deep pagination protection
|
|
201
|
+
|
|
202
|
+
- For offset: cap maximum page (e.g., max 500 pages) and show "refine your search."
|
|
203
|
+
- For cursor: no cap needed (performance is constant).
|
|
204
|
+
- Rate-limit rapid sequential page requests (scraping protection).
|
|
205
|
+
- Log deep pagination usage — it often indicates a missing search/filter feature.
|
|
206
|
+
|
|
207
|
+
### API design best practices
|
|
208
|
+
|
|
209
|
+
**REST:**
|
|
210
|
+
- Use Link headers for next/prev URLs (HATEOAS).
|
|
211
|
+
- Include pagination metadata in response body.
|
|
212
|
+
- Consistent parameter names across all endpoints.
|
|
213
|
+
- Document maximum page size (prevent `per_page=999999`).
|
|
214
|
+
|
|
215
|
+
**GraphQL:**
|
|
216
|
+
- Use Connection spec (edges + pageInfo) universally.
|
|
217
|
+
- Make totalCount nullable (computed only when requested).
|
|
218
|
+
- Support both first/after and last/before.
|
|
219
|
+
|
|
220
|
+
**General:**
|
|
221
|
+
- Default page size: 20-50 (not too small, not too large).
|
|
222
|
+
- Maximum page size: 100 (enforce server-side).
|
|
223
|
+
- Sort order must be deterministic (include tiebreaker column).
|
|
224
|
+
- Return empty array (not null) when no results.
|
|
225
|
+
|
|
226
|
+
## Self-check before task completion
|
|
227
|
+
- [ ] Did I follow the mandatory actions for this skill?
|
|
228
|
+
- [ ] Did I apply the patterns appropriate to the context?
|
|
229
|
+
- [ ] Did I verify the implementation meets the criteria above?
|
|
230
|
+
- [ ] Did I document decisions and trade-offs made?
|