You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: update CLAUDE.md, CLI-COMMANDS.md, CONTRIBUTING.md for modular CLI
- CLAUDE.md: Replace old CLI section with full modular architecture docs
(package structure, handler pattern, agent experience requirements,
documentation policy)
- CLI-COMMANDS.md: Rewrite as concise quickstart linking to docs.roboflow.com
for full reference. Covers install, global flags, common examples, --json
for agents, resource shorthand, backwards compat table.
- CONTRIBUTING.md: Add CLI Development section with handler template,
agent experience checklist, and documentation policy.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CLI is a modular package with auto-discovered handler modules. `roboflow/roboflowpy.py` is a backwards-compatibility shim that delegates to `roboflow.cli.main`.
90
+
91
+
**Package structure:**
92
+
-`__init__.py` — Root parser with global flags (`--json`, `--workspace`, `--api-key`, `--quiet`), auto-discovery via `pkgutil.iter_modules`, custom `_CleanHelpFormatter`, and `_reorder_argv` for flexible flag positioning
93
+
-`_output.py` — `output(args, data, text)` for JSON/text output, `output_error(args, msg, hint, exit_code)` for structured errors, `suppress_sdk_output()` to silence SDK noise, `stub()` for unimplemented commands
94
+
-`_table.py` — `format_table(rows, columns)` for columnar list output
95
+
-`_resolver.py` — `resolve_resource(shorthand)` for parsing `project`, `ws/project`, `ws/project/3`
96
+
-`handlers/` — One file per command group (auto-discovered). `_aliases.py` registers backwards-compat top-level commands (loaded last)
97
+
98
+
**Adding a new command:**
99
+
1. Create `roboflow/cli/handlers/mycommand.py`
100
+
2. Export `register(subparsers)` — it will be auto-discovered
101
+
3. Use lazy imports for heavy dependencies (inside handler functions, not at module top level)
102
+
4. Use `output()` for all output, `output_error()` for all errors
103
+
5. Wrap SDK calls in `with suppress_sdk_output():` to prevent "loading..." noise
104
+
6. Add tests in `tests/cli/test_mycommand_handler.py`
105
+
106
+
**Agent experience requirements for all CLI commands:**
107
+
- Support `--json` for structured output (stable schema)
108
+
- No interactive prompts when all required flags are provided
- Exit codes: 0 = success, 1 = error, 2 = auth error, 3 = not found
111
+
- Actionable error messages: always tell the user what went wrong AND what to do
112
+
113
+
**Documentation policy:**`CLI-COMMANDS.md` in this repo is a quickstart only. The full command reference lives in `roboflow-product-docs` (published to docs.roboflow.com). When adding commands, update both.
94
114
95
115
### Key Design Patterns
96
116
97
117
1.**Hierarchical Access**: Always access objects through their parent (Workspace → Project → Version → Model)
98
118
2.**API Key Flow**: API key is passed down through the object hierarchy
0 commit comments