@cubis/foundry 0.3.71 → 0.3.73
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/CHANGELOG.md +23 -2
- package/dist/cli/core.js +9 -22
- package/dist/cli/core.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/core.ts +13 -22
- package/workflows/powers/accessibility/POWER.md +83 -94
- package/workflows/powers/accessibility/SKILL.md +82 -94
- package/workflows/powers/agent-design/POWER.md +201 -0
- package/workflows/powers/agent-design/SKILL.md +198 -0
- package/workflows/powers/agent-design/references/clarification-patterns.md +153 -0
- package/workflows/powers/agent-design/references/skill-testing.md +164 -0
- package/workflows/powers/agent-design/references/workflow-patterns.md +226 -0
- package/workflows/powers/agentic-eval/POWER.md +62 -0
- package/workflows/powers/agentic-eval/SKILL.md +59 -0
- package/workflows/powers/agentic-eval/references/rubric-and-regression-checklist.md +11 -0
- package/workflows/powers/api-designer/POWER.md +43 -71
- package/workflows/powers/api-designer/SKILL.md +43 -71
- package/workflows/powers/api-patterns/POWER.md +42 -56
- package/workflows/powers/api-patterns/SKILL.md +42 -57
- package/workflows/powers/architecture-designer/POWER.md +43 -60
- package/workflows/powers/architecture-designer/SKILL.md +43 -60
- package/workflows/powers/ask-questions-if-underspecified/POWER.md +51 -3
- package/workflows/powers/auth-architect/POWER.md +69 -0
- package/workflows/powers/auth-architect/SKILL.md +66 -0
- package/workflows/powers/auth-architect/references/session-token-policy-checklist.md +45 -0
- package/workflows/powers/behavioral-modes/POWER.md +100 -9
- package/workflows/powers/c-pro/POWER.md +105 -0
- package/workflows/powers/c-pro/SKILL.md +102 -0
- package/workflows/powers/c-pro/references/build-systems-and-toolchains.md +148 -0
- package/workflows/powers/c-pro/references/common-ub-and-portability.md +166 -0
- package/workflows/powers/c-pro/references/debugging-with-sanitizers.md +205 -0
- package/workflows/powers/c-pro/references/memory-safety-and-build-checklist.md +60 -0
- package/workflows/powers/c-pro/references/posix-and-platform-apis.md +244 -0
- package/workflows/powers/changelog-generator/POWER.md +127 -63
- package/workflows/powers/changelog-generator/SKILL.md +126 -63
- package/workflows/powers/ci-cd-pipelines/POWER.md +156 -0
- package/workflows/powers/ci-cd-pipelines/SKILL.md +153 -0
- package/workflows/powers/ci-cd-pipelines/references/github-actions-patterns.md +160 -0
- package/workflows/powers/ci-cd-pipelines/references/pipeline-security-checklist.md +57 -0
- package/workflows/powers/cli-developer/POWER.md +152 -95
- package/workflows/powers/cli-developer/SKILL.md +152 -95
- package/workflows/powers/cpp-pro/POWER.md +111 -0
- package/workflows/powers/cpp-pro/SKILL.md +108 -0
- package/workflows/powers/cpp-pro/references/concurrency-primitives.md +266 -0
- package/workflows/powers/cpp-pro/references/move-semantics-and-value-types.md +149 -0
- package/workflows/powers/cpp-pro/references/performance-and-profiling.md +191 -0
- package/workflows/powers/cpp-pro/references/raii-and-modern-cpp-checklist.md +87 -0
- package/workflows/powers/cpp-pro/references/template-and-concepts-patterns.md +205 -0
- package/workflows/powers/csharp-pro/POWER.md +47 -22
- package/workflows/powers/csharp-pro/SKILL.md +47 -22
- package/workflows/powers/dart-pro/POWER.md +68 -0
- package/workflows/powers/dart-pro/SKILL.md +65 -0
- package/workflows/powers/dart-pro/references/isolate-and-concurrency.md +180 -0
- package/workflows/powers/dart-pro/references/null-safety-and-async-patterns.md +133 -0
- package/workflows/powers/dart-pro/references/package-structure-and-linting.md +193 -0
- package/workflows/powers/dart-pro/references/sealed-records-patterns.md +173 -0
- package/workflows/powers/dart-pro/references/testing-and-mocking.md +235 -0
- package/workflows/powers/database-design/POWER.md +47 -33
- package/workflows/powers/database-design/SKILL.md +47 -33
- package/workflows/powers/database-optimizer/POWER.md +43 -64
- package/workflows/powers/database-optimizer/SKILL.md +43 -64
- package/workflows/powers/database-skills/POWER.md +59 -93
- package/workflows/powers/database-skills/SKILL.md +59 -93
- package/workflows/powers/debugging-strategies/POWER.md +69 -0
- package/workflows/powers/debugging-strategies/SKILL.md +66 -0
- package/workflows/powers/debugging-strategies/references/reproduce-isolate-verify-checklist.md +42 -0
- package/workflows/powers/deep-research/POWER.md +67 -0
- package/workflows/powers/deep-research/SKILL.md +64 -0
- package/workflows/powers/deep-research/references/multi-round-research-loop.md +80 -0
- package/workflows/powers/design-system-builder/POWER.md +130 -116
- package/workflows/powers/design-system-builder/SKILL.md +130 -116
- package/workflows/powers/devops-engineer/POWER.md +120 -57
- package/workflows/powers/devops-engineer/SKILL.md +120 -57
- package/workflows/powers/docker-kubernetes/POWER.md +94 -0
- package/workflows/powers/docker-kubernetes/SKILL.md +91 -0
- package/workflows/powers/docker-kubernetes/references/dockerfile-optimization-checklist.md +35 -0
- package/workflows/powers/docker-kubernetes/references/kubernetes-deployment-patterns.md +59 -0
- package/workflows/powers/documentation-templates/POWER.md +158 -127
- package/workflows/powers/documentation-templates/SKILL.md +158 -127
- package/workflows/powers/drizzle-expert/POWER.md +66 -0
- package/workflows/powers/drizzle-expert/SKILL.md +63 -0
- package/workflows/powers/drizzle-expert/references/runtime-pairing-matrix.md +16 -0
- package/workflows/powers/drizzle-expert/references/schema-and-migration-playbook.md +18 -0
- package/workflows/powers/error-ux-observability/POWER.md +144 -131
- package/workflows/powers/error-ux-observability/SKILL.md +143 -131
- package/workflows/powers/fastapi-expert/POWER.md +46 -60
- package/workflows/powers/fastapi-expert/SKILL.md +46 -60
- package/workflows/powers/firebase/POWER.md +65 -0
- package/workflows/powers/firebase/SKILL.md +62 -0
- package/workflows/powers/firebase/references/platform-routing.md +16 -0
- package/workflows/powers/firebase/references/rules-and-indexes-checklist.md +11 -0
- package/workflows/powers/flutter-design-system/POWER.md +63 -0
- package/workflows/powers/flutter-design-system/SKILL.md +60 -0
- package/workflows/powers/flutter-design-system/references/shared-widgets.md +29 -0
- package/workflows/powers/flutter-design-system/references/tokens-and-theme.md +34 -0
- package/workflows/powers/flutter-drift/POWER.md +65 -0
- package/workflows/powers/flutter-drift/SKILL.md +62 -0
- package/workflows/powers/flutter-drift/references/migrations.md +22 -0
- package/workflows/powers/flutter-drift/references/query-patterns.md +26 -0
- package/workflows/powers/flutter-feature/POWER.md +65 -0
- package/workflows/powers/flutter-feature/SKILL.md +62 -0
- package/workflows/powers/flutter-feature/references/architecture-rules.md +85 -0
- package/workflows/powers/flutter-feature/references/composite-provider.md +58 -0
- package/workflows/powers/flutter-feature/references/outbox-pattern.md +87 -0
- package/workflows/powers/flutter-feature/references/testing-patterns.md +218 -0
- package/workflows/powers/flutter-go-router/POWER.md +64 -0
- package/workflows/powers/flutter-go-router/SKILL.md +61 -0
- package/workflows/powers/flutter-go-router/references/guards-and-deeplinks.md +20 -0
- package/workflows/powers/flutter-go-router/references/typed-routes.md +27 -0
- package/workflows/powers/flutter-offline-sync/POWER.md +62 -0
- package/workflows/powers/flutter-offline-sync/SKILL.md +59 -0
- package/workflows/powers/flutter-offline-sync/references/outbox-full.md +44 -0
- package/workflows/powers/flutter-repository/POWER.md +64 -0
- package/workflows/powers/flutter-repository/SKILL.md +61 -0
- package/workflows/powers/flutter-repository/references/drift-patterns.md +21 -0
- package/workflows/powers/flutter-repository/references/retrofit-patterns.md +20 -0
- package/workflows/powers/flutter-riverpod/POWER.md +70 -0
- package/workflows/powers/flutter-riverpod/SKILL.md +67 -0
- package/workflows/powers/flutter-riverpod/references/async-and-mutations.md +19 -0
- package/workflows/powers/flutter-riverpod/references/async-lifecycle.md +19 -0
- package/workflows/powers/flutter-riverpod/references/provider-selection.md +20 -0
- package/workflows/powers/flutter-riverpod/references/testing.md +21 -0
- package/workflows/powers/flutter-riverpod/references/version-matrix.md +24 -0
- package/workflows/powers/flutter-state-machine/POWER.md +62 -0
- package/workflows/powers/flutter-state-machine/SKILL.md +59 -0
- package/workflows/powers/flutter-state-machine/references/app-state-contract.md +23 -0
- package/workflows/powers/flutter-state-machine/references/ui-rendering.md +14 -0
- package/workflows/powers/flutter-testing/POWER.md +64 -0
- package/workflows/powers/flutter-testing/SKILL.md +61 -0
- package/workflows/powers/flutter-testing/references/offline-sync-tests.md +16 -0
- package/workflows/powers/flutter-testing/references/test-layers.md +33 -0
- package/workflows/powers/frontend-code-review/POWER.md +137 -0
- package/workflows/powers/frontend-code-review/SKILL.md +134 -0
- package/workflows/powers/frontend-code-review/references/common-antipatterns.md +86 -0
- package/workflows/powers/frontend-code-review/references/performance-budgets.md +56 -0
- package/workflows/powers/frontend-code-review/references/review-checklists.md +47 -0
- package/workflows/powers/frontend-design/POWER.md +163 -362
- package/workflows/powers/frontend-design/SKILL.md +163 -362
- package/workflows/powers/game-development/POWER.md +57 -140
- package/workflows/powers/game-development/SKILL.md +57 -140
- package/workflows/powers/geo-fundamentals/POWER.md +64 -126
- package/workflows/powers/geo-fundamentals/SKILL.md +64 -127
- package/workflows/powers/git-workflow/POWER.md +135 -0
- package/workflows/powers/git-workflow/SKILL.md +132 -0
- package/workflows/powers/git-workflow/references/pr-review-checklist.md +63 -0
- package/workflows/powers/golang-pro/POWER.md +46 -35
- package/workflows/powers/golang-pro/SKILL.md +46 -35
- package/workflows/powers/graphql-architect/POWER.md +44 -62
- package/workflows/powers/graphql-architect/SKILL.md +44 -62
- package/workflows/powers/i18n-localization/POWER.md +118 -103
- package/workflows/powers/i18n-localization/SKILL.md +118 -103
- package/workflows/powers/java-pro/POWER.md +47 -22
- package/workflows/powers/java-pro/SKILL.md +47 -22
- package/workflows/powers/javascript-pro/POWER.md +47 -34
- package/workflows/powers/javascript-pro/SKILL.md +47 -34
- package/workflows/powers/kotlin-pro/POWER.md +46 -23
- package/workflows/powers/kotlin-pro/SKILL.md +46 -23
- package/workflows/powers/legacy-modernizer/POWER.md +43 -60
- package/workflows/powers/legacy-modernizer/SKILL.md +43 -60
- package/workflows/powers/mcp-builder/POWER.md +65 -0
- package/workflows/powers/mcp-builder/SKILL.md +62 -0
- package/workflows/powers/mcp-builder/references/testing-and-evals.md +17 -0
- package/workflows/powers/mcp-builder/references/transport-and-tool-design.md +17 -0
- package/workflows/powers/microservices-architect/POWER.md +43 -70
- package/workflows/powers/microservices-architect/SKILL.md +43 -70
- package/workflows/powers/mobile-design/POWER.md +110 -345
- package/workflows/powers/mobile-design/SKILL.md +110 -345
- package/workflows/powers/mongodb/POWER.md +67 -0
- package/workflows/powers/mongodb/SKILL.md +64 -0
- package/workflows/powers/mongodb/references/mongodb-checklist.md +20 -0
- package/workflows/powers/mysql/POWER.md +67 -0
- package/workflows/powers/mysql/SKILL.md +64 -0
- package/workflows/powers/mysql/references/mysql-checklist.md +20 -0
- package/workflows/powers/neki/POWER.md +67 -0
- package/workflows/powers/neki/SKILL.md +64 -0
- package/workflows/powers/neki/references/neki-checklist.md +18 -0
- package/workflows/powers/nestjs-expert/POWER.md +45 -91
- package/workflows/powers/nestjs-expert/SKILL.md +45 -91
- package/workflows/powers/nextjs-developer/POWER.md +51 -44
- package/workflows/powers/nextjs-developer/SKILL.md +51 -44
- package/workflows/powers/nodejs-best-practices/POWER.md +48 -29
- package/workflows/powers/nodejs-best-practices/SKILL.md +48 -29
- package/workflows/powers/observability/POWER.md +109 -0
- package/workflows/powers/observability/SKILL.md +106 -0
- package/workflows/powers/observability/references/alerting-and-slo-checklist.md +87 -0
- package/workflows/powers/observability/references/opentelemetry-setup-guide.md +121 -0
- package/workflows/powers/openai-docs/POWER.md +61 -0
- package/workflows/powers/openai-docs/SKILL.md +58 -0
- package/workflows/powers/openai-docs/references/official-source-playbook.md +10 -0
- package/workflows/powers/performance-profiling/POWER.md +61 -114
- package/workflows/powers/performance-profiling/SKILL.md +61 -114
- package/workflows/powers/php-pro/POWER.md +116 -0
- package/workflows/powers/php-pro/SKILL.md +113 -0
- package/workflows/powers/php-pro/references/architecture-and-di.md +239 -0
- package/workflows/powers/php-pro/references/modern-php-features.md +189 -0
- package/workflows/powers/php-pro/references/performance-and-deployment.md +197 -0
- package/workflows/powers/php-pro/references/php84-strict-typing-checklist.md +161 -0
- package/workflows/powers/php-pro/references/testing-and-static-analysis.md +235 -0
- package/workflows/powers/playwright-e2e/POWER.md +85 -0
- package/workflows/powers/playwright-e2e/SKILL.md +82 -0
- package/workflows/powers/playwright-e2e/references/locator-trace-flake-checklist.md +80 -0
- package/workflows/powers/postgres/POWER.md +67 -0
- package/workflows/powers/postgres/SKILL.md +64 -0
- package/workflows/powers/postgres/references/postgres-checklist.md +20 -0
- package/workflows/powers/prompt-engineer/POWER.md +47 -30
- package/workflows/powers/prompt-engineer/SKILL.md +47 -30
- package/workflows/powers/python-pro/POWER.md +47 -36
- package/workflows/powers/python-pro/SKILL.md +47 -36
- package/workflows/powers/react-best-practices/POWER.md +56 -33
- package/workflows/powers/react-best-practices/SKILL.md +56 -33
- package/workflows/powers/react-expert/POWER.md +47 -37
- package/workflows/powers/react-expert/SKILL.md +47 -37
- package/workflows/powers/redis/POWER.md +67 -0
- package/workflows/powers/redis/SKILL.md +64 -0
- package/workflows/powers/redis/references/redis-checklist.md +19 -0
- package/workflows/powers/ruby-pro/POWER.md +118 -0
- package/workflows/powers/ruby-pro/SKILL.md +115 -0
- package/workflows/powers/ruby-pro/references/modern-ruby-features.md +189 -0
- package/workflows/powers/ruby-pro/references/object-design-patterns.md +220 -0
- package/workflows/powers/ruby-pro/references/performance-and-profiling.md +224 -0
- package/workflows/powers/ruby-pro/references/ruby-concurrency-and-testing.md +190 -0
- package/workflows/powers/ruby-pro/references/testing-and-rspec.md +236 -0
- package/workflows/powers/rust-pro/POWER.md +45 -31
- package/workflows/powers/rust-pro/SKILL.md +45 -31
- package/workflows/powers/security-engineer/POWER.md +129 -0
- package/workflows/powers/security-engineer/SKILL.md +126 -0
- package/workflows/powers/seo-fundamentals/POWER.md +59 -102
- package/workflows/powers/seo-fundamentals/SKILL.md +59 -102
- package/workflows/powers/serverless-patterns/POWER.md +171 -0
- package/workflows/powers/serverless-patterns/SKILL.md +168 -0
- package/workflows/powers/skill-creator/POWER.md +90 -0
- package/workflows/powers/skill-creator/SKILL.md +87 -0
- package/workflows/powers/skill-creator/references/platform-formats.md +181 -0
- package/workflows/powers/skill-creator/references/schemas.md +430 -0
- package/workflows/powers/spec-miner/POWER.md +49 -57
- package/workflows/powers/spec-miner/SKILL.md +49 -57
- package/workflows/powers/sqlite/POWER.md +67 -0
- package/workflows/powers/sqlite/SKILL.md +64 -0
- package/workflows/powers/sqlite/references/sqlite-checklist.md +19 -0
- package/workflows/powers/sre-engineer/POWER.md +123 -64
- package/workflows/powers/sre-engineer/SKILL.md +123 -64
- package/workflows/powers/static-analysis/POWER.md +121 -77
- package/workflows/powers/static-analysis/SKILL.md +121 -77
- package/workflows/powers/stripe-best-practices/POWER.md +140 -17
- package/workflows/powers/stripe-best-practices/SKILL.md +139 -17
- package/workflows/powers/supabase/POWER.md +67 -0
- package/workflows/powers/supabase/SKILL.md +64 -0
- package/workflows/powers/supabase/references/supabase-checklist.md +19 -0
- package/workflows/powers/swift-pro/POWER.md +118 -0
- package/workflows/powers/swift-pro/SKILL.md +115 -0
- package/workflows/powers/swift-pro/references/concurrency-patterns.md +165 -0
- package/workflows/powers/swift-pro/references/protocol-and-generics.md +172 -0
- package/workflows/powers/swift-pro/references/sendable-and-isolation.md +116 -0
- package/workflows/powers/swift-pro/references/swift-concurrency-and-protocols.md +260 -0
- package/workflows/powers/swift-pro/references/testing-and-packages.md +192 -0
- package/workflows/powers/tailwind-patterns/POWER.md +71 -240
- package/workflows/powers/tailwind-patterns/SKILL.md +71 -240
- package/workflows/powers/testing-patterns/POWER.md +155 -10
- package/workflows/powers/testing-patterns/SKILL.md +155 -10
- package/workflows/powers/typescript-pro/POWER.md +47 -38
- package/workflows/powers/typescript-pro/SKILL.md +47 -38
- package/workflows/powers/vitess/POWER.md +67 -0
- package/workflows/powers/vitess/SKILL.md +64 -0
- package/workflows/powers/vitess/references/vitess-checklist.md +19 -0
- package/workflows/powers/vulnerability-scanner/POWER.md +146 -10
- package/workflows/powers/vulnerability-scanner/SKILL.md +146 -10
- package/workflows/powers/web-perf/POWER.md +43 -170
- package/workflows/powers/web-perf/SKILL.md +43 -170
- package/workflows/powers/webapp-testing/POWER.md +43 -164
- package/workflows/powers/webapp-testing/SKILL.md +43 -164
- package/workflows/workflows/agent-environment-setup/platforms/antigravity/rules/GEMINI.md +65 -42
- package/workflows/workflows/agent-environment-setup/platforms/claude/rules/CLAUDE.md +8 -6
- package/workflows/workflows/agent-environment-setup/platforms/codex/rules/AGENTS.md +65 -41
- package/workflows/workflows/agent-environment-setup/platforms/copilot/rules/copilot-instructions.md +8 -6
- package/workflows/workflows/agent-environment-setup/shared/rules/STEERING.md +9 -8
- package/workflows/workflows/agent-environment-setup/shared/rules/overrides/codex.md +1 -1
|
@@ -1,160 +1,173 @@
|
|
|
1
1
|
````markdown
|
|
2
2
|
---
|
|
3
3
|
inclusion: manual
|
|
4
|
-
name:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"logging",
|
|
12
|
-
"observability",
|
|
13
|
-
"user feedback",
|
|
14
|
-
"failure mapping",
|
|
15
|
-
"error ux",
|
|
16
|
-
]
|
|
4
|
+
name: error-ux-observability
|
|
5
|
+
description: Design error experiences, structured logging, distributed tracing, alerting strategies, and user-facing error handling for production systems.
|
|
6
|
+
license: Apache-2.0
|
|
7
|
+
metadata:
|
|
8
|
+
author: cubis-foundry
|
|
9
|
+
version: "3.0"
|
|
10
|
+
compatibility: Claude Code, Codex, GitHub Copilot, Gemini CLI
|
|
17
11
|
---
|
|
18
12
|
|
|
19
13
|
# Error UX & Observability
|
|
20
14
|
|
|
21
|
-
##
|
|
15
|
+
## Purpose
|
|
22
16
|
|
|
23
|
-
|
|
17
|
+
Bridge user-facing error handling and backend observability. Design error experiences that help users recover, while ensuring engineers have the telemetry to diagnose and fix issues quickly.
|
|
24
18
|
|
|
25
19
|
## When to Use
|
|
26
20
|
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
|
|
33
|
-
## Quick Reference
|
|
34
|
-
|
|
35
|
-
### Failure to UI Message Mapping
|
|
36
|
-
|
|
37
|
-
```dart
|
|
38
|
-
// ✅ Map technical errors to user-friendly messages
|
|
39
|
-
String getErrorMessage(Failure failure) {
|
|
40
|
-
return failure.when(
|
|
41
|
-
network: () => 'No internet connection. Please check your network.',
|
|
42
|
-
server: (code, message) {
|
|
43
|
-
if (code == 401) return 'Session expired. Please login again.';
|
|
44
|
-
if (code == 403) return 'You don\'t have permission for this action.';
|
|
45
|
-
if (code == 404) return 'Resource not found.';
|
|
46
|
-
if (code >= 500) return 'Server error. Please try again later.';
|
|
47
|
-
return message ?? 'Something went wrong.';
|
|
48
|
-
},
|
|
49
|
-
validation: (errors) => errors.values.first,
|
|
50
|
-
unauthorized: () => 'Please login to continue.',
|
|
51
|
-
notFound: () => 'Item not found.',
|
|
52
|
-
unknown: (error) => 'An unexpected error occurred.',
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
```
|
|
21
|
+
- Designing error messages, states, and recovery flows for users
|
|
22
|
+
- Implementing structured logging and error tracking
|
|
23
|
+
- Setting up distributed tracing across services
|
|
24
|
+
- Building alerting strategies that reduce noise
|
|
25
|
+
- Creating error boundaries and fallback UI
|
|
26
|
+
- Debugging production issues with telemetry data
|
|
56
27
|
|
|
57
|
-
|
|
28
|
+
## Instructions
|
|
58
29
|
|
|
59
|
-
|
|
60
|
-
// ✅ Use appropriate log levels
|
|
61
|
-
logger.debug('Cache hit for attendance data'); // Development only
|
|
62
|
-
logger.info('User logged in: userId=${user.id}'); // Important events
|
|
63
|
-
logger.warning('API rate limit approaching'); // Potential issues
|
|
64
|
-
logger.error('Failed to sync attendance', error: e, stackTrace: st); // Errors
|
|
65
|
-
logger.fatal('Database corruption detected'); // Critical failures
|
|
66
|
-
```
|
|
30
|
+
### Step 1 — Design User-Facing Errors
|
|
67
31
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
'userId': user.id,
|
|
81
|
-
'leaveType': leaveRequest.type,
|
|
82
|
-
'startDate': leaveRequest.startDate,
|
|
83
|
-
},
|
|
84
|
-
);
|
|
85
|
-
rethrow;
|
|
86
|
-
}
|
|
32
|
+
Every error the user sees must answer three questions:
|
|
33
|
+
|
|
34
|
+
1. **What happened?** (plain language, no stack traces)
|
|
35
|
+
2. **Is it their fault or ours?** (affects tone)
|
|
36
|
+
3. **What can they do next?** (always give an action)
|
|
37
|
+
|
|
38
|
+
**Error message structure**:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
[Title]: Brief description of what went wrong
|
|
42
|
+
[Body]: What happened and why
|
|
43
|
+
[Action]: Clear next step (retry, change input, contact support)
|
|
87
44
|
```
|
|
88
45
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
46
|
+
**Good vs Bad error messages**:
|
|
47
|
+
| Bad | Good |
|
|
48
|
+
|-----|------|
|
|
49
|
+
| "Error 500" | "Something went wrong on our end. We're looking into it." |
|
|
50
|
+
| "Invalid input" | "Email address must include @ and a domain (e.g., name@example.com)" |
|
|
51
|
+
| "Network error" | "Couldn't reach the server. Check your connection and try again." |
|
|
52
|
+
| "Null reference exception" | "We couldn't load your profile. Try refreshing the page." |
|
|
53
|
+
|
|
54
|
+
**Error states in UI**:
|
|
55
|
+
|
|
56
|
+
- **Inline**: validation errors next to the field that caused them
|
|
57
|
+
- **Toast/snackbar**: transient non-critical errors (auto-dismiss in 5-8s)
|
|
58
|
+
- **Banner**: persistent issues affecting the whole page
|
|
59
|
+
- **Full page**: catastrophic failures with recovery path
|
|
60
|
+
- **Empty state**: data couldn't load — show illustration + retry button
|
|
61
|
+
|
|
62
|
+
### Step 2 — Implement Error Boundaries
|
|
63
|
+
|
|
64
|
+
**Frontend**:
|
|
65
|
+
|
|
66
|
+
- Catch errors at route/feature boundaries, not globally
|
|
67
|
+
- Show fallback UI that lets the user continue elsewhere
|
|
68
|
+
- Log the error with context (component tree, user action, state)
|
|
69
|
+
- Auto-report to error tracking service
|
|
70
|
+
|
|
71
|
+
**Backend**:
|
|
72
|
+
|
|
73
|
+
- Return structured error responses:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"error": {
|
|
78
|
+
"code": "PAYMENT_DECLINED",
|
|
79
|
+
"message": "Your card was declined. Please try a different payment method.",
|
|
80
|
+
"details": { "reason": "insufficient_funds" },
|
|
81
|
+
"requestId": "req_abc123"
|
|
105
82
|
}
|
|
106
83
|
}
|
|
107
84
|
```
|
|
108
85
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
86
|
+
- Map internal errors to user-safe messages (never expose stack traces, SQL, or internal paths)
|
|
87
|
+
- Include request ID for correlation
|
|
88
|
+
- Use appropriate HTTP status codes (don't 200 everything)
|
|
89
|
+
|
|
90
|
+
### Step 3 — Structured Logging
|
|
91
|
+
|
|
92
|
+
**Every log entry should include**:
|
|
93
|
+
|
|
94
|
+
- Timestamp (ISO 8601, UTC)
|
|
95
|
+
- Level (debug, info, warn, error)
|
|
96
|
+
- Message (human-readable)
|
|
97
|
+
- Request ID / correlation ID
|
|
98
|
+
- Service name and version
|
|
99
|
+
- User ID (if authenticated)
|
|
100
|
+
- Relevant context (input parameters, affected resource)
|
|
101
|
+
|
|
102
|
+
**Log levels**:
|
|
103
|
+
| Level | When | Example |
|
|
104
|
+
|-------|------|---------|
|
|
105
|
+
| error | Something failed that shouldn't have | Database connection lost |
|
|
106
|
+
| warn | Something unusual but handled | Rate limit approaching |
|
|
107
|
+
| info | Normal business events | User signed up, order placed |
|
|
108
|
+
| debug | Development troubleshooting | Query parameters, cache hit/miss |
|
|
109
|
+
|
|
110
|
+
**Rules**:
|
|
111
|
+
|
|
112
|
+
- Never log secrets, passwords, tokens, or PII
|
|
113
|
+
- Use structured format (JSON) for machine parsing
|
|
114
|
+
- Include enough context to diagnose without reproducing
|
|
115
|
+
- Log at the boundary (entry/exit of service calls)
|
|
116
|
+
|
|
117
|
+
### Step 4 — Distributed Tracing
|
|
118
|
+
|
|
119
|
+
**Trace propagation**:
|
|
120
|
+
|
|
121
|
+
- Every request gets a trace ID at the edge
|
|
122
|
+
- Pass trace ID through all service calls (HTTP headers, message metadata)
|
|
123
|
+
- Each service creates spans for its operations
|
|
124
|
+
- Spans include: operation name, duration, status, attributes
|
|
125
|
+
|
|
126
|
+
**What to trace**:
|
|
127
|
+
|
|
128
|
+
- HTTP requests (method, path, status, latency)
|
|
129
|
+
- Database queries (operation, table, duration)
|
|
130
|
+
- External API calls (service, endpoint, latency)
|
|
131
|
+
- Queue operations (publish, consume, processing time)
|
|
132
|
+
- Cache operations (hit/miss, key pattern, latency)
|
|
133
|
+
|
|
134
|
+
### Step 5 — Alerting Strategy
|
|
135
|
+
|
|
136
|
+
**Alert on symptoms, not causes**:
|
|
137
|
+
|
|
138
|
+
- DO alert: "Error rate > 1% for 5 minutes"
|
|
139
|
+
- DON'T alert: "CPU > 80%" (that's a dashboard metric, not an alert)
|
|
140
|
+
|
|
141
|
+
**Reduce noise**:
|
|
142
|
+
|
|
143
|
+
- Alert on SLO burn rate, not individual errors
|
|
144
|
+
- Group related alerts (one page, not 50)
|
|
145
|
+
- Required for every alert: runbook link, severity, escalation path
|
|
146
|
+
- Review alert fatigue monthly — suppress alerts that never led to action
|
|
147
|
+
|
|
148
|
+
## Output Format
|
|
128
149
|
|
|
129
|
-
### UI Layer
|
|
130
|
-
|
|
131
|
-
```dart
|
|
132
|
-
ref.listen(controllerProvider, (prev, next) {
|
|
133
|
-
next.whenOrNull(
|
|
134
|
-
error: (error, _) {
|
|
135
|
-
final message = error is Failure
|
|
136
|
-
? getErrorMessage(error)
|
|
137
|
-
: 'An unexpected error occurred';
|
|
138
|
-
OneSnackbar.error(context, message);
|
|
139
|
-
},
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
150
|
```
|
|
151
|
+
## Error Handling Design
|
|
152
|
+
[user-facing error strategy]
|
|
153
|
+
|
|
154
|
+
## Observability Implementation
|
|
155
|
+
[logging, tracing, and metrics setup]
|
|
143
156
|
|
|
144
|
-
##
|
|
157
|
+
## Alerting Rules
|
|
158
|
+
[what triggers alerts and who responds]
|
|
159
|
+
|
|
160
|
+
## Runbook
|
|
161
|
+
[diagnosis and resolution steps for common errors]
|
|
162
|
+
```
|
|
145
163
|
|
|
146
|
-
|
|
147
|
-
2. **Include context** (userId, action, timestamp)
|
|
148
|
-
3. **Use structured logging** (key-value pairs)
|
|
149
|
-
4. **Log at appropriate levels** (debug/info/warning/error/fatal)
|
|
150
|
-
5. **Include stack traces for errors**
|
|
164
|
+
## Examples
|
|
151
165
|
|
|
152
|
-
|
|
166
|
+
**User**: "Design error handling for our checkout flow"
|
|
153
167
|
|
|
154
|
-
|
|
155
|
-
- `logging_levels.md` - When to use each log level
|
|
168
|
+
**Response approach**: Map all failure modes (payment declined, inventory gone, session expired, network error). Design user-facing messages for each. Implement retry logic for transient errors. Add structured logging at every decision point. Set up alerts on checkout error rate.
|
|
156
169
|
|
|
157
|
-
|
|
170
|
+
**User**: "We can't figure out why requests are slow in production"
|
|
158
171
|
|
|
159
|
-
|
|
172
|
+
**Response approach**: Add distributed tracing to identify the slow span. Structured logging at service boundaries. Dashboard for p50/p95/p99 latency. Alert on latency SLO burn rate. Runbook for common latency causes.
|
|
160
173
|
````
|
|
@@ -1,158 +1,170 @@
|
|
|
1
1
|
---
|
|
2
|
-
name:
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"logging",
|
|
10
|
-
"observability",
|
|
11
|
-
"user feedback",
|
|
12
|
-
"failure mapping",
|
|
13
|
-
"error ux",
|
|
14
|
-
]
|
|
2
|
+
name: error-ux-observability
|
|
3
|
+
description: Design error experiences, structured logging, distributed tracing, alerting strategies, and user-facing error handling for production systems.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
metadata:
|
|
6
|
+
author: cubis-foundry
|
|
7
|
+
version: "3.0"
|
|
8
|
+
compatibility: Claude Code, Codex, GitHub Copilot, Gemini CLI
|
|
15
9
|
---
|
|
16
10
|
|
|
17
11
|
# Error UX & Observability
|
|
18
12
|
|
|
19
|
-
##
|
|
13
|
+
## Purpose
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
Bridge user-facing error handling and backend observability. Design error experiences that help users recover, while ensuring engineers have the telemetry to diagnose and fix issues quickly.
|
|
22
16
|
|
|
23
17
|
## When to Use
|
|
24
18
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
## Quick Reference
|
|
32
|
-
|
|
33
|
-
### Failure to UI Message Mapping
|
|
34
|
-
|
|
35
|
-
```dart
|
|
36
|
-
// ✅ Map technical errors to user-friendly messages
|
|
37
|
-
String getErrorMessage(Failure failure) {
|
|
38
|
-
return failure.when(
|
|
39
|
-
network: () => 'No internet connection. Please check your network.',
|
|
40
|
-
server: (code, message) {
|
|
41
|
-
if (code == 401) return 'Session expired. Please login again.';
|
|
42
|
-
if (code == 403) return 'You don\'t have permission for this action.';
|
|
43
|
-
if (code == 404) return 'Resource not found.';
|
|
44
|
-
if (code >= 500) return 'Server error. Please try again later.';
|
|
45
|
-
return message ?? 'Something went wrong.';
|
|
46
|
-
},
|
|
47
|
-
validation: (errors) => errors.values.first,
|
|
48
|
-
unauthorized: () => 'Please login to continue.',
|
|
49
|
-
notFound: () => 'Item not found.',
|
|
50
|
-
unknown: (error) => 'An unexpected error occurred.',
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
```
|
|
19
|
+
- Designing error messages, states, and recovery flows for users
|
|
20
|
+
- Implementing structured logging and error tracking
|
|
21
|
+
- Setting up distributed tracing across services
|
|
22
|
+
- Building alerting strategies that reduce noise
|
|
23
|
+
- Creating error boundaries and fallback UI
|
|
24
|
+
- Debugging production issues with telemetry data
|
|
54
25
|
|
|
55
|
-
|
|
26
|
+
## Instructions
|
|
56
27
|
|
|
57
|
-
|
|
58
|
-
// ✅ Use appropriate log levels
|
|
59
|
-
logger.debug('Cache hit for attendance data'); // Development only
|
|
60
|
-
logger.info('User logged in: userId=${user.id}'); // Important events
|
|
61
|
-
logger.warning('API rate limit approaching'); // Potential issues
|
|
62
|
-
logger.error('Failed to sync attendance', error: e, stackTrace: st); // Errors
|
|
63
|
-
logger.fatal('Database corruption detected'); // Critical failures
|
|
64
|
-
```
|
|
28
|
+
### Step 1 — Design User-Facing Errors
|
|
65
29
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
'userId': user.id,
|
|
79
|
-
'leaveType': leaveRequest.type,
|
|
80
|
-
'startDate': leaveRequest.startDate,
|
|
81
|
-
},
|
|
82
|
-
);
|
|
83
|
-
rethrow;
|
|
84
|
-
}
|
|
30
|
+
Every error the user sees must answer three questions:
|
|
31
|
+
|
|
32
|
+
1. **What happened?** (plain language, no stack traces)
|
|
33
|
+
2. **Is it their fault or ours?** (affects tone)
|
|
34
|
+
3. **What can they do next?** (always give an action)
|
|
35
|
+
|
|
36
|
+
**Error message structure**:
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
[Title]: Brief description of what went wrong
|
|
40
|
+
[Body]: What happened and why
|
|
41
|
+
[Action]: Clear next step (retry, change input, contact support)
|
|
85
42
|
```
|
|
86
43
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
44
|
+
**Good vs Bad error messages**:
|
|
45
|
+
| Bad | Good |
|
|
46
|
+
|-----|------|
|
|
47
|
+
| "Error 500" | "Something went wrong on our end. We're looking into it." |
|
|
48
|
+
| "Invalid input" | "Email address must include @ and a domain (e.g., name@example.com)" |
|
|
49
|
+
| "Network error" | "Couldn't reach the server. Check your connection and try again." |
|
|
50
|
+
| "Null reference exception" | "We couldn't load your profile. Try refreshing the page." |
|
|
51
|
+
|
|
52
|
+
**Error states in UI**:
|
|
53
|
+
|
|
54
|
+
- **Inline**: validation errors next to the field that caused them
|
|
55
|
+
- **Toast/snackbar**: transient non-critical errors (auto-dismiss in 5-8s)
|
|
56
|
+
- **Banner**: persistent issues affecting the whole page
|
|
57
|
+
- **Full page**: catastrophic failures with recovery path
|
|
58
|
+
- **Empty state**: data couldn't load — show illustration + retry button
|
|
59
|
+
|
|
60
|
+
### Step 2 — Implement Error Boundaries
|
|
61
|
+
|
|
62
|
+
**Frontend**:
|
|
63
|
+
|
|
64
|
+
- Catch errors at route/feature boundaries, not globally
|
|
65
|
+
- Show fallback UI that lets the user continue elsewhere
|
|
66
|
+
- Log the error with context (component tree, user action, state)
|
|
67
|
+
- Auto-report to error tracking service
|
|
68
|
+
|
|
69
|
+
**Backend**:
|
|
70
|
+
|
|
71
|
+
- Return structured error responses:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"error": {
|
|
76
|
+
"code": "PAYMENT_DECLINED",
|
|
77
|
+
"message": "Your card was declined. Please try a different payment method.",
|
|
78
|
+
"details": { "reason": "insufficient_funds" },
|
|
79
|
+
"requestId": "req_abc123"
|
|
103
80
|
}
|
|
104
81
|
}
|
|
105
82
|
```
|
|
106
83
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
84
|
+
- Map internal errors to user-safe messages (never expose stack traces, SQL, or internal paths)
|
|
85
|
+
- Include request ID for correlation
|
|
86
|
+
- Use appropriate HTTP status codes (don't 200 everything)
|
|
87
|
+
|
|
88
|
+
### Step 3 — Structured Logging
|
|
89
|
+
|
|
90
|
+
**Every log entry should include**:
|
|
91
|
+
|
|
92
|
+
- Timestamp (ISO 8601, UTC)
|
|
93
|
+
- Level (debug, info, warn, error)
|
|
94
|
+
- Message (human-readable)
|
|
95
|
+
- Request ID / correlation ID
|
|
96
|
+
- Service name and version
|
|
97
|
+
- User ID (if authenticated)
|
|
98
|
+
- Relevant context (input parameters, affected resource)
|
|
99
|
+
|
|
100
|
+
**Log levels**:
|
|
101
|
+
| Level | When | Example |
|
|
102
|
+
|-------|------|---------|
|
|
103
|
+
| error | Something failed that shouldn't have | Database connection lost |
|
|
104
|
+
| warn | Something unusual but handled | Rate limit approaching |
|
|
105
|
+
| info | Normal business events | User signed up, order placed |
|
|
106
|
+
| debug | Development troubleshooting | Query parameters, cache hit/miss |
|
|
107
|
+
|
|
108
|
+
**Rules**:
|
|
109
|
+
|
|
110
|
+
- Never log secrets, passwords, tokens, or PII
|
|
111
|
+
- Use structured format (JSON) for machine parsing
|
|
112
|
+
- Include enough context to diagnose without reproducing
|
|
113
|
+
- Log at the boundary (entry/exit of service calls)
|
|
114
|
+
|
|
115
|
+
### Step 4 — Distributed Tracing
|
|
116
|
+
|
|
117
|
+
**Trace propagation**:
|
|
118
|
+
|
|
119
|
+
- Every request gets a trace ID at the edge
|
|
120
|
+
- Pass trace ID through all service calls (HTTP headers, message metadata)
|
|
121
|
+
- Each service creates spans for its operations
|
|
122
|
+
- Spans include: operation name, duration, status, attributes
|
|
123
|
+
|
|
124
|
+
**What to trace**:
|
|
125
|
+
|
|
126
|
+
- HTTP requests (method, path, status, latency)
|
|
127
|
+
- Database queries (operation, table, duration)
|
|
128
|
+
- External API calls (service, endpoint, latency)
|
|
129
|
+
- Queue operations (publish, consume, processing time)
|
|
130
|
+
- Cache operations (hit/miss, key pattern, latency)
|
|
131
|
+
|
|
132
|
+
### Step 5 — Alerting Strategy
|
|
133
|
+
|
|
134
|
+
**Alert on symptoms, not causes**:
|
|
135
|
+
|
|
136
|
+
- DO alert: "Error rate > 1% for 5 minutes"
|
|
137
|
+
- DON'T alert: "CPU > 80%" (that's a dashboard metric, not an alert)
|
|
138
|
+
|
|
139
|
+
**Reduce noise**:
|
|
140
|
+
|
|
141
|
+
- Alert on SLO burn rate, not individual errors
|
|
142
|
+
- Group related alerts (one page, not 50)
|
|
143
|
+
- Required for every alert: runbook link, severity, escalation path
|
|
144
|
+
- Review alert fatigue monthly — suppress alerts that never led to action
|
|
145
|
+
|
|
146
|
+
## Output Format
|
|
126
147
|
|
|
127
|
-
### UI Layer
|
|
128
|
-
|
|
129
|
-
```dart
|
|
130
|
-
ref.listen(controllerProvider, (prev, next) {
|
|
131
|
-
next.whenOrNull(
|
|
132
|
-
error: (error, _) {
|
|
133
|
-
final message = error is Failure
|
|
134
|
-
? getErrorMessage(error)
|
|
135
|
-
: 'An unexpected error occurred';
|
|
136
|
-
OneSnackbar.error(context, message);
|
|
137
|
-
},
|
|
138
|
-
);
|
|
139
|
-
});
|
|
140
148
|
```
|
|
149
|
+
## Error Handling Design
|
|
150
|
+
[user-facing error strategy]
|
|
141
151
|
|
|
142
|
-
##
|
|
152
|
+
## Observability Implementation
|
|
153
|
+
[logging, tracing, and metrics setup]
|
|
143
154
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
155
|
+
## Alerting Rules
|
|
156
|
+
[what triggers alerts and who responds]
|
|
157
|
+
|
|
158
|
+
## Runbook
|
|
159
|
+
[diagnosis and resolution steps for common errors]
|
|
160
|
+
```
|
|
149
161
|
|
|
150
|
-
##
|
|
162
|
+
## Examples
|
|
151
163
|
|
|
152
|
-
|
|
153
|
-
- `logging_levels.md` - When to use each log level
|
|
164
|
+
**User**: "Design error handling for our checkout flow"
|
|
154
165
|
|
|
155
|
-
|
|
166
|
+
**Response approach**: Map all failure modes (payment declined, inventory gone, session expired, network error). Design user-facing messages for each. Implement retry logic for transient errors. Add structured logging at every decision point. Set up alerts on checkout error rate.
|
|
156
167
|
|
|
157
|
-
|
|
168
|
+
**User**: "We can't figure out why requests are slow in production"
|
|
158
169
|
|
|
170
|
+
**Response approach**: Add distributed tracing to identify the slow span. Structured logging at service boundaries. Dashboard for p50/p95/p99 latency. Alert on latency SLO burn rate. Runbook for common latency causes.
|