Structure cross-platform Dart command-line applications with arguments and exit codes.
---
name: dart-build-cli-app
description: Entrypoint structure, exit codes, cross-platform scripts. Use when building command line utilities, scripts, or applications.
metadata:
model: models/gemini-3.1-pro-preview
last_modified: Fri, 04 May 2026 17:41:00 GMT
---
# 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`.… install to load the full skill