dart-build-cli-app
Use when creating Dart command-line tools, parsing CLI arguments with args, handling exit codes, or managing child processes.
Skill by dhruvanbhalara
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/dhruvanbhalara-dart-build-cli-app
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 26, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/dart-build-cli-app
What's inside
- Skill name
dart-build-cli-app- Description
- Use when creating Dart command-line tools, parsing CLI arguments with args, handling exit codes, or managing child processes.
- License
- MIT
- Metadata
- category: development · languages: dart · platforms: dart
- Instructions
- 171 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Building Dart CLI Applications
## Contents
- [Project Setup & Architecture](#project-setup--architecture)
- [Argument Parsing & Command Routing](#argument-parsing--command-routing)
- [Execution & Error Handling](#execution--error-handling)
- [Testing CLI Applications](#testing-cli-applications)
- [Compilation & Distribution](#compilation--distribution)
- [Workflows](#workflows)
- [Examples](#examples)
## Project Setup & Architecture
Initialize new CLI projects using the official Dart template to ensure standard directory structures.
* Run `dart create -t cli <project_name>` to scaffold a console application with basic argument parsing.
* Place executable entry points (files containing `main()`) exclusively in the `bin/` directory.
* Place internal implementation logic in `lib/src/` and expose public APIs via `lib/<project_name>.dart`.
* Enforce formatting in CI environments by running `dart format . --set-exit-if-changed`. This returns exit code 1 if formatting violations exist.
## Argument Parsing & Command Routing
Implement the `args` package to manage command-line arguments, flags, and subcommands.
* If building a simple script: Use `ArgParser` directly to define flags (`addFlag`) and options (`addOption`).
* If building a complex, multi-command CLI (like `git`): Implement `CommandRunner` and extend `Command` for each subcommand.
* Define global arguments on the `CommandRunner.argParser` and command-specific arguments on the individual `Command.argParser`.
* Catch `UsageException` to gracefully handle invalid arguments and display the automatically generated help text.
## Execution & Error Handling
Use the `io` and `stack_trace` packages to build reliable, production-ready CLI tools.
* Use the `io` package's `ExitCode` enum to return standard POSIX exit codes (e.g., `ExitCode.success.code`, `ExitCode.usage.code`).
* Use `sharedStdIn` from the `io` package if multiple asynchronous listeners need sequential access to standard input.
* Wrap the application execution in `Chain.capture()` from the `stack_trace` package to track asynchronous stack chains.
* Format output stack traces using `Trace.terse` or `Chain.terse` to strip noisy core library frames and present readable errors to the user.
## Testing CLI Applications
Use `test_process` and `test_descriptor` to write high-fidelity integration tests for your CLI.
* Define expected filesystem states using `test_descriptor` (`d.dir`, `d.file`).
* Create the mock filesystem before execution using `await d.Descriptor.create()`.
* Spawn the CLI process using `TestProcess.start('dart', ['run', 'bin/cli.dart', ...args])`.
* Validate standard output and error streams using `StreamQueue` matchers (e.g., `emitsThrough`, `emits`).
* Assert the final exit code using `await process.shouldExit(0)`.
* Validate resulting filesystem mutations using `await d.Descriptor.validate()`.
## Compilation & Distribution
Select the appropriate compilation target based on your distribution requirements.
* **If testing locally during development:** Use `dart run bin/cli.dart`. This uses the JIT compiler for rapid iteration.
* **If bundling code assets and dynamic libraries:** Use `dart build cli`. This runs build hooks and outputs to `build/cli/_/bundle/`.
* **If distributing a standalone native executable:** Use `dart compile exe bin/cli.dart -o <output_path>`. This bundles the Dart runtime and machine code into a single file.
* **If distributing multiple apps with strict disk space limits:** Use `dart compile aot-snapshot bin/cli.dart`. Run the resulting `.aot` file using `dartaotruntime`.
<details>
<summary>Cross-Compilation Targets (Linux Only)</summary>
Dart supports cross-compiling to Linux from macOS, Windows, or Linux hosts.
Use the `--target-os` and `--target-arch` flags with `dart compile exe` or `dart compile aot-snapshot`.
* `--target-os=linux` (Only Linux is currently supported as a cross-compilation target)
* `--target-arch=arm64` (64-bit ARM)
* `--target-arch=x64` (x86-64)
* `--target-arch=arm` (32-bit ARM)
* `--target-arch=riscv64` (64-bit RISC-V)
Example: `dart compile exe --target-os=linux --target-arch=arm64 bin/cli.dart`
</details>
## Workflows
### Task Progress: Implement a New CLI Command
- [ ] Create a new class extending `Command` in `lib/src/commands/`.
- [ ] Define the `name` and `description` properties.
- [ ] Register command-specific flags in the constructor using `argParser.addFlag()` or `argParser.addOption()`.
- [ ] Implement the `run()` method with the core logic.
- [ ] Register the new command in the `CommandRunner` instance in `bin/cli.dart` using `addCommand()`.
- [ ] Run validator -> Execute `dart run bin/cli.dart help <command_name>` to verify help text generation.
### Task Progress: Compile and Release Native Executable
- [ ] Run validator -> Execute `dart format . --set-exit-if-changed` to ensure code formatting.
- [ ] Run validator -> Execute `dart analyze` to ensure no static analysis errors.
- [ ] Run validator -> Execute `dart test` to pass all integration tests.
- [ ] Compile for host OS: `dart compile exe bin/cli.dart -o build/cli-host`
- [ ] Compile for Linux (if host is macOS/Windows): `dart compile exe --target-os=linux --target-arch=x64 bin/cli.dart -o build/cli-linux-x64`
## Examples
### Example: CommandRunner Implementation
```dart
import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:stack_trace/stack_trace.dart';
class CommitCommand extends Command {
@override
final String name = 'commit';
@override
final String description = 'Record changes to the repository.';
CommitCommand() {
argParser.addFlag('all', abbr: 'a', help: 'Commit all changed files.');
}
@override
Future<void> run() async {
final commitAll = argResults?['all'] as bool? ?? false;
print('Committing... (All: $commitAll)');
}
}
void main(List<String> args) {
Chain.capture(() async {
final runner = CommandRunner('dgit', 'Distributed version control.')
..addCommand(CommitCommand());From dhruvanbhalara/skills, MIT.
More from dhruvanbhalara/skills
- 0.611score
dart-fix-runtime-errors
dhruvanbhalara
Use when diagnosing runtime failures, type cast errors, null check violations, or unhandled asynchronous exceptions in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-logic-patterns
dhruvanbhalara
Use when organizing business logic, implementing algorithmic workflows, or applying Dart data structures and pattern matching.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-memory
dhruvanbhalara
Use when troubleshooting memory leaks, optimizing garbage collection overhead, or disposing streams and listeners in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-add-widget-preview
dhruvanbhalara
Use when configuring widget previews in Flutter development, testing visual component variations, or isolating widget UI states.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-apply-architecture-best-practices
dhruvanbhalara
Use when structuring Flutter application layers across data, domain, and presentation using Clean Architecture and BLoC.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-bloc
dhruvanbhalara
Use when implementing state management with sealed BLoC classes, registering dependency injection with injectable, or setting up GoRouter listeners.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-bloc-forms
dhruvanbhalara
Use when managing complex form state, synchronous and asynchronous input validation, or form submission transitions in BLoC.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-config
dhruvanbhalara
Use when configuring build flavors, passing environment variables via dart-define-from-file, or setting up stage-specific credentials.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-debugging
dhruvanbhalara
Use when diagnosing Flutter layout issues, inspecting widget rebuilds, setting breakpoints, or tracking down UI rendering anomalies.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-devtools
dhruvanbhalara
Use when profiling CPU performance, tracking memory leaks, inspecting widget trees, or viewing network traffic in Flutter DevTools.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-dio
dhruvanbhalara
Use when configuring HTTP network clients with Dio, adding auth token interceptors, handling retry logic, or caching API responses.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-firebase
dhruvanbhalara
Use when integrating Firebase Authentication, Cloud Firestore, Cloud Messaging, Crashlytics, or Firebase Analytics in Flutter.
SkillBFreshness: B★ 30Claude Code +9
Signals
- Stars
- 30
- Forks
- 4
- Open issues
- 0
- Last commit (this folder)
- Aug 29, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/dhruvanbhalara/skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from dhruvanbhalara
- 0.611score
dart-fix-runtime-errors
dhruvanbhalara
Use when diagnosing runtime failures, type cast errors, null check violations, or unhandled asynchronous exceptions in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-logic-patterns
dhruvanbhalara
Use when organizing business logic, implementing algorithmic workflows, or applying Dart data structures and pattern matching.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
dart-memory
dhruvanbhalara
Use when troubleshooting memory leaks, optimizing garbage collection overhead, or disposing streams and listeners in Dart.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-add-widget-preview
dhruvanbhalara
Use when configuring widget previews in Flutter development, testing visual component variations, or isolating widget UI states.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-apply-architecture-best-practices
dhruvanbhalara
Use when structuring Flutter application layers across data, domain, and presentation using Clean Architecture and BLoC.
SkillBFreshness: B★ 30Claude Code +9 - 0.611score
flutter-bloc
dhruvanbhalara
Use when implementing state management with sealed BLoC classes, registering dependency injection with injectable, or setting up GoRouter listeners.
SkillBFreshness: B★ 30Claude Code +9
Cite this page
dart-build-cli-app skill. Agent Mart. https://agentmart.dev/skills/dhruvanbhalara-dart-build-cli-app (last updated 2026-10-24)