Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
fb0dca6
feat(cli): add modular CLI foundation (Wave 0)
yeldarby Apr 1, 2026
ffb0d9a
Add auth and workspace CLI handler modules
yeldarby Apr 1, 2026
68fc439
fix(cli): respect --json flag for --version output
yeldarby Apr 1, 2026
88ef877
Add project and version CLI handler modules
yeldarby Apr 1, 2026
2fbfe60
fix(cli): gracefully handle broken handler modules during auto-discovery
yeldarby Apr 1, 2026
fd60a4e
Add image and annotation CLI handler modules
yeldarby Apr 1, 2026
e4e189e
Add remaining CLI handlers: deployment, search, workflow, video, univ…
yeldarby Apr 1, 2026
ab7774d
Add model, train, and infer CLI handler modules
yeldarby Apr 1, 2026
fa921b4
Fix deployment handler to avoid fragile argparse internals
yeldarby Apr 1, 2026
5820b1c
Fix project list stdout pollution breaking --json output
yeldarby Apr 1, 2026
01eeaac
Fix 3 bugs and 1 rough-edge in auth and workspace handlers
yeldarby Apr 1, 2026
39c63b3
feat(cli): wire up backwards-compat aliases and integrate all handlers
yeldarby Apr 1, 2026
5266e4f
Fix QA feedback on image and annotation handlers
yeldarby Apr 1, 2026
b9315bb
Fix auth status env var fallback and workspace get member count
yeldarby Apr 1, 2026
2960cf8
fix(cli): address QA findings from Wave 3
yeldarby Apr 1, 2026
f30356e
Fix deployment help display, structured errors, and search stdout leak
yeldarby Apr 1, 2026
d5d1b48
Fix error handling in model and train handlers
yeldarby Apr 1, 2026
65f67f7
feat(cli): add suppress_sdk_output helper for --json/--quiet mode
yeldarby Apr 1, 2026
c45fd9b
docs: add DEVIATIONS.md documenting plan changes during implementation
yeldarby Apr 1, 2026
7ca9721
fix(cli): custom HelpFormatter hides legacy aliases, fix annotation s…
yeldarby Apr 2, 2026
406a19d
fix(cli): default annotation group and improve project get display
yeldarby Apr 2, 2026
edacf90
fix(cli): format epoch timestamps in project get output
yeldarby Apr 2, 2026
4649508
fix(cli): parse JSON error strings to avoid double-encoding in --json…
yeldarby Apr 2, 2026
142c25d
refactor(cli): centralize JSON error parsing in output_error
yeldarby Apr 2, 2026
a8203a1
fix(cli): add suppress_sdk_output and error handling to image/version…
yeldarby Apr 2, 2026
cca8809
fix(cli): extend suppress_sdk_output scope for image upload and versi…
yeldarby Apr 2, 2026
59ec057
fix(cli): always suppress SDK init noise in image upload and version …
yeldarby Apr 2, 2026
7b877cc
fix(cli): polish remaining rough edges from QA round 2
yeldarby Apr 2, 2026
c9bb74b
fix(cli): allow --json in any position, fix type choices, unwrap doub…
yeldarby Apr 2, 2026
2558170
feat(cli): add descriptive args to batch command stubs
yeldarby Apr 2, 2026
9ee05f0
fix(cli): whoami honors --api-key, normalize error JSON schema
yeldarby Apr 2, 2026
4b600f0
fix(cli): rewrite deployment handler with clean names, legacy shims h…
yeldarby Apr 2, 2026
1756e4e
fix(cli): workspace list falls back to API when no local config exists
yeldarby Apr 2, 2026
54f055f
fix(cli): project list/get auto-detect workspace from API key
yeldarby Apr 2, 2026
f213c87
fix(cli): add hint for non-image upload errors
yeldarby Apr 2, 2026
1d8ac14
fix(cli): address review feedback -- alias bug, stubs, output consist…
yeldarby Apr 2, 2026
9e93fcf
fix(cli): address remaining review items -- URL params, exit codes, t…
yeldarby Apr 2, 2026
a06a059
refactor(tests): consolidate alias and reorder_argv tests into test_d…
yeldarby Apr 2, 2026
11a2de2
security(cli): fix config file permissions and login alias api_key dest
yeldarby Apr 2, 2026
adfa656
fix(cli): add backwards-compat re-exports to roboflowpy.py shim
yeldarby Apr 2, 2026
b894bdf
fix(pre_commit): 🎨 auto format pre-commit hooks
pre-commit-ci[bot] Apr 2, 2026
7b4a4b1
chore: remove DEVIATIONS.md (internal planning doc, not needed in PR)
yeldarby Apr 2, 2026
71c530d
fix(cli): address Codex review - flag collision, missing args, compat
yeldarby Apr 2, 2026
edef1f3
docs: update CLAUDE.md, CLI-COMMANDS.md, CONTRIBUTING.md for modular CLI
yeldarby Apr 2, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 31 additions & 8 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,26 +84,49 @@ The Roboflow Python SDK follows a hierarchical object model that mirrors the Rob
- **rfapi** (`roboflow/adapters/rfapi.py`) - Low-level API communication
- **deploymentapi** (`roboflow/adapters/deploymentapi.py`) - Model deployment operations

### CLI Interface

The `roboflow` command line tool (`roboflow/roboflowpy.py`) provides:
- Authentication: `roboflow login`
- Dataset operations: `roboflow download`, `roboflow upload`, `roboflow import`
- Inference: `roboflow infer`
- Project/workspace management: `roboflow project`, `roboflow workspace`
### CLI Package (`roboflow/cli/`)

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`.

**Package structure:**
- `__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
- `_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
- `_table.py` — `format_table(rows, columns)` for columnar list output
- `_resolver.py` — `resolve_resource(shorthand)` for parsing `project`, `ws/project`, `ws/project/3`
- `handlers/` — One file per command group (auto-discovered). `_aliases.py` registers backwards-compat top-level commands (loaded last)

**Adding a new command:**
1. Create `roboflow/cli/handlers/mycommand.py`
2. Export `register(subparsers)` — it will be auto-discovered
3. Use lazy imports for heavy dependencies (inside handler functions, not at module top level)
4. Use `output()` for all output, `output_error()` for all errors
5. Wrap SDK calls in `with suppress_sdk_output():` to prevent "loading..." noise
6. Add tests in `tests/cli/test_mycommand_handler.py`

**Agent experience requirements for all CLI commands:**
- Support `--json` for structured output (stable schema)
- No interactive prompts when all required flags are provided
- Structured error output: `{"error": {"message": "...", "hint": "..."}}` on stderr
- Exit codes: 0 = success, 1 = error, 2 = auth error, 3 = not found
- Actionable error messages: always tell the user what went wrong AND what to do

**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.

### Key Design Patterns

1. **Hierarchical Access**: Always access objects through their parent (Workspace → Project → Version → Model)
2. **API Key Flow**: API key is passed down through the object hierarchy
3. **Format Flexibility**: Supports multiple dataset formats (YOLO, COCO, Pascal VOC, etc.)
4. **Batch Operations**: Upload and download operations support concurrent processing
5. **CLI Noun-Verb Pattern**: Commands follow `roboflow <noun> <verb>` (e.g. `roboflow project list`). Common operations have top-level aliases (`login`, `upload`, `download`)
6. **CLI Auto-Discovery**: Handler modules in `roboflow/cli/handlers/` are loaded automatically — no registration list to maintain
7. **Backwards Compatibility**: Legacy command names and flag signatures are preserved as hidden aliases

## Project Configuration

- **Python Version**: 3.8+
- **Main Dependencies**: See `requirements.txt`
- **Entry Point**: `roboflow=roboflow.roboflowpy:main`
- **Entry Point**: `roboflow=roboflow.roboflowpy:main` (shim delegates to `roboflow.cli.main`)
- **Code Style**: Enforced by ruff with Google docstring convention
- **Type Checking**: mypy configured for Python 3.8

Expand Down
Loading
Loading