wishtohear/bucket-water-oms/dart-cli-app-best-practices
Claude Code and agent skill by wishtohear/bucket-water-oms
- community
Checking that the SKILL.md file is still in the repository.
Best practices for creating high-quality, executable Dart CLI applications. Covers entrypoint structure, exit code handling, and recommended packages.
Install
npx vskill@latest install wishtohear/bucket-water-oms/dart-cli-app-best-practicesSKILL.md
Dart CLI Application Best Practices
1. When to use this skill
Use this skill when:
- Creating a new Dart CLI application.
- Refactoring an existing CLI entrypoint (
bin/). - Reviewing CLI code for quality and standards.
- Setting up executable scripts for Linux/Mac.
2. Best Practices
Entrypoint Structure (bin/)
Keep the contents of your entrypoint file (e.g., bin/my_app.dart) minimal. This improves testability by decoupling logic from the process runner.
DO:
DON'T:
- Put complex logic directly in
bin/my_app.dart. - Define classes or heavy functions in the entrypoint.
Executable Scripts
For CLI tools intended to be run directly on Linux and Mac, add a shebang and ensure the file is executable.
DO:
- Add
#!/usr/bin/env dartto the first line. - Run
chmod +x bin/my_script.dartto make it executable.
Process Termination (exitCode)
Properly handle process termination to allow for debugging and correct status reporting.
DO:
- Use the
exitCodesetter to report failure. - Allow
mainto complete naturally. - Use standard exit codes (sysexits) for clarity (e.g.,
64for bad usage,
78 for configuration errors).
- See
package:ioExitCodeclass or FreeBSD sysexits man page.
AVOID:
- Calling
exit(code)directly, as it terminates the VM immediately,
preventing "pause on exit" debugging and finally blocks from running.
Exception Handling
Uncaught exceptions automatically set a non-zero exit code, but you should handle expected errors gracefully.
Example:
Cross-Platform Compatibility (Windows Support)
When writing CLI applications and tests, ensure compatibility with Windows:
- Paths: Never hardcode path separators like
/. Usepackage:path's
p.join or p.normalize to construct paths portably.
- File Permissions: When testing file permission errors, remember that
chmod is not available on Windows. Use icacls on Windows or appropriate mock libraries. Never skip tests on Windows simply because of permission commands if a Windows equivalent exists.
3. Recommended Packages
Use these community-standard packages owned by the Dart team to solve common CLI problems:
| Category | Recommended Package | Usage | |
|---|---|---|---|
| Stack Traces | `package:stack_trace` | detailed, cleaner stack traces | |
| Arg Parsing | `package:args` | standard flag/option parsing | |
| Testing | `package:test_process` | integration testing for CLI apps | |
| Testing | `package:test_descriptor` | file system fixtures for tests | |
| Networking | `package:http` | standard HTTP client (remember user-agent!) | |
| ANSI Output | `package:io` | handling ANSI colors and styles |
4. Interesting community packages
| Category | Recommended Package | Usage | |
|---|---|---|---|
| Configuration | `package:json_serializable` | strongly typed config objects | |
| CLI Generation | `package:build_cli` | generate arg parsers from classes | |
| Version Info | `package:build_version` | automatic version injection | |
| Configuration | `package:checked_yaml` | precise YAML parsing with line numbers |
5. Conventions
- File Caching: Write cached files to
.dart_tool/[pkg_name]/. - User-Agent: Always set a User-Agent header in HTTP requests, including
version info.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingbucket-water-oms-admin-mobile/tool/dart_skills_lint/.agents/skills/dart-cli-app-best-practices/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wishtohear/bucket-water-oms/dart-cli-app-best-practices)