dart-write-documentation
flutter/agent-plugins
Rules and formatting guidelines for writing Dart /// API documentation following Effective Dart standards.
What is dart-write-documentation?
Provides strict formatting rules for Dart API documentation comments (///) covering scope, tone, linking, and anti-patterns. Use when documenting Dart code, writing doc comments for any declaration, or following Effective Dart documentation guidelines.
- Enforces /// comment syntax and proper sentence structure for all public API documentation
- Specifies tone conventions: noun phrases for properties, 'whether' for booleans, third-person verbs for methods
- Bans Javadoc-style tags (@param, @return, @throws) in favor of prose-based documentation
- Provides linking rules using square brackets for in-scope symbols and backticks for keywords/literals
- Defines placement rules for annotations, inherited documentation, and getter/setter pairs
- Includes verification steps using dart analyze and dart doc
How to install dart-write-documentation
npx skills add https://github.com/flutter/agent-plugins --skill dart-write-documentationHow to use dart-write-documentation
- 1.Review the scope and structure rules: use /// for all public API docs, start with a single summary sentence, separate with /// blank lines
- 2.Apply tone conventions: noun phrases for properties, 'whether' for booleans, third-person verbs for methods
- 3.Use square brackets [identifier] for in-scope symbol links and backticks for keywords/literals
- 4.Avoid Javadoc tags; instead weave parameter names, return behavior, and exceptions into prose
- 5.Place doc comments before annotations, use .new syntax for default constructor links, and add @docImport for out-of-scope symbols
- 6.Run dart analyze to verify all bracketed references resolve without warnings, then optionally run dart doc to preview rendered output
Use cases
- Writing doc comments for library, class, method, variable, and function declarations
- Updating existing Dart documentation to comply with Effective Dart guidelines
- Ensuring consistent documentation style across a Dart/Flutter codebase
- Linking to parameters, classes, and methods correctly in doc comments
- Documenting edge cases, exceptions, and internal behavior in code blocks
- Dart and Flutter developers writing public APIs
- Technical writers documenting Dart libraries
- Teams enforcing consistent documentation standards
- Developers migrating from Javadoc or TSDoc conventions to Dart style
dart-write-documentation FAQ
No, do not document private members unless explicitly instructed, as they do not appear in generated API reference sites. Focus on public declarations only.
No, these Javadoc-style tags are banned. Instead, weave parameter names, return behavior, and exceptions directly into the prose documentation.
Use the .new syntax, e.g., [ClassName.new], not [ClassName()] or [ClassName].
Use the @docImport directive at the top of the file on the library; declaration rather than adding a standard import.
Always label the language fence with ```dart for Dart code or ```sh for shell commands. Never leave code blocks unlabeled.
Full instructions (SKILL.md)
Source of truth, from flutter/agent-plugins.
name: dart-write-documentation description: "Rules and formatting guidelines for writing Dart /// API documentation and doc comments. Use when documenting Dart code, writing doc comments for any Dart declaration (libraries, classes, methods, variables, etc.), or when instructed to follow the Effective Dart documentation guidelines."
Writing Dart API Documentation
Contents
- 1. Scope and Structure
- 2. Tone and Openers
- 3. Strict Anti-Patterns (Banned)
- 4. Technical Placement & Resolution
- 5. Linking and Markdown
- 6. Verification
- Examples
When asked to write or update documentation for Dart code, you must strictly follow these formatting rules based on the "Effective Dart: Documentation" guidelines.
1. Scope and Structure
- Target Public APIs: Focus your documentation efforts on public declarations. Do not document private members (those starting with an underscore
_) unless explicitly instructed, as they do not appear in generated API reference sites. - Always use
///: Use///consecutive line comments for all API documentation. Never use/** ... */block comments. - Proper Sentences: Format all comments like proper sentences. Capitalize the first word (unless it's a lowercase identifier) and end with a period.
- The First Paragraph: The first paragraph of a doc comment must be a single, concise sentence that summarizes the element. End it with a period. Dartdoc extracts this verbatim for list views.
- Separation: Always separate the first sentence summary from the rest of the documentation with a blank line containing
///. Never output a completely empty newline (e.g., a\nwithout///), as this terminates the doc comment block.
2. Tone and Openers
- Noun phrases for properties: Start descriptions of variables, getters, or setters with a noun phrase.
/// The radius of the sphere.(Not "Gets the radius...") - "Whether" for booleans: Start documentation for boolean properties with "Whether".
/// Whether the connection is active. - Third-person verbs for methods: Start descriptions of methods or functions with a third-person verb that describes what it does.
/// Initializes the database.(Not "Initialize" or "This method initializes"). - Avoid redundancy: Do not restate the signature or the element name. Do not say "This class is a..." or "The foo method does...".
3. Strict Anti-Patterns (Banned)
- No Javadoc/TSDoc Tags (
@param,@return,@throws, etc.): Never use Javadoc-style tags (@param,@return,@returns,@throws,@exception,@see,@type). Instead, weave parameter names, return behavior, and exceptions into the prose.
4. Technical Placement & Resolution
- Annotations (
@override, etc.): Doc comments must be placed before metadata annotations. - Inherited Documentation: Avoid duplicating doc comments on
@overridemembers if the behavior does not differ from the superclass or interface. Dartdoc automatically inherits the base documentation. - Getter/Setter Pairs: If a property has both a getter and a setter, place the documentation only on the getter. Tooling will emit a warning if both are documented.
- Default Constructors: To link to a default, unnamed constructor in doc comments, you must use the
.newsyntax (e.g.,[ClassName.new]).
5. Linking and Markdown
- Square brackets (
[identifier]) for in-scope symbols: Use square brackets to link to any in-scope identifier (parameters, classes, methods, fields, and top-level functions) so dartdoc can resolve them. Never use backticks for parameters. - No parentheses in method links: Avoid parentheses in links (e.g., use
[String.contains], not[String.contains()]). - Backticks for keywords & literals: Use backticks for keywords, literals, and arbitrary expressions (e.g.
`null`,`true`,`void`). Never put keywords in square brackets (avoid[null]or[true]). - Out-of-Scope Links: If you need to link to a symbol that is not imported by the current library, use the
@docImportdirective at the top of the file (on thelibrary;declaration) rather than adding a standardimport. - Code Blocks: For code samples, always label the language fence. Use
```dartfor Dart, or```shfor shell commands. Do not leave code blocks unlabelled, as Dartdoc will attempt to auto-detect the language and frequently guesses wrong. - Formatting: Use standard Markdown (bold, lists, etc.) after the first paragraph to fully explain edge cases, exceptions thrown, and internal behavior the caller cannot see.
6. Verification
After writing or updating doc comments:
- Run
dart analyzeto ensure all bracketed references resolve properly without triggeringcomment_referenceswarnings. - (Optional) Run
dart docto verify the generated documentation renders cleanly.
Examples
1. Banned Tags vs. Prose
Bad:
/// This method fetches data.
/// @param force true to force reload.
/// @return the data
/// @throws NetworkException if host is unreachable.
Data load(bool force) { ... }
Good:
/// Fetches the remote data.
///
/// If [force] is true, this bypasses the local cache and forces a
/// network request.
///
/// Throws a [NetworkException] if the host is unreachable.
Data load(bool force) { ... }
2. The Annotation Placement Trap
Bad:
@override
/// Renders the widget to the screen.
Widget build(BuildContext context) { ... }
Good:
/// Renders the widget to the screen.
@override
Widget build(BuildContext context) { ... }
3. Openers and Tone
Bad:
/// Gets if the connection is active.
bool get isActive => _active;
/// This method initializes the connection.
void init() { ... }
Good:
/// Whether the connection is active.
bool get isActive => _active;
/// Initializes the connection.
void init() { ... }
4. Constructor Linking
Bad:
/// Creates a new user. Similar to calling [User()].
User.create() { ... }
Good:
/// Creates a new user. Similar to calling [User.new].
User.create() { ... }
5. Out-of-Scope Links (@docImport)
Bad:
import 'package:http/http.dart'; // Adds unnecessary runtime dependency just for docs
/// To use this, you must pass a [Client].
Good:
/// @docImport 'package:http/http.dart';
library;
/// To use this, you must pass a [Client].
Related skills
More from flutter/agent-plugins and the wider catalog.

flutter-accessibility-audit
Agent skill from flutter/agent-plugins.

flutter-add-integration-test
Configure Flutter Driver and convert MCP interactions into permanent integration tests.

flutter-add-widget-preview
Add interactive widget previews to Flutter projects for real-time UI component testing and design validation.

flutter-add-widget-test
Write component-level Flutter tests using WidgetTester to verify UI rendering and user interactions.

flutter-adding-home-screen-widgets
Agent skill from flutter/agent-plugins.

flutter-animating-apps
Agent skill from flutter/agent-plugins.