CLI Reference
Complete command-line interface reference for DeviceSDK
Installation
Install the CLI via npm:
npm install -g @devicesdk/cli
Or use it directly with npx:
npx @devicesdk/cli [command]
Configuration
The CLI is configured through devicesdk.ts in your project root:
export default {
devices: {
'my-device': './src/devices/my-device.ts'
}
}
Most commands auto-discover this file by walking up from the current directory, so they work from any subdirectory of your project. The keys under devices are device slugs and the top-level projectId is the project slug — see Project & Device Identifiers for the conventions.
Global Flags
All commands support these global flags:
--config <path>- Path to config file (default:devicesdk.ts)--verbose- Enable verbose logging--help- Show help for a command
Environment Variables
DEVICESDK_TOKEN- API authentication tokenDEVICESDK_API_URL- API endpoint (default: production)
Available Commands
Development
- devicesdk init - Create a new project
Deployment
- devicesdk deploy - Deploy to production
- devicesdk flash - Flash firmware to device
Monitoring
- devicesdk status - Check device connection status
- devicesdk inspect - Interactive hardware REPL
Configuration
- devicesdk env - Manage project environment variables
Debugging
- devicesdk logs - View and stream device logs
Getting Help
Run any command with --help to see detailed usage:
npx @devicesdk/cli deploy --help
Exit Codes
The CLI uses stable numeric exit codes so scripts and CI pipelines can dispatch on failure type. These values will not be renumbered — new categories get new values.
| Code | Name | Meaning |
|---|---|---|
| 0 | SUCCESS | Command completed successfully |
| 1 | GENERIC | Unclassified error; treat as “retry or file a bug” |
| 2 | CONFIG_INVALID | Bad template, unknown/missing device, or invalid argument |
| 3 | NOT_AUTHENTICATED | No valid credentials; run devicesdk login |
| 4 | CONFIG_LOAD_FAILED | devicesdk.ts is missing, unparseable, or semantically wrong |
| 5 | BUILD_ERROR | esbuild bundling failed — check device script for TS errors |
| 6 | DEPLOY_ERROR | Script upload, firmware flash, or device-communication failure |