MCPInstall

dart-effective-style

Maintain code consistency by following official Dart style and naming conventions.

Installs
76
Last 24h
—
Trending rank
—
Security
Not audited

Install

Works with every agent the skills CLI supports.

npx skills add https://github.com/dart-lang/skills --skill dart-effective-style
  1. 01

    Install

    Run the command in your project. The CLI asks which agents to install for.

  2. 02

    Describe the task

    Ask your agent for something this skill covers. It loads dart-effective-style automatically when relevant.

  3. 03

    Review the result

    The agent follows the SKILL.md steps, scripts and references bundled with the skill.

SKILL.md

The instructions your agent reads when the skill is triggered.

Styling Dart Code

Contents

Naming Conventions

Apply the following naming conventions strictly to maintain consistency across the Dart ecosystem.

  • Types: Name classes, enum types, typedefs, extensions, and type parameters using UpperCamelCase.
  • Variables & Members: Name class members, top-level definitions, variables, parameters, and named parameters using lowerCamelCase.
  • Constants: Prefer lowerCamelCase for constant variables, including enum values.
    • Conditional: If editing existing code that uses SCREAMING_CAPS or working with generated code (e.g., protobufs), maintain consistency with the existing style.
  • Files & Directories: Name packages, directories, and source files using lowercase_with_underscores.
  • Import Prefixes: Name import prefixes using lowercase_with_underscores.
  • Acronyms: Capitalize acronyms and abbreviations longer than two letters like regular words (e.g., Http, Uri). Keep two-letter acronyms fully capitalized (e.g., ID, UI). If an abbreviation begins a lowerCamelCase identifier, make it entirely lowercase (e.g., httpConnection).
  • Privacy: Use a leading underscore _ for members and top-level declarations to indicate library privacy. Do not use leading underscores for local variables, parameters, local functions, or library prefixes.
  • Unused Parameters: Prefer using wildcards (_, __, etc.) for unused callback parameters to explicitly signal intent.
  • Prefixes: Do not use prefix letters (e.g., Hungarian notation like kDefaultTimeout).
  • Libraries: Do not explicitly name libraries (e.g., avoid library my_library;).

Examples

// GOOD
class SliderMenu {}
typedef Predicate<T> = bool Function(T value);
const defaultTimeout = 1000;
var httpConnection = connect();

futureOfVoid.then((_) {
  print('Operation complete.');
});

// BAD
class slider_menu {}
const DEFAULT_TIMEOUT = 1000;
var HTTPConnection = connect();
const kDefaultTimeout = 1000;

Ordering Directives

Organize file preambles using the following strict order. Separate each section with a blank line and sort directives alphabetically within each section.

  1. Place dart: imports first.
  2. Place package: imports second.
  3. Place relative imports third.
    • Best Practice: Prefer relative imports for files located inside the lib directory of the same package.
  4. Specify export directives in a separate section after all imports.

Example

// GOOD
import 'dart:async';
import 'dart:collection';

import 'package:bar/bar.dart';
import 'package:foo/foo.dart';

import 'src/util.dart';

export 'src/error.dart';

Formatting Rules

  • Mandatory Formatting: Run dart format as a mandatory step before committing any code. The official whitespace-handling rules for Dart are defined entirely by what dart format produces.
  • Line Length: Prefer lines of 80 characters or fewer. Reorganize deeply nested expressions or extract variables if dart format produces unreadable output due to line length constraints.
  • Flow Control: Use curly braces for all flow control statements to avoid the dangling else problem.
    • Exception: You may omit braces for an if statement with no else clause if the entire statement fits on a single line.

Example

// GOOD
if (isWeekDay) {
  print('Bike to work!');
} else {
  print('Go dancing or read a book!');
}

if (arg == null) return defaultValue;

// BAD
if (overflowChars != other.overflowChars)
  return overflowChars < other.overflowChars;

Workflows

Pre-Commit Formatting & Linting Workflow

Execute this workflow before finalizing any Dart code modifications to ensure style compliance.

  • Task Progress
    • 1. Review code against naming conventions (e.g., UpperCamelCase for types, lowerCamelCase for variables).
    • 2. Verify import ordering (dart: -> package: -> relative -> exports).
    • 3. Run dart format . on the modified files.
    • 4. Run dart analyze to catch static analysis and linting errors.
    • 5. Run validator -> review errors -> fix any issues reported by the analyzer.

FAQ

What does the dart-effective-style skill do?

Maintain code consistency by following official Dart style and naming conventions.

How do I install dart-effective-style?

Run npx skills add https://github.com/dart-lang/skills --skill dart-effective-style in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/dart-effective-style/ (personal) or .claude/skills/dart-effective-style/ (project).

Which AI agents can use dart-effective-style?

Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.

Is dart-effective-style safe to install?

No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.

Who maintains dart-effective-style?

It is published by dart-lang in dart-lang/skills. It has 76 recorded installs.

More from dart-lang/skills

View all →

dart-add-unit-test

dart-lang/skills

Write and organize unit tests for functions, methods, and classes using package:test. Use when creating new logic or fixing bugs to ensure code remains correct and regression-free.

Testing & QA19.3K installs

dart-run-static-analysis

dart-lang/skills

Execute dart analyze to identify warnings and errors, and use dart fix --apply to automatically resolve mechanical lint issues. Use during development to ensure code quality and before committing changes.

Applies Dart 3 pattern matching, switch expressions, and destructuring idiomatically to validate data schemas, handle algebraic data types, and decompose control flow. Use when refactoring complex if-else chains, parsing polymorphic JSON or API responses, destructuring Lists, URI/path segments, String.split() tokens, Records, or Maps, or enforcing exhaustiveness on sealed classes. Don't use for simple boolean conditions, single-variable type promotion (use is), or basic collection filtering.

Backend & APIs18.8K installs

dart-fix-runtime-errors

dart-lang/skills

Uses getruntimeerrors and lsp to fetch an active stack trace, locate the failing line, apply a fix, and verify resolution via hotreload.

18.8K installs

Workflow for fixing package version conflicts. Use this when pub get fails due to incompatible package versions.

dart-collect-coverage

dart-lang/skills

Collect coverage using the coverage packge and create an LCOV report

Testing & QA18.5K installs

Popular other skills

View category →

hyperframes-cli

heygen-com/hyperframes

The HyperFrames CLI by job - scaffold, check, look at frames, edit the timeline, preview, render locally or in the cloud, publish, project history - plus reading its JSON and recovering from build or render failures.

1.3M installs

triage

mattpocock/skills

Move issues and external PRs through a state machine of triage roles, categorise, verify, grill if needed, and write agent-ready briefs.

1M installs

ask-matt

mattpocock/skills

Ask which skill or flow fits your situation. A router over the skills in this repo.

778.4K installs

to-questionnaire

mattpocock/skills

Turn a decision you can't fully answer into a questionnaire for someone else to fill in.

508.9K installs

wait-what

mattpocock/skills

Stop. That last message did not land: re-pitch it.

459.7K installs

loop-me

mattpocock/skills

Grill me about specs for the workflows I want to build, within this workspace.

447.9K installs