naming-conventions
Installation
SKILL.md
Naming Conventions
Consistent, role-carrying names make code searchable and self-explaining, and the suffix on a type declares which layer it lives in — so a reviewer, a grep, and a banned-import gate can all read the layer off the name alone. This skill is the how; the normative what is Effective Dart. Never invent a house style that contradicts the language's own.
Non-negotiable rules
- Types are
UpperCamelCase. Classes, enums, mixins, extensions, typedefs, type parameters:TaskScreen,OrderStatus,Predicate<T>. Consistent shape makes types visually distinct from values. - Members, variables, functions, and parameters are
lowerCamelCase.dueDate,loadTasks(),itemCount. It is the language default; deviating costs readers a double-take. - Constants are
lowerCamelCase, neverSCREAMING_CAPS.const maxItemsPerPage = 50;— notconst MAX_ITEMS = 50. Dart dropped the C convention; the analyzer expectsconstant_identifier_names. - Files, folders, libraries, and import prefixes are
lowercase_with_underscores.task_detail_screen.dart,features/task_detail/,import 'package:app_core/app_core.dart';. Cross-platform filesystems and pub demand it. - File name = its primary declaration, snake_cased, one primary public type per file.
TaskNotifierlives intask_notifier.dart. Noutils.dart/helpers.dart/models.dartgrab-bags and noutils//common//helpers//misc/junk-drawer folders — a reader who greps a symbol must land in the file that owns it.core/is the sanctioned pure-foundation layer (value objects,Result/Failure, theClockseam, pure calculators), not a junk-drawer — seeproject-structure-and-packages, which owns the layout. - Acronyms longer than two letters are cased like a word.
Json,Http,Url,Api→JsonOrder,HttpClient,fromJson,imageUrl— notJSONOrder,HTTPClient. Two-letter caps-in-English acronyms may stay caps as types (ID,UI). Mixed-case acronyms are unsearchable and inconsistent. - A leading underscore means library-private — use it only when you mean private. Never prefix a public symbol with
_to "namespace" it; that makes it unusable from another file. Public (no_) is a documented contract — seedartdoc-conventions. - No Hungarian / type-encoding in names. Not
strName,iCount,lstItems,userMap,nameString,itemsList. The type system already knows the type; writename,usersById,items. - Full dictionary words; units and semantics live in the name.
maxItemsPerPage,retryDelaySeconds,orderTotalMinorUnits— never baremax,delay,total. Abbreviations (opt,qty,amt) are confined to the inside of one short pure function with a comment mapping them. A name that omits its unit invites a unit bug. - Booleans read as assertions.
isLoading,hasError,canSubmit,shouldRetry— notloading,error,retry. Boolean getters and methods startis/has/can/shouldso a condition reads like prose. - No
get-prefixed accessors. ExposedueTasks, notgetDueTasks(). Dart has real getters. Functions are verb phrases (loadTasks(),scheduleReminder()); non-boolean getters are noun phrases (itemCount,nextDueDate). - Imports grouped and sorted:
dart:first, thenpackage:, then relative — each group alphabetized,exports in their own section after imports. Letdart formatplus thedirectives_orderinglint enforce it; never hand-fight the formatter.