MKS DevEnv

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/cli

Quick Start

Create a new environment:

devenv create myproject --template bun-typescript

Access the environment:

Manage your environment:

devenv status        # View all environments
devenv logs myproject # View logs
devenv stop myproject # Stop environment

Commands

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-start

What 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:8443

devenv 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 list

Output 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:

TemplateDescriptionRuntime
bun-typescriptBun + TypeScriptBun v1.x
node-typescriptNode.js + TypeScriptNode.js 22 LTS
customCustom base image-

IDE Options

IDEDescriptionAccess
code-serverVS Code in browserhttp://localhost:8443
jetbrainsJetBrains GatewayJetBrains Client
noneCLI onlySSH/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 help

Configuration

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 myapp

Troubleshooting

Docker not running

devenv create test
# Error: Docker is not running

# Solution: Start Docker Desktop

Port already in use

devenv create myproject
# Error: Port 8443 already allocated

# Solution: Change port in config
devenv config --set ports.codeServer 8444

Container won't start

devenv logs myproject --tail 100
# Check logs for errors

devenv status myproject
# Check resource usage

Integration 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 myproject

Exit Codes

  • 0 - Success
  • 1 - Error (see error message for details)
  • 2 - Invalid usage
  • 3 - Docker not available
  • 4 - Resource not found

Actions

On this page