claude-code-pilot 3.1.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (110) hide show
  1. package/README.md +11 -11
  2. package/bin/install.js +20 -2
  3. package/manifest.json +5 -1
  4. package/package.json +18 -6
  5. package/src/agents/a11y-architect.md +141 -0
  6. package/src/agents/code-architect.md +71 -0
  7. package/src/agents/code-explorer.md +69 -0
  8. package/src/agents/code-simplifier.md +47 -0
  9. package/src/agents/comment-analyzer.md +45 -0
  10. package/src/agents/csharp-reviewer.md +101 -0
  11. package/src/agents/dart-build-resolver.md +201 -0
  12. package/src/agents/pr-test-analyzer.md +45 -0
  13. package/src/agents/silent-failure-hunter.md +50 -0
  14. package/src/agents/type-design-analyzer.md +41 -0
  15. package/src/available-rules/README.md +3 -1
  16. package/src/available-rules/dart/coding-style.md +159 -0
  17. package/src/available-rules/dart/hooks.md +66 -0
  18. package/src/available-rules/dart/patterns.md +261 -0
  19. package/src/available-rules/dart/security.md +135 -0
  20. package/src/available-rules/dart/testing.md +215 -0
  21. package/src/available-rules/web/coding-style.md +105 -0
  22. package/src/available-rules/web/design-quality.md +72 -0
  23. package/src/available-rules/web/hooks.md +129 -0
  24. package/src/available-rules/web/patterns.md +88 -0
  25. package/src/available-rules/web/performance.md +73 -0
  26. package/src/available-rules/web/security.md +66 -0
  27. package/src/available-rules/web/testing.md +64 -0
  28. package/src/commands/ccp/ai-integration-phase.md +36 -0
  29. package/src/commands/ccp/audit-fix.md +33 -0
  30. package/src/commands/ccp/code-review-fix.md +52 -0
  31. package/src/commands/ccp/eval-review.md +32 -0
  32. package/src/commands/ccp/extract_learnings.md +22 -0
  33. package/src/commands/ccp/import.md +37 -0
  34. package/src/commands/ccp/ingest-docs.md +42 -0
  35. package/src/commands/ccp/intel.md +179 -0
  36. package/src/commands/ccp/plan-review-convergence.md +58 -0
  37. package/src/commands/ccp/scan.md +26 -0
  38. package/src/commands/ccp/sketch-wrap-up.md +31 -0
  39. package/src/commands/ccp/sketch.md +54 -0
  40. package/src/commands/ccp/spec-phase.md +62 -0
  41. package/src/commands/ccp/spike-wrap-up.md +31 -0
  42. package/src/commands/ccp/spike.md +51 -0
  43. package/src/commands/ccp/ultraplan-phase.md +33 -0
  44. package/src/hooks/ccp-read-injection-scanner.js +152 -0
  45. package/src/hooks/kit-check-update.js +59 -7
  46. package/src/hooks/run-with-flags-shell.sh +1 -0
  47. package/src/hooks/run-with-flags.js +48 -1
  48. package/src/hooks/session-end.js +88 -1
  49. package/src/lib/hook-flags.js +14 -0
  50. package/src/pilot/references/agent-contracts.md +79 -0
  51. package/src/pilot/references/ai-evals.md +156 -0
  52. package/src/pilot/references/ai-frameworks.md +186 -0
  53. package/src/pilot/references/doc-conflict-engine.md +91 -0
  54. package/src/pilot/references/gate-prompts.md +100 -0
  55. package/src/pilot/references/gates.md +70 -0
  56. package/src/pilot/references/mandatory-initial-read.md +2 -0
  57. package/src/pilot/references/project-skills-discovery.md +19 -0
  58. package/src/pilot/references/revision-loop.md +97 -0
  59. package/src/pilot/references/sketch-interactivity.md +41 -0
  60. package/src/pilot/references/sketch-theme-system.md +94 -0
  61. package/src/pilot/references/sketch-tooling.md +45 -0
  62. package/src/pilot/references/sketch-variant-patterns.md +81 -0
  63. package/src/pilot/references/thinking-models-debug.md +44 -0
  64. package/src/pilot/references/thinking-models-execution.md +50 -0
  65. package/src/pilot/references/thinking-models-planning.md +62 -0
  66. package/src/pilot/references/thinking-models-research.md +50 -0
  67. package/src/pilot/references/thinking-models-verification.md +55 -0
  68. package/src/pilot/templates/AI-SPEC.md +246 -0
  69. package/src/pilot/templates/spec.md +307 -0
  70. package/src/pilot/workflows/ai-integration-phase.md +284 -0
  71. package/src/pilot/workflows/audit-fix.md +175 -0
  72. package/src/pilot/workflows/code-review-fix.md +497 -0
  73. package/src/pilot/workflows/eval-review.md +155 -0
  74. package/src/pilot/workflows/extract_learnings.md +242 -0
  75. package/src/pilot/workflows/import.md +246 -0
  76. package/src/pilot/workflows/ingest-docs.md +328 -0
  77. package/src/pilot/workflows/plan-review-convergence.md +329 -0
  78. package/src/pilot/workflows/scan.md +102 -0
  79. package/src/pilot/workflows/sketch-wrap-up.md +285 -0
  80. package/src/pilot/workflows/sketch.md +360 -0
  81. package/src/pilot/workflows/spec-phase.md +262 -0
  82. package/src/pilot/workflows/spike-wrap-up.md +306 -0
  83. package/src/pilot/workflows/spike.md +452 -0
  84. package/src/pilot/workflows/ultraplan-phase.md +189 -0
  85. package/src/skills/accessibility/SKILL.md +146 -0
  86. package/src/skills/agent-eval/SKILL.md +145 -0
  87. package/src/skills/agent-introspection-debugging/SKILL.md +153 -0
  88. package/src/skills/android-clean-architecture/SKILL.md +339 -0
  89. package/src/skills/api-connector-builder/SKILL.md +120 -0
  90. package/src/skills/code-tour/SKILL.md +236 -0
  91. package/src/skills/compose-multiplatform-patterns/SKILL.md +299 -0
  92. package/src/skills/csharp-testing/SKILL.md +321 -0
  93. package/src/skills/dart-flutter-patterns/SKILL.md +563 -0
  94. package/src/skills/dashboard-builder/SKILL.md +108 -0
  95. package/src/skills/dotnet-patterns/SKILL.md +321 -0
  96. package/src/skills/frontend-design/SKILL.md +145 -0
  97. package/src/skills/frontend-slides/SKILL.md +184 -0
  98. package/src/skills/frontend-slides/STYLE_PRESETS.md +330 -0
  99. package/src/skills/gateguard/SKILL.md +121 -0
  100. package/src/skills/github-ops/SKILL.md +144 -0
  101. package/src/skills/hookify-rules/SKILL.md +128 -0
  102. package/src/skills/knowledge-ops/SKILL.md +154 -0
  103. package/src/skills/liquid-glass-design/SKILL.md +279 -0
  104. package/src/skills/nestjs-patterns/SKILL.md +230 -0
  105. package/src/skills/security-bounty-hunter/SKILL.md +99 -0
  106. package/src/skills/swift-actor-persistence/SKILL.md +143 -0
  107. package/src/skills/swift-protocol-di-testing/SKILL.md +190 -0
  108. package/src/skills/swiftui-patterns/SKILL.md +259 -0
  109. package/src/skills/terminal-ops/SKILL.md +109 -0
  110. package/src/skills/ui-demo/SKILL.md +465 -0
@@ -0,0 +1,201 @@
1
+ ---
2
+ name: dart-build-resolver
3
+ description: Dart/Flutter build, analysis, and dependency error resolution specialist. Fixes `dart analyze` errors, Flutter compilation failures, pub dependency conflicts, and build_runner issues with minimal, surgical changes. Use when Dart/Flutter builds fail.
4
+ tools: ["Read", "Write", "Edit", "Bash", "Grep", "Glob"]
5
+ model: sonnet
6
+ ---
7
+
8
+ # Dart/Flutter Build Error Resolver
9
+
10
+ You are an expert Dart/Flutter build error resolution specialist. Your mission is to fix Dart analyzer errors, Flutter compilation issues, pub dependency conflicts, and build_runner failures with **minimal, surgical changes**.
11
+
12
+ ## Core Responsibilities
13
+
14
+ 1. Diagnose `dart analyze` and `flutter analyze` errors
15
+ 2. Fix Dart type errors, null safety violations, and missing imports
16
+ 3. Resolve `pubspec.yaml` dependency conflicts and version constraints
17
+ 4. Fix `build_runner` code generation failures
18
+ 5. Handle Flutter-specific build errors (Android Gradle, iOS CocoaPods, web)
19
+
20
+ ## Diagnostic Commands
21
+
22
+ Run these in order:
23
+
24
+ ```bash
25
+ # Check Dart/Flutter analysis errors
26
+ flutter analyze 2>&1
27
+ # or for pure Dart projects
28
+ dart analyze 2>&1
29
+
30
+ # Check pub dependency resolution
31
+ flutter pub get 2>&1
32
+
33
+ # Check if code generation is stale
34
+ dart run build_runner build --delete-conflicting-outputs 2>&1
35
+
36
+ # Flutter build for target platform
37
+ flutter build apk 2>&1 # Android
38
+ flutter build ipa --no-codesign 2>&1 # iOS (CI without signing)
39
+ flutter build web 2>&1 # Web
40
+ ```
41
+
42
+ ## Resolution Workflow
43
+
44
+ ```text
45
+ 1. flutter analyze -> Parse error messages
46
+ 2. Read affected file -> Understand context
47
+ 3. Apply minimal fix -> Only what's needed
48
+ 4. flutter analyze -> Verify fix
49
+ 5. flutter test -> Ensure nothing broke
50
+ ```
51
+
52
+ ## Common Fix Patterns
53
+
54
+ | Error | Cause | Fix |
55
+ |-------|-------|-----|
56
+ | `The name 'X' isn't defined` | Missing import or typo | Add correct `import` or fix name |
57
+ | `A value of type 'X?' can't be assigned to type 'X'` | Null safety — nullable not handled | Add `!`, `?? default`, or null check |
58
+ | `The argument type 'X' can't be assigned to 'Y'` | Type mismatch | Fix type, add explicit cast, or correct API call |
59
+ | `Non-nullable instance field 'x' must be initialized` | Missing initializer | Add initializer, mark `late`, or make nullable |
60
+ | `The method 'X' isn't defined for type 'Y'` | Wrong type or wrong import | Check type and imports |
61
+ | `'await' applied to non-Future` | Awaiting a non-async value | Remove `await` or make function async |
62
+ | `Missing concrete implementation of 'X'` | Abstract interface not fully implemented | Add missing method implementations |
63
+ | `The class 'X' doesn't implement 'Y'` | Missing `implements` or missing method | Add method or fix class signature |
64
+ | `Because X depends on Y >=A and Z depends on Y <B, version solving failed` | Pub version conflict | Adjust version constraints or add `dependency_overrides` |
65
+ | `Could not find a file named "pubspec.yaml"` | Wrong working directory | Run from project root |
66
+ | `build_runner: No actions were run` | No changes to build_runner inputs | Force rebuild with `--delete-conflicting-outputs` |
67
+ | `Part of directive found, but 'X' expected` | Stale generated file | Delete `.g.dart` file and re-run build_runner |
68
+
69
+ ## Pub Dependency Troubleshooting
70
+
71
+ ```bash
72
+ # Show full dependency tree
73
+ flutter pub deps
74
+
75
+ # Check why a specific package version was chosen
76
+ flutter pub deps --style=compact | grep <package>
77
+
78
+ # Upgrade packages to latest compatible versions
79
+ flutter pub upgrade
80
+
81
+ # Upgrade specific package
82
+ flutter pub upgrade <package_name>
83
+
84
+ # Clear pub cache if metadata is corrupted
85
+ flutter pub cache repair
86
+
87
+ # Verify pubspec.lock is consistent
88
+ flutter pub get --enforce-lockfile
89
+ ```
90
+
91
+ ## Null Safety Fix Patterns
92
+
93
+ ```dart
94
+ // Error: A value of type 'String?' can't be assigned to type 'String'
95
+ // BAD — force unwrap
96
+ final name = user.name!;
97
+
98
+ // GOOD — provide fallback
99
+ final name = user.name ?? 'Unknown';
100
+
101
+ // GOOD — guard and return early
102
+ if (user.name == null) return;
103
+ final name = user.name!; // safe after null check
104
+
105
+ // GOOD — Dart 3 pattern matching
106
+ final name = switch (user.name) {
107
+ final n? => n,
108
+ null => 'Unknown',
109
+ };
110
+ ```
111
+
112
+ ## Type Error Fix Patterns
113
+
114
+ ```dart
115
+ // Error: The argument type 'List<dynamic>' can't be assigned to 'List<String>'
116
+ // BAD
117
+ final ids = jsonList; // inferred as List<dynamic>
118
+
119
+ // GOOD
120
+ final ids = List<String>.from(jsonList);
121
+ // or
122
+ final ids = (jsonList as List).cast<String>();
123
+ ```
124
+
125
+ ## build_runner Troubleshooting
126
+
127
+ ```bash
128
+ # Clean and regenerate all files
129
+ dart run build_runner clean
130
+ dart run build_runner build --delete-conflicting-outputs
131
+
132
+ # Watch mode for development
133
+ dart run build_runner watch --delete-conflicting-outputs
134
+
135
+ # Check for missing build_runner dependencies in pubspec.yaml
136
+ # Required: build_runner, json_serializable / freezed / riverpod_generator (as dev_dependencies)
137
+ ```
138
+
139
+ ## Android Build Troubleshooting
140
+
141
+ ```bash
142
+ # Clean Android build cache
143
+ cd android && ./gradlew clean && cd ..
144
+
145
+ # Invalidate Flutter tool cache
146
+ flutter clean
147
+
148
+ # Rebuild
149
+ flutter pub get && flutter build apk
150
+
151
+ # Check Gradle/JDK version compatibility
152
+ cd android && ./gradlew --version
153
+ ```
154
+
155
+ ## iOS Build Troubleshooting
156
+
157
+ ```bash
158
+ # Update CocoaPods
159
+ cd ios && pod install --repo-update && cd ..
160
+
161
+ # Clean iOS build
162
+ flutter clean && cd ios && pod deintegrate && pod install && cd ..
163
+
164
+ # Check for platform version mismatches in Podfile
165
+ # Ensure ios platform version >= minimum required by all pods
166
+ ```
167
+
168
+ ## Key Principles
169
+
170
+ - **Surgical fixes only** — don't refactor, just fix the error
171
+ - **Never** add `// ignore:` suppressions without approval
172
+ - **Never** use `dynamic` to silence type errors
173
+ - **Always** run `flutter analyze` after each fix to verify
174
+ - Fix root cause over suppressing symptoms
175
+ - Prefer null-safe patterns over bang operators (`!`)
176
+
177
+ ## Stop Conditions
178
+
179
+ Stop and report if:
180
+ - Same error persists after 3 fix attempts
181
+ - Fix introduces more errors than it resolves
182
+ - Requires architectural changes or package upgrades that change behavior
183
+ - Conflicting platform constraints need user decision
184
+
185
+ ## Output Format
186
+
187
+ ```text
188
+ [FIXED] lib/features/cart/data/cart_repository_impl.dart:42
189
+ Error: A value of type 'String?' can't be assigned to type 'String'
190
+ Fix: Changed `final id = response.id` to `final id = response.id ?? ''`
191
+ Remaining errors: 2
192
+
193
+ [FIXED] pubspec.yaml
194
+ Error: Version solving failed — http >=0.13.0 required by dio and <0.13.0 required by retrofit
195
+ Fix: Upgraded dio to ^5.3.0 which allows http >=0.13.0
196
+ Remaining errors: 0
197
+ ```
198
+
199
+ Final: `Build Status: SUCCESS/FAILED | Errors Fixed: N | Files Modified: list`
200
+
201
+ For detailed Dart patterns and code examples, see `skill: flutter-dart-code-review`.
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: pr-test-analyzer
3
+ description: Review pull request test coverage quality and completeness, with emphasis on behavioral coverage and real bug prevention.
4
+ model: sonnet
5
+ tools: [Read, Grep, Glob, Bash]
6
+ ---
7
+
8
+ # PR Test Analyzer Agent
9
+
10
+ You review whether a PR's tests actually cover the changed behavior.
11
+
12
+ ## Analysis Process
13
+
14
+ ### 1. Identify Changed Code
15
+
16
+ - map changed functions, classes, and modules
17
+ - locate corresponding tests
18
+ - identify new untested code paths
19
+
20
+ ### 2. Behavioral Coverage
21
+
22
+ - check that each feature has tests
23
+ - verify edge cases and error paths
24
+ - ensure important integrations are covered
25
+
26
+ ### 3. Test Quality
27
+
28
+ - prefer meaningful assertions over no-throw checks
29
+ - flag flaky patterns
30
+ - check isolation and clarity of test names
31
+
32
+ ### 4. Coverage Gaps
33
+
34
+ Rate gaps by impact:
35
+
36
+ - critical
37
+ - important
38
+ - nice-to-have
39
+
40
+ ## Output Format
41
+
42
+ 1. coverage summary
43
+ 2. critical gaps
44
+ 3. improvement suggestions
45
+ 4. positive observations
@@ -0,0 +1,50 @@
1
+ ---
2
+ name: silent-failure-hunter
3
+ description: Review code for silent failures, swallowed errors, bad fallbacks, and missing error propagation.
4
+ model: sonnet
5
+ tools: [Read, Grep, Glob, Bash]
6
+ ---
7
+
8
+ # Silent Failure Hunter Agent
9
+
10
+ You have zero tolerance for silent failures.
11
+
12
+ ## Hunt Targets
13
+
14
+ ### 1. Empty Catch Blocks
15
+
16
+ - `catch {}` or ignored exceptions
17
+ - errors converted to `null` / empty arrays with no context
18
+
19
+ ### 2. Inadequate Logging
20
+
21
+ - logs without enough context
22
+ - wrong severity
23
+ - log-and-forget handling
24
+
25
+ ### 3. Dangerous Fallbacks
26
+
27
+ - default values that hide real failure
28
+ - `.catch(() => [])`
29
+ - graceful-looking paths that make downstream bugs harder to diagnose
30
+
31
+ ### 4. Error Propagation Issues
32
+
33
+ - lost stack traces
34
+ - generic rethrows
35
+ - missing async handling
36
+
37
+ ### 5. Missing Error Handling
38
+
39
+ - no timeout or error handling around network/file/db paths
40
+ - no rollback around transactional work
41
+
42
+ ## Output Format
43
+
44
+ For each finding:
45
+
46
+ - location
47
+ - severity
48
+ - issue
49
+ - impact
50
+ - fix recommendation
@@ -0,0 +1,41 @@
1
+ ---
2
+ name: type-design-analyzer
3
+ description: Analyze type design for encapsulation, invariant expression, usefulness, and enforcement.
4
+ model: sonnet
5
+ tools: [Read, Grep, Glob, Bash]
6
+ ---
7
+
8
+ # Type Design Analyzer Agent
9
+
10
+ You evaluate whether types make illegal states harder or impossible to represent.
11
+
12
+ ## Evaluation Criteria
13
+
14
+ ### 1. Encapsulation
15
+
16
+ - are internal details hidden
17
+ - can invariants be violated from outside
18
+
19
+ ### 2. Invariant Expression
20
+
21
+ - do the types encode business rules
22
+ - are impossible states prevented at the type level
23
+
24
+ ### 3. Invariant Usefulness
25
+
26
+ - do these invariants prevent real bugs
27
+ - are they aligned with the domain
28
+
29
+ ### 4. Enforcement
30
+
31
+ - are invariants enforced by the type system
32
+ - are there easy escape hatches
33
+
34
+ ## Output Format
35
+
36
+ For each type reviewed:
37
+
38
+ - type name and location
39
+ - scores for the four dimensions
40
+ - overall assessment
41
+ - specific improvement suggestions
@@ -16,6 +16,7 @@ available-rules/
16
16
  │ └── security.md
17
17
  ├── cpp/ # C/C++ specific
18
18
  ├── csharp/ # C# specific
19
+ ├── dart/ # Dart/Flutter specific
19
20
  ├── golang/ # Go specific
20
21
  ├── java/ # Java specific
21
22
  ├── kotlin/ # Kotlin specific
@@ -24,7 +25,8 @@ available-rules/
24
25
  ├── python/ # Python specific
25
26
  ├── rust/ # Rust specific
26
27
  ├── swift/ # Swift specific
27
- └── typescript/ # TypeScript/JavaScript specific
28
+ ├── typescript/ # TypeScript/JavaScript specific
29
+ └── web/ # Web platform specific
28
30
  ```
29
31
 
30
32
  - **common/** contains universal principles — no language-specific code examples.
@@ -0,0 +1,159 @@
1
+ ---
2
+ paths:
3
+ - "**/*.dart"
4
+ - "**/pubspec.yaml"
5
+ - "**/analysis_options.yaml"
6
+ ---
7
+ # Dart/Flutter Coding Style
8
+
9
+ > This file extends [common/coding-style.md](../common/coding-style.md) with Dart and Flutter-specific content.
10
+
11
+ ## Formatting
12
+
13
+ - **dart format** for all `.dart` files — enforced in CI (`dart format --set-exit-if-changed .`)
14
+ - Line length: 80 characters (dart format default)
15
+ - Trailing commas on multi-line argument/parameter lists to improve diffs and formatting
16
+
17
+ ## Immutability
18
+
19
+ - Prefer `final` for local variables and `const` for compile-time constants
20
+ - Use `const` constructors wherever all fields are `final`
21
+ - Return unmodifiable collections from public APIs (`List.unmodifiable`, `Map.unmodifiable`)
22
+ - Use `copyWith()` for state mutations in immutable state classes
23
+
24
+ ```dart
25
+ // BAD
26
+ var count = 0;
27
+ List<String> items = ['a', 'b'];
28
+
29
+ // GOOD
30
+ final count = 0;
31
+ const items = ['a', 'b'];
32
+ ```
33
+
34
+ ## Naming
35
+
36
+ Follow Dart conventions:
37
+ - `camelCase` for variables, parameters, and named constructors
38
+ - `PascalCase` for classes, enums, typedefs, and extensions
39
+ - `snake_case` for file names and library names
40
+ - `SCREAMING_SNAKE_CASE` for constants declared with `const` at top level
41
+ - Prefix private members with `_`
42
+ - Extension names describe the type they extend: `StringExtensions`, not `MyHelpers`
43
+
44
+ ## Null Safety
45
+
46
+ - Avoid `!` (bang operator) — prefer `?.`, `??`, `if (x != null)`, or Dart 3 pattern matching; reserve `!` only where a null value is a programming error and crashing is the right behaviour
47
+ - Avoid `late` unless initialization is guaranteed before first use (prefer nullable or constructor init)
48
+ - Use `required` for constructor parameters that must always be provided
49
+
50
+ ```dart
51
+ // BAD — crashes at runtime if user is null
52
+ final name = user!.name;
53
+
54
+ // GOOD — null-aware operators
55
+ final name = user?.name ?? 'Unknown';
56
+
57
+ // GOOD — Dart 3 pattern matching (exhaustive, compiler-checked)
58
+ final name = switch (user) {
59
+ User(:final name) => name,
60
+ null => 'Unknown',
61
+ };
62
+
63
+ // GOOD — early-return null guard
64
+ String getUserName(User? user) {
65
+ if (user == null) return 'Unknown';
66
+ return user.name; // promoted to non-null after the guard
67
+ }
68
+ ```
69
+
70
+ ## Sealed Types and Pattern Matching (Dart 3+)
71
+
72
+ Use sealed classes to model closed state hierarchies:
73
+
74
+ ```dart
75
+ sealed class AsyncState<T> {
76
+ const AsyncState();
77
+ }
78
+
79
+ final class Loading<T> extends AsyncState<T> {
80
+ const Loading();
81
+ }
82
+
83
+ final class Success<T> extends AsyncState<T> {
84
+ const Success(this.data);
85
+ final T data;
86
+ }
87
+
88
+ final class Failure<T> extends AsyncState<T> {
89
+ const Failure(this.error);
90
+ final Object error;
91
+ }
92
+ ```
93
+
94
+ Always use exhaustive `switch` with sealed types — no default/wildcard:
95
+
96
+ ```dart
97
+ // BAD
98
+ if (state is Loading) { ... }
99
+
100
+ // GOOD
101
+ return switch (state) {
102
+ Loading() => const CircularProgressIndicator(),
103
+ Success(:final data) => DataWidget(data),
104
+ Failure(:final error) => ErrorWidget(error.toString()),
105
+ };
106
+ ```
107
+
108
+ ## Error Handling
109
+
110
+ - Specify exception types in `on` clauses — never use bare `catch (e)`
111
+ - Never catch `Error` subtypes — they indicate programming bugs
112
+ - Use `Result`-style types or sealed classes for recoverable errors
113
+ - Avoid using exceptions for control flow
114
+
115
+ ```dart
116
+ // BAD
117
+ try {
118
+ await fetchUser();
119
+ } catch (e) {
120
+ log(e.toString());
121
+ }
122
+
123
+ // GOOD
124
+ try {
125
+ await fetchUser();
126
+ } on NetworkException catch (e) {
127
+ log('Network error: ${e.message}');
128
+ } on NotFoundException {
129
+ handleNotFound();
130
+ }
131
+ ```
132
+
133
+ ## Async / Futures
134
+
135
+ - Always `await` Futures or explicitly call `unawaited()` to signal intentional fire-and-forget
136
+ - Never mark a function `async` if it never `await`s anything
137
+ - Use `Future.wait` / `Future.any` for concurrent operations
138
+ - Check `context.mounted` before using `BuildContext` after any `await` (Flutter 3.7+)
139
+
140
+ ```dart
141
+ // BAD — ignoring Future
142
+ fetchData(); // fire-and-forget without marking intent
143
+
144
+ // GOOD
145
+ unawaited(fetchData()); // explicit fire-and-forget
146
+ await fetchData(); // or properly awaited
147
+ ```
148
+
149
+ ## Imports
150
+
151
+ - Use `package:` imports throughout — never relative imports (`../`) for cross-feature or cross-layer code
152
+ - Order: `dart:` → external `package:` → internal `package:` (same package)
153
+ - No unused imports — `dart analyze` enforces this with `unused_import`
154
+
155
+ ## Code Generation
156
+
157
+ - Generated files (`.g.dart`, `.freezed.dart`, `.gr.dart`) must be committed or gitignored consistently — pick one strategy per project
158
+ - Never manually edit generated files
159
+ - Keep generator annotations (`@JsonSerializable`, `@freezed`, `@riverpod`, etc.) on the canonical source file only
@@ -0,0 +1,66 @@
1
+ ---
2
+ paths:
3
+ - "**/*.dart"
4
+ - "**/pubspec.yaml"
5
+ - "**/analysis_options.yaml"
6
+ ---
7
+ # Dart/Flutter Hooks
8
+
9
+ > This file extends [common/hooks.md](../common/hooks.md) with Dart and Flutter-specific content.
10
+
11
+ ## PostToolUse Hooks
12
+
13
+ Configure in `~/.claude/settings.json`:
14
+
15
+ - **dart format**: Auto-format `.dart` files after edit
16
+ - **dart analyze**: Run static analysis after editing Dart files and surface warnings
17
+ - **flutter test**: Optionally run affected tests after significant changes
18
+
19
+ ## Recommended Hook Configuration
20
+
21
+ ```json
22
+ {
23
+ "hooks": {
24
+ "PostToolUse": [
25
+ {
26
+ "matcher": { "tool_name": "Edit", "file_paths": ["**/*.dart"] },
27
+ "hooks": [
28
+ { "type": "command", "command": "dart format $CLAUDE_FILE_PATHS" }
29
+ ]
30
+ }
31
+ ]
32
+ }
33
+ }
34
+ ```
35
+
36
+ ## Pre-commit Checks
37
+
38
+ Run before committing Dart/Flutter changes:
39
+
40
+ ```bash
41
+ dart format --set-exit-if-changed .
42
+ dart analyze --fatal-infos
43
+ flutter test
44
+ ```
45
+
46
+ ## Useful One-liners
47
+
48
+ ```bash
49
+ # Format all Dart files
50
+ dart format .
51
+
52
+ # Analyze and report issues
53
+ dart analyze
54
+
55
+ # Run all tests with coverage
56
+ flutter test --coverage
57
+
58
+ # Regenerate code-gen files
59
+ dart run build_runner build --delete-conflicting-outputs
60
+
61
+ # Check for outdated packages
62
+ flutter pub outdated
63
+
64
+ # Upgrade packages within constraints
65
+ flutter pub upgrade
66
+ ```