dart-cli-app-best-practices

Applies best practices for structuring, testing, and packaging Dart CLI applications.

1|Updated Apr 30, 2026
One-click install
npx skills add https://github.com/Wishtohear/bucket-water-oms --skill dart-cli-app-best-practices-wishtohear
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dart-cli-app-best-practices
Source: https://github.com/Wishtohear/bucket-water-oms/tree/main/bucket-water-oms-admin-mobile/tool/dart_skills_lint/.agents/skills/dart-cli-app-best-practices
Command: npx skills add https://github.com/Wishtohear/bucket-water-oms --skill dart-cli-app-best-practices-wishtohear

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Dart CLI projects often suffer from bloated entrypoints, improper exit code handling, and non-portable scripts, leading to unmaintainable tools and broken cross-platform behavior. ## Core Features & Use Cases - Entrypoint Structure Guidance: Keeps bin/ files minimal by delegating logic to testable library code. - Exit Code & Process Handling: Enforces correct use of exitCode setters and standard sysexits codes instead of abrupt exit() calls. - Cross-Platform Compatibility: Covers Windows-safe path handling with package:path and executable script setup with shebangs. - Package Recommendations: Curates Dart team packages like args, io, stack_trace, and test_process for common CLI needs. - Use Case: When scaffolding a new Dart command-line tool, apply these practices to produce a testable entrypoint, correct exit codes, and portable scripts that run on Linux, Mac, and Windows. ## Quick Start Review my Dart CLI application in the bin directory and refactor it to follow Dart CLI best practices including exit codes and entrypoint structure.

Frequently Asked Questions about dart-cli-app-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I structure a Dart CLI application entrypoint?▼

Keep the bin/ entrypoint file minimal by delegating all logic to a library function such as runApp in src/. This decouples logic from the process runner and makes the application testable.

What packages should I use for Dart CLI argument parsing?▼

Use package:args from the Dart team for standard flag and option parsing. For generating parsers from classes, package:build_cli is a community option, and package:io helps with ANSI output and exit codes.

Why should I avoid calling exit() in Dart CLI apps?▼

Calling exit() terminates the VM immediately, preventing finally blocks from running and breaking pause-on-exit debugging. Set the exitCode top-level setter instead and let main complete naturally.

How do I make a Dart script executable on Linux and Mac?▼

Add #!/usr/bin/env dart as the first line of the script, then run chmod +x on the file. This lets the script run directly from the shell without invoking dart explicitly.

Does Dart CLI code work on Windows?▼

Yes, but avoid hardcoded path separators and use package:path for portable path construction. For file permission tests, use icacls on Windows instead of chmod rather than skipping tests.