
dart-write-documentation
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.
- Installs
- 5.9K
- Last 24h
- +92
- Trending rank
- #2095
- Security
- Pass
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/dart-lang/skills --skill dart-write-documentation- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads dart-write-documentation automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
Security audits
Independent scans of the skill's instructions and bundled files.
SKILL.md
The instructions your agent reads when the skill is triggered.
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].
FAQ
What does the dart-write-documentation skill do?
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.
How do I install dart-write-documentation?
Run npx skills add https://github.com/dart-lang/skills --skill dart-write-documentation 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-write-documentation/ (personal) or .claude/skills/dart-write-documentation/ (project).
Which AI agents can use dart-write-documentation?
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-write-documentation safe to install?
Security partners have reviewed it: Gen Agent Trust Hub passed; Socket passed; Snyk passed. As with any skill, read the SKILL.md and bundled scripts before installing.
Who maintains dart-write-documentation?
It is published by dart-lang in dart-lang/skills. It has 5,854 recorded installs.
More from dart-lang/skills
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.
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.
dart-use-pattern-matching
dart-lang/skills
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.
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.
dart-resolve-package-conflicts
dart-lang/skills
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
Popular docs & writing skills
grill-with-docs
mattpocock/skills
A relentless interview to sharpen a plan or design, which also creates docs (ADR's and glossary) as we go.
lark-markdown
open.feishu.cn
飞书 Markdown:查看、创建、上传、编辑和比较飞书中的原生 Markdown 文件。当用户要操作飞书 Markdown 文件,或比较其远端版本及本地草稿时使用。纯本地 Markdown 文件操作不触发本 skill。不负责将 Markdown 导入为飞书在线文档,也不负责文件搜索、权限、评论、移动、删除等云空间管理操作。
writing-beats
mattpocock/skills
Writing, exploit; assemble raw material into a journey of beats, grounding each term before a beat leans on it.
writing-shape
mattpocock/skills
Writing, exploit: shape raw material into an article, paragraph by paragraph.
writing-fragments
mattpocock/skills
Writing, explore: mine raw fragments, no structure yet.
writing-for-agents
mattpocock/skills
Writing documents for agents. Use when creating or editing skills, or modifying AGENTS.md or CLAUDE.md.