DevEnv CLI
Command-line interface for managing development environments
DevEnv CLI
The @mks-devenv/cli provides a command-line interface for creating, managing, and interacting with containerized development environments.
Installation
# From source
cd apps/devenv-cli
bun run build
bun link
# Or from npm (when published)
npm install -g @mks-devenv/cliQuick Start
Create a new environment:
devenv create myproject --template bun-typescriptAccess the environment:
- Browser: http://localhost:8443
- Shell:
devenv shell myproject
Manage your environment:
devenv status # View all environments
devenv logs myproject # View logs
devenv stop myproject # Stop environmentCommands
devenv create
Create a new development environment.
devenv create <name> [options]Options:
-t, --template <template>- Template to use (default:bun-typescript)-i, --ide <ide>- IDE type:code-server,jetbrains,none(default:code-server)-g, --git <url>- Git repository URL to clone-b, --branch <branch>- Git branch to checkout--no-start- Do not start after creation
Examples:
# Create with default template
devenv create myproject
# Create with specific template
devenv create myproject --template node-typescript
# Create and clone repository
devenv create myproject --git https://github.com/user/repo.git --branch main
# Create without starting
devenv create myproject --no-startWhat it creates:
- Docker volumes for workspace, config, and data
- Container with selected template and IDE
- Git repository (if specified)
- Persistent configuration
devenv start
Start an existing environment.
devenv start <name>Example:
devenv start myproject
# Access at: http://localhost:8443devenv stop
Stop a running environment.
devenv stop <name>devenv shell
Open an interactive shell in the environment.
devenv shell <name>Features:
- Full terminal access
- All development tools available
- Runs in current terminal
devenv logs
View logs from the environment.
devenv logs <name> [options]Options:
-f, --follow- Follow log output--tail <lines>- Number of lines to show (default: 100)
devenv list
List all development environments.
devenv listOutput format:
NAME STATUS TEMPLATE IDE PORTS
myproject running bun-ts code-server 8443, 3389
test-env stopped node-ts none -devenv status
Get detailed status of an environment.
devenv status <name>Shows:
- Container state
- Resource usage
- Port mappings
- Volume information
- Git status (if applicable)
devenv config
Manage DevEnv configuration.
devenv config [options]Options:
--get <key>- Get config value--set <key> <value>- Set config value--list- List all config
Config location: ~/.config/devenv/config.json
devenv destroy
Completely remove an environment.
devenv destroy <name>WARNING: This removes the container AND all persistent volumes. Data cannot be recovered!
Templates
Available templates for new environments:
| Template | Description | Runtime |
|---|---|---|
bun-typescript | Bun + TypeScript | Bun v1.x |
node-typescript | Node.js + TypeScript | Node.js 22 LTS |
custom | Custom base image | - |
IDE Options
| IDE | Description | Access |
|---|---|---|
code-server | VS Code in browser | http://localhost:8443 |
jetbrains | JetBrains Gateway | JetBrains Client |
none | CLI only | SSH/Shell |
Global Options
These options work with all commands:
devenv [command] --quiet # Suppress output
devenv [command] --debug # Enable debug output
devenv --version # Show version
devenv --help # Show helpConfiguration
Default configuration is stored in ~/.config/devenv/config.json:
{
"defaultTemplate": "bun-typescript",
"defaultIde": "code-server",
"images": {
"base": "mks-devenv-base:latest",
"codeServer": "mks-devenv-full:latest"
},
"ports": {
"codeServer": 8443,
"ssh": 2222,
"rdp": 3389
}
}Workflow Example
Complete development workflow:
# 1. Create new project
devenv create myapp --git https://github.com/user/myapp.git
# 2. Access in browser
open http://localhost:8443
# 3. Work in shell when needed
devenv shell myapp
# Inside: bun run dev
# 4. Monitor logs
devenv logs myapp --follow
# 5. Stop when done
devenv stop myapp
# 6. Clean up when project is finished
devenv destroy myappTroubleshooting
Docker not running
devenv create test
# Error: Docker is not running
# Solution: Start Docker DesktopPort already in use
devenv create myproject
# Error: Port 8443 already allocated
# Solution: Change port in config
devenv config --set ports.codeServer 8444Container won't start
devenv logs myproject --tail 100
# Check logs for errors
devenv status myproject
# Check resource usageIntegration with tmux Utilities
The CLI integrates seamlessly with the custom tmux utilities:
# Create environment in tmux session
cx myproject
tx myproject "devenv create myproject --git https://github.com/user/repo.git"
txout myproject 100 # Watch the output
# Run dev server in background
tx myproject "bun run dev" --no-wait
# Check logs anytime
txout myprojectExit Codes
0- Success1- Error (see error message for details)2- Invalid usage3- Docker not available4- Resource not found