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.
73
90%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
When asked to write or update documentation for Dart code, you must strictly follow these formatting rules based on the "Effective Dart: Documentation" guidelines.
_) unless explicitly instructed, as they do not appear in generated API reference sites.///: Use /// consecutive line comments for all API documentation. Never use /** ... */ block comments.///. Never output a completely empty newline (e.g., a \n without ///), as this terminates the doc comment block./// The radius of the sphere. (Not "Gets the radius...")/// Whether the connection is active./// Initializes the database. (Not "Initialize" or "This method initializes").@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.@override, etc.): Doc comments must be placed before metadata annotations.@override members if the behavior does not differ from the superclass or interface. Dartdoc automatically inherits the base documentation..new syntax (e.g., [ClassName.new]).[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.[String.contains], not [String.contains()]).`null`, `true`, `void`). Never put keywords in square brackets (avoid [null] or [true]).@docImport directive at the top of the file (on the library; declaration) rather than adding a standard import.```dart for Dart, or ```sh for shell commands. Do not leave code blocks unlabelled, as Dartdoc will attempt to auto-detect the language and frequently guesses wrong.After writing or updating doc comments:
dart analyze to ensure all bracketed references resolve properly without triggering comment_references warnings.dart doc to verify the generated documentation renders cleanly.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) { ... }Bad:
@override
/// Renders the widget to the screen.
Widget build(BuildContext context) { ... }Good:
/// Renders the widget to the screen.
@override
Widget build(BuildContext context) { ... }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() { ... }Bad:
/// Creates a new user. Similar to calling [User()].
User.create() { ... }Good:
/// Creates a new user. Similar to calling [User.new].
User.create() { ... }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].1412474
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.