dart-best-practices
General best practices for Dart development. Covers code style, effective Dart, and language features.
Best practices for validating Dart documentation comments. Covers using `dart doc` to catch unresolved references and macros.
$ npx -y skills add kevmoo/dash_skills --skill dart-doc-validation --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/dart-doc-validationContext preview
The summary Claude sees to decide when to auto-load this skill.
Best practices for validating Dart documentation comments. Covers using `dart doc` to catch unresolved references and macros.
name: dart-doc-validation description: |- Best practices for validating Dart documentation comments. Covers using `dart doc` to catch unresolved references and macros. license: Apache-2.0 key_features: - Documentation comment validation - Unresolved reference checking - Dart doc macro verification
Use this skill when:
Do NOT apply this skill or refactor doc comments when:
pseudo-code, non-Dart language identifiers (e.g. ``yaml`, ``json`, ````bash`,
compile as valid Dart.
- **Generated Code**: Files generated by tools (e.g. `*.g.dart`, `*.mocks.dart`,
`*.freezed.dart`) where comments are synthesized.
- **External Markdown Hyperlinks**: Text in square brackets followed by a link
target (e.g. `[External Guide](https://...)`), which is standard Markdown
hyperlink syntax rather than an unresolved Dart doc reference.
## Discovery
To find documentation issues:
### Missing Lint
Verify if the `comment_references` lint is enabled:
- **Target**: `analysis_options.yaml`
- **Search Query**: `comment_references`
### Automated Validation
Run the documentation generator to surface warnings:
- **Command**: `dart doc -o $(mktemp -d)`
- **Keywords to look for**: `warning:`, `unresolved doc reference`,
`undefined macro`
## 2. Best Practices
### Enable the doc validation lint
In your `analysis_options.yaml`, enable the `comment_references` lint.
```yaml
linter:
rules:
- comment_referencesUse the `dart doc` command with a temporary output directory to validate documentation comments without polluting the local project workspace.
This command parses all documentation comments and reports warnings such as:
**Command to run:**
dart doc -o $(mktemp -d)
_This will work on Mac and Linux._
This ensures that the generated HTML files are stored in a temporary location and don't clutter the package directory, while still surfacing all validation warnings in the terminal output.
**Browsing the docs:**
Our docs use features designed to be run on a web server. If you want to browse the generated docs locally, install the `dhttpd` package.
dart install dhttpd TMP_DIR=$(mktemp -d) && dart doc -o "$TMP_DIR" && dhttpd --path "$TMP_DIR"
_(Or use another HTTP server, such as `python3 -m http.server`.)_
brackets (`[Identifier]`) correctly points to an existing class, method, property, or parameter in the current scope or imported libraries.
`{@template macro_name}` is defined in the same file or a file that is imported and visible to the documentation generator.
General best practices for Dart development. Covers code style, effective Dart, and language features.
Guidelines for handling long lines in Dart code to adhere to the 80-column rule. The `lines_longer_than_80_chars` lint.
Best practices for using `expect` and `package:matcher`. Focuses on readable assertions, proper matcher selection, and avoiding…
Guidelines for using modern Dart features (v3.0 - v3.10) such as Records, Extension Types, Class Modifiers, Wildcards, Digit…
Guidelines and best practices for refactoring consecutive prints, single-line string concatenations, and complex output blocks…
Guidelines for maintaining external Dart packages, covering versioning, publishing workflows, and pull request management. Use…