@cubis/foundry 0.3.71 → 0.3.72
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 +15 -0
- package/dist/cli/core.js +4 -18
- package/dist/cli/core.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/core.ts +4 -18
- 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
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# Template and Concepts Patterns
|
|
2
|
+
|
|
3
|
+
## Concepts (C++20/23)
|
|
4
|
+
|
|
5
|
+
Concepts replace SFINAE with readable, composable constraints.
|
|
6
|
+
|
|
7
|
+
```cpp
|
|
8
|
+
#include <concepts>
|
|
9
|
+
|
|
10
|
+
// Basic concept usage
|
|
11
|
+
template<std::integral T>
|
|
12
|
+
T add(T a, T b) { return a + b; }
|
|
13
|
+
|
|
14
|
+
// Custom concept
|
|
15
|
+
template<typename T>
|
|
16
|
+
concept Serializable = requires(T t, std::ostream& os) {
|
|
17
|
+
{ t.serialize(os) } -> std::same_as<void>;
|
|
18
|
+
{ T::deserialize(os) } -> std::same_as<T>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Use in function template
|
|
22
|
+
template<Serializable T>
|
|
23
|
+
void save(const T& obj, const std::filesystem::path& path) {
|
|
24
|
+
std::ofstream file(path);
|
|
25
|
+
obj.serialize(file);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Concept with multiple requirements
|
|
29
|
+
template<typename T>
|
|
30
|
+
concept Hashable = requires(T a) {
|
|
31
|
+
{ std::hash<T>{}(a) } -> std::convertible_to<std::size_t>;
|
|
32
|
+
requires std::equality_comparable<T>;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// Constrained auto
|
|
36
|
+
void process(std::ranges::range auto&& r) {
|
|
37
|
+
for (auto&& elem : r) {
|
|
38
|
+
// works with any range
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Concept Composition
|
|
44
|
+
|
|
45
|
+
```cpp
|
|
46
|
+
// Combine concepts with &&, ||
|
|
47
|
+
template<typename T>
|
|
48
|
+
concept Numeric = std::integral<T> || std::floating_point<T>;
|
|
49
|
+
|
|
50
|
+
template<typename T>
|
|
51
|
+
concept OrderedNumeric = Numeric<T> && std::totally_ordered<T>;
|
|
52
|
+
|
|
53
|
+
// Subsumption — more constrained overload wins
|
|
54
|
+
template<std::integral T>
|
|
55
|
+
void process(T val) { /* integral-specific */ }
|
|
56
|
+
|
|
57
|
+
template<Numeric T>
|
|
58
|
+
void process(T val) { /* fallback for floating point */ }
|
|
59
|
+
|
|
60
|
+
// int → matches std::integral (more constrained), calls first overload
|
|
61
|
+
// double → matches Numeric, calls second overload
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Variadic Templates
|
|
65
|
+
|
|
66
|
+
```cpp
|
|
67
|
+
// Fold expressions (C++17) — clean variadic operations
|
|
68
|
+
template<typename... Args>
|
|
69
|
+
auto sum(Args... args) {
|
|
70
|
+
return (args + ...); // right fold
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Print all arguments
|
|
74
|
+
template<typename... Args>
|
|
75
|
+
void print_all(Args&&... args) {
|
|
76
|
+
((std::cout << args << " "), ...); // comma fold
|
|
77
|
+
std::cout << "\n";
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Constrained variadic
|
|
81
|
+
template<std::convertible_to<std::string_view>... Args>
|
|
82
|
+
std::string join(std::string_view sep, Args&&... args) {
|
|
83
|
+
std::string result;
|
|
84
|
+
((result += std::string(args) + std::string(sep)), ...);
|
|
85
|
+
if (!result.empty()) result.resize(result.size() - sep.size());
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## `constexpr` and `consteval`
|
|
91
|
+
|
|
92
|
+
```cpp
|
|
93
|
+
// constexpr — evaluable at compile time or runtime
|
|
94
|
+
constexpr int factorial(int n) {
|
|
95
|
+
if (n <= 1) return 1;
|
|
96
|
+
return n * factorial(n - 1);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
constexpr int ct = factorial(10); // computed at compile time
|
|
100
|
+
int rt = factorial(runtime_val); // computed at runtime
|
|
101
|
+
|
|
102
|
+
// consteval — MUST be evaluated at compile time
|
|
103
|
+
consteval int compile_time_only(int n) {
|
|
104
|
+
return n * n;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
constexpr int x = compile_time_only(5); // OK
|
|
108
|
+
// int y = compile_time_only(runtime_val); // ERROR: not a constant expression
|
|
109
|
+
|
|
110
|
+
// constexpr containers (C++20)
|
|
111
|
+
constexpr auto make_primes() {
|
|
112
|
+
std::array<int, 5> primes{};
|
|
113
|
+
// ... sieve algorithm
|
|
114
|
+
return primes;
|
|
115
|
+
}
|
|
116
|
+
constexpr auto primes = make_primes(); // computed at compile time
|
|
117
|
+
|
|
118
|
+
// if constexpr — compile-time branching
|
|
119
|
+
template<typename T>
|
|
120
|
+
auto to_string(const T& val) {
|
|
121
|
+
if constexpr (std::is_arithmetic_v<T>) {
|
|
122
|
+
return std::to_string(val);
|
|
123
|
+
} else if constexpr (std::is_same_v<T, std::string>) {
|
|
124
|
+
return val;
|
|
125
|
+
} else {
|
|
126
|
+
static_assert(false, "unsupported type");
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## CTAD (Class Template Argument Deduction)
|
|
132
|
+
|
|
133
|
+
```cpp
|
|
134
|
+
// Deduction guides — compiler deduces template arguments
|
|
135
|
+
std::vector v = {1, 2, 3}; // deduces vector<int>
|
|
136
|
+
std::pair p = {"hello", 42}; // deduces pair<const char*, int>
|
|
137
|
+
std::optional o = 3.14; // deduces optional<double>
|
|
138
|
+
|
|
139
|
+
// Custom deduction guide
|
|
140
|
+
template<typename T>
|
|
141
|
+
struct Wrapper {
|
|
142
|
+
T value;
|
|
143
|
+
Wrapper(T v) : value(std::move(v)) {}
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// Deduction guide for string literals
|
|
147
|
+
Wrapper(const char*) -> Wrapper<std::string>;
|
|
148
|
+
|
|
149
|
+
auto w = Wrapper("hello"); // deduces Wrapper<std::string>, not Wrapper<const char*>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## Type Traits and `static_assert`
|
|
153
|
+
|
|
154
|
+
```cpp
|
|
155
|
+
#include <type_traits>
|
|
156
|
+
|
|
157
|
+
// Compile-time type validation
|
|
158
|
+
template<typename T>
|
|
159
|
+
class Container {
|
|
160
|
+
static_assert(std::is_nothrow_move_constructible_v<T>,
|
|
161
|
+
"Container requires nothrow movable types for exception safety");
|
|
162
|
+
static_assert(!std::is_reference_v<T>,
|
|
163
|
+
"Container cannot store references — use reference_wrapper");
|
|
164
|
+
// ...
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
// Conditional types
|
|
168
|
+
template<typename T>
|
|
169
|
+
using storage_type = std::conditional_t<
|
|
170
|
+
sizeof(T) <= sizeof(void*),
|
|
171
|
+
T, // small: store by value
|
|
172
|
+
std::unique_ptr<T> // large: store by pointer
|
|
173
|
+
>;
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## CRTP (Curiously Recurring Template Pattern)
|
|
177
|
+
|
|
178
|
+
Static polymorphism without virtual dispatch overhead.
|
|
179
|
+
|
|
180
|
+
```cpp
|
|
181
|
+
template<typename Derived>
|
|
182
|
+
class Comparable {
|
|
183
|
+
public:
|
|
184
|
+
bool operator!=(const Derived& other) const {
|
|
185
|
+
return !(static_cast<const Derived&>(*this) == other);
|
|
186
|
+
}
|
|
187
|
+
bool operator>(const Derived& other) const {
|
|
188
|
+
return other < static_cast<const Derived&>(*this);
|
|
189
|
+
}
|
|
190
|
+
// Derived must implement operator== and operator<
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
class Temperature : public Comparable<Temperature> {
|
|
194
|
+
double celsius_;
|
|
195
|
+
public:
|
|
196
|
+
explicit Temperature(double c) : celsius_(c) {}
|
|
197
|
+
|
|
198
|
+
bool operator==(const Temperature& other) const {
|
|
199
|
+
return celsius_ == other.celsius_;
|
|
200
|
+
}
|
|
201
|
+
bool operator<(const Temperature& other) const {
|
|
202
|
+
return celsius_ < other.celsius_;
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
```
|
|
@@ -2,42 +2,67 @@
|
|
|
2
2
|
---
|
|
3
3
|
inclusion: manual
|
|
4
4
|
name: "csharp-pro"
|
|
5
|
-
description: "Use for modern C# backend/application engineering with C#
|
|
5
|
+
description: "Use for modern C# backend/application engineering with C# 15 and .NET 11-era production practices."
|
|
6
6
|
license: MIT
|
|
7
7
|
metadata:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
stack: "csharp"
|
|
12
|
-
baseline: "C# 14 / .NET 10"
|
|
8
|
+
author: cubis-foundry
|
|
9
|
+
version: "1.0"
|
|
10
|
+
compatibility: Claude Code, Codex, GitHub Copilot
|
|
13
11
|
---
|
|
14
12
|
|
|
15
13
|
# C# Pro
|
|
16
14
|
|
|
17
|
-
##
|
|
15
|
+
## Purpose
|
|
16
|
+
|
|
17
|
+
Expert-level guidance for modern C# backend and application engineering. Covers async/await patterns with cancellation, nullable reference types, records, dependency injection lifetimes, and production diagnostics using current .NET practices.
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
18
20
|
|
|
19
21
|
- Building APIs, workers, and services in .NET.
|
|
20
22
|
- Refactoring legacy C# into modern, testable architecture.
|
|
21
23
|
- Improving async correctness and operational resilience.
|
|
22
24
|
|
|
23
|
-
##
|
|
25
|
+
## Instructions
|
|
26
|
+
|
|
27
|
+
1. **Confirm target framework and language version** — establish .NET version (.NET 11 LTS, etc.) and C# language version constraints before choosing features.
|
|
28
|
+
|
|
29
|
+
2. **Define clean contracts with modern types** — use `record` for immutable DTOs and value objects. Use `record struct` for small value types to avoid heap allocation. Use primary constructors (C# 12+) for concise DI. Prefer `sealed` on classes not designed for inheritance. Use pattern matching (`is`, `switch` expressions) instead of type-checking cascades.
|
|
30
|
+
|
|
31
|
+
3. **Enable nullable reference types project-wide** — set `<Nullable>enable</Nullable>` and treat warnings as errors. Use null-forgiving (`!`) only at boundaries with external proof (deserialization, DI resolution). Use `required` modifier on properties that must be set at construction. Use `[NotNullWhen]` and `[MaybeNullWhen]` on bool-returning try-pattern methods.
|
|
32
|
+
|
|
33
|
+
4. **Implement async-first I/O with CancellationToken propagation** — every public async method takes `CancellationToken` as its last parameter. Use `ConfigureAwait(false)` in library code. Use `ValueTask<T>` when the common path completes synchronously. Use `await using` for `IAsyncDisposable` resources. Do not use `.Result`, `.Wait()`, or `.GetAwaiter().GetResult()` in request paths because it causes threadpool starvation and deadlocks.
|
|
34
|
+
|
|
35
|
+
5. **Wire dependency injection with explicit lifetimes** — `Transient` for stateless, `Scoped` for per-request, `Singleton` for shared. Do not inject `Scoped` services into `Singleton` because it causes captive dependency and stale data. Use `IOptions<T>` / `IOptionsSnapshot<T>` / `IOptionsMonitor<T>` for configuration with proper reload semantics. Use `IServiceScopeFactory` when a Singleton needs to create scoped work.
|
|
36
|
+
|
|
37
|
+
6. **Handle errors consistently at boundaries** — use `IExceptionHandler` (ASP.NET 8+) or middleware for error-to-response mapping. Throw domain exceptions for business rule violations; use `Result<T>` patterns for expected failures. Use `ActivitySource` and `Activity` for distributed tracing. Log exceptions at the boundary, not at every catch. Do not catch `Exception` in deep code without rethrowing because it swallows unexpected errors.
|
|
38
|
+
|
|
39
|
+
7. **Observe and diagnose** — use structured logging (Serilog, Microsoft.Extensions.Logging) with request/job correlation IDs. Use `dotnet-counters`, `dotnet-trace`, and `dotnet-dump` for runtime diagnostics. Do not expose stack traces in production.
|
|
40
|
+
|
|
41
|
+
8. **Optimize with measurement** — use `dotnet-trace` or BenchmarkDotNet to identify allocation hotspots before changing data structures. Use `Span<T>`, `ReadOnlySpan<T>`, and `Memory<T>` for zero-copy slicing in hot paths. Use `ArrayPool<T>.Shared` over repeated allocations. Use `FrozenDictionary` / `FrozenSet` (.NET 8+) for read-heavy lookup tables.
|
|
42
|
+
|
|
43
|
+
9. **Validate with tests and analyzers** — use Roslyn analyzers and `dotnet test`. Bound retries and timeouts explicitly for network and queue work. Do not build fat controllers with mixed business logic and persistence because it resists testing. Do not use `string` concatenation in loops because `StringBuilder` or interpolated string handlers are more efficient. Do not ignore `CancellationToken` in long-running operations because it makes services unresponsive to shutdown. Do not use global static mutable state in multi-request services because it creates race conditions — use DI with proper lifetimes.
|
|
44
|
+
|
|
45
|
+
## Output Format
|
|
46
|
+
|
|
47
|
+
Produces C# code using records, nullable reference types, async/await with cancellation, and explicit DI lifetimes. Includes structured error handling and pattern matching where applicable.
|
|
48
|
+
|
|
49
|
+
## References
|
|
24
50
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
51
|
+
| File | Load when |
|
|
52
|
+
| --------------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| `references/operational-baseline.md` | You need current async, logging, testing, and deployment guardrails for C#/.NET services. |
|
|
54
|
+
| `references/async-await-patterns.md` | You need async/await patterns, ValueTask usage, cancellation design, or threadpool management. |
|
|
55
|
+
| `references/modern-csharp-features.md` | You need patterns for records, pattern matching, primary constructors, or collection expressions. |
|
|
56
|
+
| `references/dependency-injection-patterns.md` | You need DI lifetime management, keyed services, option patterns, or service resolution strategies. |
|
|
57
|
+
| `references/testing-and-analyzers.md` | You need testing patterns, analyzer configuration, BenchmarkDotNet setup, or CI validation. |
|
|
29
58
|
|
|
30
|
-
##
|
|
59
|
+
## Scripts
|
|
31
60
|
|
|
32
|
-
|
|
33
|
-
- Use `async`/`await` with `CancellationToken` in public async APIs.
|
|
34
|
-
- Keep exception handling consistent and observable.
|
|
35
|
-
- Use dependency injection with explicit lifetimes.
|
|
36
|
-
- Keep API contracts versioned and backward-compatible.
|
|
61
|
+
No helper scripts are required for this skill right now. Keep execution in `SKILL.md` and `references/` unless repeated automation becomes necessary.
|
|
37
62
|
|
|
38
|
-
##
|
|
63
|
+
## Examples
|
|
39
64
|
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
65
|
+
- "Refactor this controller to use async/await with CancellationToken propagation and proper DI lifetime management."
|
|
66
|
+
- "Enable nullable reference types in this project and fix all the null-safety warnings with appropriate patterns."
|
|
67
|
+
- "Design the error handling middleware for this ASP.NET API using IExceptionHandler and Result<T> patterns."
|
|
43
68
|
````
|
|
@@ -1,40 +1,65 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: "csharp-pro"
|
|
3
|
-
description: "Use for modern C# backend/application engineering with C#
|
|
3
|
+
description: "Use for modern C# backend/application engineering with C# 15 and .NET 11-era production practices."
|
|
4
4
|
license: MIT
|
|
5
5
|
metadata:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
stack: "csharp"
|
|
10
|
-
baseline: "C# 14 / .NET 10"
|
|
6
|
+
author: cubis-foundry
|
|
7
|
+
version: "1.0"
|
|
8
|
+
compatibility: Claude Code, Codex, GitHub Copilot
|
|
11
9
|
---
|
|
12
10
|
|
|
13
11
|
# C# Pro
|
|
14
12
|
|
|
15
|
-
##
|
|
13
|
+
## Purpose
|
|
14
|
+
|
|
15
|
+
Expert-level guidance for modern C# backend and application engineering. Covers async/await patterns with cancellation, nullable reference types, records, dependency injection lifetimes, and production diagnostics using current .NET practices.
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
16
18
|
|
|
17
19
|
- Building APIs, workers, and services in .NET.
|
|
18
20
|
- Refactoring legacy C# into modern, testable architecture.
|
|
19
21
|
- Improving async correctness and operational resilience.
|
|
20
22
|
|
|
21
|
-
##
|
|
23
|
+
## Instructions
|
|
24
|
+
|
|
25
|
+
1. **Confirm target framework and language version** — establish .NET version (.NET 11 LTS, etc.) and C# language version constraints before choosing features.
|
|
26
|
+
|
|
27
|
+
2. **Define clean contracts with modern types** — use `record` for immutable DTOs and value objects. Use `record struct` for small value types to avoid heap allocation. Use primary constructors (C# 12+) for concise DI. Prefer `sealed` on classes not designed for inheritance. Use pattern matching (`is`, `switch` expressions) instead of type-checking cascades.
|
|
28
|
+
|
|
29
|
+
3. **Enable nullable reference types project-wide** — set `<Nullable>enable</Nullable>` and treat warnings as errors. Use null-forgiving (`!`) only at boundaries with external proof (deserialization, DI resolution). Use `required` modifier on properties that must be set at construction. Use `[NotNullWhen]` and `[MaybeNullWhen]` on bool-returning try-pattern methods.
|
|
30
|
+
|
|
31
|
+
4. **Implement async-first I/O with CancellationToken propagation** — every public async method takes `CancellationToken` as its last parameter. Use `ConfigureAwait(false)` in library code. Use `ValueTask<T>` when the common path completes synchronously. Use `await using` for `IAsyncDisposable` resources. Do not use `.Result`, `.Wait()`, or `.GetAwaiter().GetResult()` in request paths because it causes threadpool starvation and deadlocks.
|
|
32
|
+
|
|
33
|
+
5. **Wire dependency injection with explicit lifetimes** — `Transient` for stateless, `Scoped` for per-request, `Singleton` for shared. Do not inject `Scoped` services into `Singleton` because it causes captive dependency and stale data. Use `IOptions<T>` / `IOptionsSnapshot<T>` / `IOptionsMonitor<T>` for configuration with proper reload semantics. Use `IServiceScopeFactory` when a Singleton needs to create scoped work.
|
|
34
|
+
|
|
35
|
+
6. **Handle errors consistently at boundaries** — use `IExceptionHandler` (ASP.NET 8+) or middleware for error-to-response mapping. Throw domain exceptions for business rule violations; use `Result<T>` patterns for expected failures. Use `ActivitySource` and `Activity` for distributed tracing. Log exceptions at the boundary, not at every catch. Do not catch `Exception` in deep code without rethrowing because it swallows unexpected errors.
|
|
36
|
+
|
|
37
|
+
7. **Observe and diagnose** — use structured logging (Serilog, Microsoft.Extensions.Logging) with request/job correlation IDs. Use `dotnet-counters`, `dotnet-trace`, and `dotnet-dump` for runtime diagnostics. Do not expose stack traces in production.
|
|
38
|
+
|
|
39
|
+
8. **Optimize with measurement** — use `dotnet-trace` or BenchmarkDotNet to identify allocation hotspots before changing data structures. Use `Span<T>`, `ReadOnlySpan<T>`, and `Memory<T>` for zero-copy slicing in hot paths. Use `ArrayPool<T>.Shared` over repeated allocations. Use `FrozenDictionary` / `FrozenSet` (.NET 8+) for read-heavy lookup tables.
|
|
40
|
+
|
|
41
|
+
9. **Validate with tests and analyzers** — use Roslyn analyzers and `dotnet test`. Bound retries and timeouts explicitly for network and queue work. Do not build fat controllers with mixed business logic and persistence because it resists testing. Do not use `string` concatenation in loops because `StringBuilder` or interpolated string handlers are more efficient. Do not ignore `CancellationToken` in long-running operations because it makes services unresponsive to shutdown. Do not use global static mutable state in multi-request services because it creates race conditions — use DI with proper lifetimes.
|
|
42
|
+
|
|
43
|
+
## Output Format
|
|
44
|
+
|
|
45
|
+
Produces C# code using records, nullable reference types, async/await with cancellation, and explicit DI lifetimes. Includes structured error handling and pattern matching where applicable.
|
|
46
|
+
|
|
47
|
+
## References
|
|
22
48
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
49
|
+
| File | Load when |
|
|
50
|
+
| --------------------------------------------- | --------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| `references/operational-baseline.md` | You need current async, logging, testing, and deployment guardrails for C#/.NET services. |
|
|
52
|
+
| `references/async-await-patterns.md` | You need async/await patterns, ValueTask usage, cancellation design, or threadpool management. |
|
|
53
|
+
| `references/modern-csharp-features.md` | You need patterns for records, pattern matching, primary constructors, or collection expressions. |
|
|
54
|
+
| `references/dependency-injection-patterns.md` | You need DI lifetime management, keyed services, option patterns, or service resolution strategies. |
|
|
55
|
+
| `references/testing-and-analyzers.md` | You need testing patterns, analyzer configuration, BenchmarkDotNet setup, or CI validation. |
|
|
27
56
|
|
|
28
|
-
##
|
|
57
|
+
## Scripts
|
|
29
58
|
|
|
30
|
-
|
|
31
|
-
- Use `async`/`await` with `CancellationToken` in public async APIs.
|
|
32
|
-
- Keep exception handling consistent and observable.
|
|
33
|
-
- Use dependency injection with explicit lifetimes.
|
|
34
|
-
- Keep API contracts versioned and backward-compatible.
|
|
59
|
+
No helper scripts are required for this skill right now. Keep execution in `SKILL.md` and `references/` unless repeated automation becomes necessary.
|
|
35
60
|
|
|
36
|
-
##
|
|
61
|
+
## Examples
|
|
37
62
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
63
|
+
- "Refactor this controller to use async/await with CancellationToken propagation and proper DI lifetime management."
|
|
64
|
+
- "Enable nullable reference types in this project and fix all the null-safety warnings with appropriate patterns."
|
|
65
|
+
- "Design the error handling middleware for this ASP.NET API using IExceptionHandler and Result<T> patterns."
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
````markdown
|
|
2
|
+
---
|
|
3
|
+
inclusion: manual
|
|
4
|
+
name: "dart-pro"
|
|
5
|
+
description: "Use for modern Dart engineering across Flutter, server, and CLI code with Dart 3.11-era language features, package hygiene, isolates, and testing discipline."
|
|
6
|
+
license: MIT
|
|
7
|
+
metadata:
|
|
8
|
+
author: cubis-foundry
|
|
9
|
+
version: "2.0"
|
|
10
|
+
compatibility: Claude Code, Codex, GitHub Copilot
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Dart Pro
|
|
14
|
+
|
|
15
|
+
## Purpose
|
|
16
|
+
|
|
17
|
+
Expert-level guidance for modern Dart development across Flutter app logic, server applications, and CLI tooling. Covers null safety, sealed classes with pattern matching, async and isolate patterns, package hygiene, and testing discipline using current Dart language features.
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
|
|
21
|
+
- Designing Dart libraries, Flutter app logic, or Dart CLI tooling.
|
|
22
|
+
- Refactoring null-safety, sealed classes, records, or pattern matching.
|
|
23
|
+
- Improving package structure, async correctness, and testability.
|
|
24
|
+
|
|
25
|
+
## Instructions
|
|
26
|
+
|
|
27
|
+
1. **Confirm runtime context** — identify whether the code targets Flutter UI, server, or CLI. This determines available APIs, isolate patterns, and testing approaches.
|
|
28
|
+
|
|
29
|
+
2. **Keep null safety and type intent explicit** — prefer non-nullable types by default. Use `?` only when null is a valid domain value. Use `late` only when initialization is guaranteed before access. Target sound null safety with no `// ignore: null_check` suppressions without justification. Do not use `!` (null assertion) in production code without a preceding null check because it crashes at runtime.
|
|
30
|
+
|
|
31
|
+
3. **Use sealed models, records, and pattern matching** — use sealed classes for closed type hierarchies with exhaustive `switch` that catches missing cases at compile time. Use records `(int, String)` for lightweight grouped returns. Use `switch` expressions with pattern matching for state machines. Prefer destructuring in `if-case` and `switch` over manual `is` checks and casts.
|
|
32
|
+
|
|
33
|
+
4. **Design async flows with proper lifecycle** — use `async`/`await` for I/O-bound work. Keep `Future` chains flat. Use `Stream` for event-driven data with `StreamController.broadcast()` only when multiple listeners are needed. Cancel subscriptions and close controllers in `dispose()` to prevent memory leaks. Do not block the main isolate with synchronous I/O or heavy computation because it freezes the UI.
|
|
34
|
+
|
|
35
|
+
5. **Offload compute to isolates when needed** — use `Isolate.run()` or `compute()` in Flutter for CPU-heavy work. Keep the main isolate responsive for UI and event handling.
|
|
36
|
+
|
|
37
|
+
6. **Maintain package hygiene** — keep `pubspec.yaml` dependencies minimal. Use `dart pub outdated` to identify stale dependencies. Export only the public API from `lib/src/` via a barrel file. Pin SDK constraint to the minimum required version. Keep `pubspec.lock` in version control for applications (not for libraries). Do not import implementation files from `lib/src/` directly in other packages because it breaks encapsulation.
|
|
38
|
+
|
|
39
|
+
7. **Run analysis before committing** — run `dart analyze` with zero warnings. Treat analyzer warnings as defects. Use `dart format` for consistent style. Do not override formatter rules per-file. Do not ignore analyzer warnings with `// ignore:` comments without a justification comment because it hides real defects.
|
|
40
|
+
|
|
41
|
+
8. **Test business logic independently** — use `package:test` for unit tests, `package:mocktail` or `package:mockito` for mocking. Test logic in plain Dart classes independent of Flutter widgets. Run tests with `--coverage` and review uncovered branches. Do not mix business logic into widget `build()` methods because it prevents isolated testing.
|
|
42
|
+
|
|
43
|
+
9. **Do not use `dynamic` as a type** because it disables all static checking — use `Object` or generics instead.
|
|
44
|
+
|
|
45
|
+
## Output Format
|
|
46
|
+
|
|
47
|
+
Produces Dart code with sound null safety, sealed class hierarchies, pattern matching, and clean async patterns. Includes barrel exports and analyzer-clean output with proper package structure.
|
|
48
|
+
|
|
49
|
+
## References
|
|
50
|
+
|
|
51
|
+
| File | Load when |
|
|
52
|
+
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
53
|
+
| `references/null-safety-and-async-patterns.md` | Null safety migration, sealed class patterns, async/isolate architecture, or stream lifecycle management is needed. |
|
|
54
|
+
| `references/sealed-records-patterns.md` | You need sealed class hierarchies, records, destructuring, or exhaustive switch patterns for state modeling. |
|
|
55
|
+
| `references/isolate-and-concurrency.md` | You need isolate architecture, compute offload, port communication, or Flutter isolate integration patterns. |
|
|
56
|
+
| `references/package-structure-and-linting.md` | You need pub workspace layout, barrel exports, analysis_options rules, or dependency audit workflow. |
|
|
57
|
+
| `references/testing-and-mocking.md` | You need test patterns with mockito/mocktail, widget testing, golden tests, or coverage-driven CI. |
|
|
58
|
+
|
|
59
|
+
## Scripts
|
|
60
|
+
|
|
61
|
+
No helper scripts are required for this skill right now. Keep execution in `SKILL.md` and `references/` unless repeated automation becomes necessary.
|
|
62
|
+
|
|
63
|
+
## Examples
|
|
64
|
+
|
|
65
|
+
- "Refactor this state management code to use sealed classes with exhaustive pattern matching instead of enum flags."
|
|
66
|
+
- "Design the isolate architecture for this image processing pipeline in a Flutter app."
|
|
67
|
+
- "Set up the package structure for this shared Dart library with proper barrel exports and analysis_options."
|
|
68
|
+
````
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: "dart-pro"
|
|
3
|
+
description: "Use for modern Dart engineering across Flutter, server, and CLI code with Dart 3.11-era language features, package hygiene, isolates, and testing discipline."
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: cubis-foundry
|
|
7
|
+
version: "2.0"
|
|
8
|
+
compatibility: Claude Code, Codex, GitHub Copilot
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Dart Pro
|
|
12
|
+
|
|
13
|
+
## Purpose
|
|
14
|
+
|
|
15
|
+
Expert-level guidance for modern Dart development across Flutter app logic, server applications, and CLI tooling. Covers null safety, sealed classes with pattern matching, async and isolate patterns, package hygiene, and testing discipline using current Dart language features.
|
|
16
|
+
|
|
17
|
+
## When to Use
|
|
18
|
+
|
|
19
|
+
- Designing Dart libraries, Flutter app logic, or Dart CLI tooling.
|
|
20
|
+
- Refactoring null-safety, sealed classes, records, or pattern matching.
|
|
21
|
+
- Improving package structure, async correctness, and testability.
|
|
22
|
+
|
|
23
|
+
## Instructions
|
|
24
|
+
|
|
25
|
+
1. **Confirm runtime context** — identify whether the code targets Flutter UI, server, or CLI. This determines available APIs, isolate patterns, and testing approaches.
|
|
26
|
+
|
|
27
|
+
2. **Keep null safety and type intent explicit** — prefer non-nullable types by default. Use `?` only when null is a valid domain value. Use `late` only when initialization is guaranteed before access. Target sound null safety with no `// ignore: null_check` suppressions without justification. Do not use `!` (null assertion) in production code without a preceding null check because it crashes at runtime.
|
|
28
|
+
|
|
29
|
+
3. **Use sealed models, records, and pattern matching** — use sealed classes for closed type hierarchies with exhaustive `switch` that catches missing cases at compile time. Use records `(int, String)` for lightweight grouped returns. Use `switch` expressions with pattern matching for state machines. Prefer destructuring in `if-case` and `switch` over manual `is` checks and casts.
|
|
30
|
+
|
|
31
|
+
4. **Design async flows with proper lifecycle** — use `async`/`await` for I/O-bound work. Keep `Future` chains flat. Use `Stream` for event-driven data with `StreamController.broadcast()` only when multiple listeners are needed. Cancel subscriptions and close controllers in `dispose()` to prevent memory leaks. Do not block the main isolate with synchronous I/O or heavy computation because it freezes the UI.
|
|
32
|
+
|
|
33
|
+
5. **Offload compute to isolates when needed** — use `Isolate.run()` or `compute()` in Flutter for CPU-heavy work. Keep the main isolate responsive for UI and event handling.
|
|
34
|
+
|
|
35
|
+
6. **Maintain package hygiene** — keep `pubspec.yaml` dependencies minimal. Use `dart pub outdated` to identify stale dependencies. Export only the public API from `lib/src/` via a barrel file. Pin SDK constraint to the minimum required version. Keep `pubspec.lock` in version control for applications (not for libraries). Do not import implementation files from `lib/src/` directly in other packages because it breaks encapsulation.
|
|
36
|
+
|
|
37
|
+
7. **Run analysis before committing** — run `dart analyze` with zero warnings. Treat analyzer warnings as defects. Use `dart format` for consistent style. Do not override formatter rules per-file. Do not ignore analyzer warnings with `// ignore:` comments without a justification comment because it hides real defects.
|
|
38
|
+
|
|
39
|
+
8. **Test business logic independently** — use `package:test` for unit tests, `package:mocktail` or `package:mockito` for mocking. Test logic in plain Dart classes independent of Flutter widgets. Run tests with `--coverage` and review uncovered branches. Do not mix business logic into widget `build()` methods because it prevents isolated testing.
|
|
40
|
+
|
|
41
|
+
9. **Do not use `dynamic` as a type** because it disables all static checking — use `Object` or generics instead.
|
|
42
|
+
|
|
43
|
+
## Output Format
|
|
44
|
+
|
|
45
|
+
Produces Dart code with sound null safety, sealed class hierarchies, pattern matching, and clean async patterns. Includes barrel exports and analyzer-clean output with proper package structure.
|
|
46
|
+
|
|
47
|
+
## References
|
|
48
|
+
|
|
49
|
+
| File | Load when |
|
|
50
|
+
| ---------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
51
|
+
| `references/null-safety-and-async-patterns.md` | Null safety migration, sealed class patterns, async/isolate architecture, or stream lifecycle management is needed. |
|
|
52
|
+
| `references/sealed-records-patterns.md` | You need sealed class hierarchies, records, destructuring, or exhaustive switch patterns for state modeling. |
|
|
53
|
+
| `references/isolate-and-concurrency.md` | You need isolate architecture, compute offload, port communication, or Flutter isolate integration patterns. |
|
|
54
|
+
| `references/package-structure-and-linting.md` | You need pub workspace layout, barrel exports, analysis_options rules, or dependency audit workflow. |
|
|
55
|
+
| `references/testing-and-mocking.md` | You need test patterns with mockito/mocktail, widget testing, golden tests, or coverage-driven CI. |
|
|
56
|
+
|
|
57
|
+
## Scripts
|
|
58
|
+
|
|
59
|
+
No helper scripts are required for this skill right now. Keep execution in `SKILL.md` and `references/` unless repeated automation becomes necessary.
|
|
60
|
+
|
|
61
|
+
## Examples
|
|
62
|
+
|
|
63
|
+
- "Refactor this state management code to use sealed classes with exhaustive pattern matching instead of enum flags."
|
|
64
|
+
- "Design the isolate architecture for this image processing pipeline in a Flutter app."
|
|
65
|
+
- "Set up the package structure for this shared Dart library with proper barrel exports and analysis_options."
|