Use when writing Dart code, reviewing for style, refactoring naming, adding doc comments, structuring imports, or enforcing type annotations.
npx skills add https://github.com/evanca/flutter-ai-rules --skill effective-dart
This skill defines how to write idiomatic, high-quality Dart and Flutter code following Effective Dart guidelines.
| Kind | Convention | Example |
|---|---|---|
| Classes, enums, typedefs, type parameters, extensions | UpperCamelCase | MyWidget, UserState |
| Packages, directories, source files | lowercase_with_underscores | user_profile.dart |
| Import prefixes | lowercase_with_underscores | import '...' as my_prefix; |
| Variables, parameters, named parameters, functions | lowerCamelCase | userName, fetchData() |
HttpRequest, not HTTPRequest.E (element), K/V (key/value), T/S/U (generic types).get; prefer removing get and using a getter when the API conceptually exposes a property.final, sealed, interface, base, mixin) to control whether a class can be extended or implemented.dynamic instead of letting inference fail.Future<void> as the return type of async members that do not produce values.// Prefer: explicit class modifier
final class AppConfig {
final String apiUrl;
final int timeout;
const AppConfig({required this.apiUrl, required this.timeout});
}
// Prefer: sealed for exhaustive pattern matching
sealed class Result<T> {}
class Success<T> extends Result<T> { final T value; Success(this.value); }
class Failure<T> extends Result<T> { final Exception error; Failure(this.error); }
dart format .
dart format — don't manually format.final over var when variable values won't change.const for compile-time constants.src directory of another package.lib./lib/ or ../ in import paths.final.const if the class supports it.// Adjacent string concatenation (not +)
final greeting = 'Hello, '
'world!';
// Collection literals
final list = [1, 2, 3];
final map = {'key': 'value'};
// Initializing formals
class Point {
final double x, y;
Point(this.x, this.y);
}
// Empty constructor body
class Empty {
Empty(); // not Empty() {}
}
// rethrow to preserve stack trace
try {
doSomething();
} catch (e) {
log(e);
rethrow;
}
whereType<T>() to filter a collection by type.var and final on local variables.hashCode if you override ==; ensure == obeys mathematical equality rules.on SomeException catch (e) instead of broad catch (e) or .catchError handlers./// Returns the sum of [a] and [b].
///
/// Throws [ArgumentError] if either value is negative.
int add(int a, int b) { ... }
/// doc comments — not /* */ block comments — for types and members.[identifier] in doc comments to refer to in-scope identifiers.group and descriptive test names:import 'package:test/test.dart';
void main() {
group('CartService', () {
late CartService cart;
setUp(() => cart = CartService());
test('addItem increases item count', () {
cart.addItem(Product(id: '1', name: 'Widget', price: 9.99));
expect(cart.items, hasLength(1));
});
test('removeItem decreases total price', () {
final product = Product(id: '1', name: 'Widget', price: 9.99);
cart.addItem(product);
cart.removeItem(product.id);
expect(cart.totalPrice, equals(0.0));
});
});
}
testWidgets and WidgetTester:import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('LoginButton shows loading indicator when tapped',
(WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(home: LoginScreen()));
await tester.tap(find.byType(ElevatedButton));
await tester.pump();
expect(find.byType(CircularProgressIndicator), findsOneWidget);
});
}
When reviewing Dart code for Effective Dart compliance, the agent should check:
final, sealed, or interface is used where appropriate./// doc comments with a single-sentence summary.dart format --output=none --set-exit-if-changed . to verify formatting.dart analyze and confirm zero issues.Behavioral guidelines to reduce common LLM coding mistakes. Use when writing, reviewing, or refactoring code to avoid overcomplication, make surgical changes, surface assumptions, and define verifiable success criteria.
Structured task planning with clear breakdowns, dependencies, and verification criteria. Use when implementing features, refactoring, or any multi-step work.
Master ES6+ features including async/await, destructuring, spread operators, arrow functions, promises, modules, iterators, generators, and functional programming patterns for writing clean, efficient JavaScript code. Use when refactoring legacy code, implementing modern patterns, or optimizing JavaScript applications.
Master ES6+ features including async/await, destructuring, spread operators, arrow functions, promises, modules, iterators, generators, and functional programming patterns for writing clean, efficient JavaScript code. Use when refactoring legacy code, implementing modern patterns, or optimizing JavaScript applications.
Guidelines and format for writing pull request descriptions in this repository. Use this skill whenever the user asks you to draft a pull request description, submit a PR, or update a PR description.
Angular performance optimization and best practices guide. Use when writing, reviewing, or refactoring Angular code for optimal performance, bundle size, and rendering efficiency.
Use when a user asks to debug or fix failing GitHub PR checks that run in GitHub Actions. Uses `gh` to inspect checks and logs, summarize failure context, draft a fix plan, and implement only after explicit approval. Treats external providers (for example Buildkite) as out of scope and reports only the details URL. Do NOT use for addressing PR review comments (use gh-address-comments) or general CI outside GitHub Actions.
Angular performance optimization and best practices guide. Use when writing, reviewing, or refactoring Angular code for optimal performance, bundle size, and rendering efficiency.
Take evanca/effective-dart from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.