# What Is the Purpose of the Dev Script in OpenWork? A Complete Development Guide

> Understand the purpose of the dev script in OpenWork. This guide explains how it enables hot-reloading, remote debugging, and custom configurations for efficient local development.

- Repository: [Different AI/openwork](https://github.com/different-ai/openwork)
- Tags: how-to-guide
- Published: 2026-08-01

---

**The `dev` script in the OpenWork repository launches the desktop application in local development mode, enabling hot-reloading, Chrome DevTools remote debugging, and development-specific configuration through environment variables.**

The `dev` script serves as the primary entry point for developers working on OpenWork, an open-source desktop application built by different-ai. As implemented in the different-ai/openwork repository, this script orchestrates the entire development environment with a single command, making it essential for feature development and UI iteration.

## Core Functions of the OpenWork Dev Script

Running `pnpm dev` from the repository root executes three critical operations:

1. **Enables Development Mode** – Sets `OPENWORK_DEV_MODE=1`, which activates development-only configuration including mock services, relaxed security policies, and hot-reloading capabilities.

2. **Exposes Remote Debugging** – Assigns `OPENWORK_ELECTRON_REMOTE_DEBUG_PORT` (defaulting to port 9823) to allow inspection of the Electron renderer process using Chrome DevTools.

3. **Boots the Desktop Application** – Executes `pnpm --filter @openwork/desktop dev`, which runs the desktop workspace in watch mode, automatically rebuilding and reloading when source files change.

## How to Use the Dev Script in OpenWork

### Starting the Development Environment

The standard command to launch OpenWork locally:

```bash
pnpm dev

```

This single command initializes the full desktop environment with live-reloading enabled.

### Customizing the Debug Port

Override the default remote debug port (9823) by setting the environment variable before execution:

```bash
OPENWORK_ELECTRON_REMOTE_DEBUG_PORT=9234 pnpm dev

```

### Alternative Development Commands

OpenWork provides additional development scripts for specific scenarios:

- **`pnpm run dev:ui`** – Starts the web UI (`@openwork/app`) without the Electron wrapper, useful for browser-only testing.

- **`pnpm dev:electron:two`** – Launches a demonstration with two Electron windows side-by-side, facilitating multi-window interaction testing.

## Key Files Supporting the Dev Script

The development workflow relies on several configuration files across the monorepo:

- **[`dev/package.json`](https://github.com/different-ai/openwork/blob/main/dev/package.json)** – Contains the central script definition at line 6, registering the top-level `dev` command.

- **[`apps/desktop/package.json`](https://github.com/different-ai/openwork/blob/main/apps/desktop/package.json)** – Defines the desktop-specific `dev` script that actually initializes the Electron application.

- **`scripts/electron-dev.mjs`** – Helper script that configures and boots Electron with proper environment variable injection.

- **[`apps/app/package.json`](https://github.com/different-ai/openwork/blob/main/apps/app/package.json)** – Provides the `dev` script for the browser-based UI layer (`@openwork/app`).

- **[`apps/ui-demo/package.json`](https://github.com/different-ai/openwork/blob/main/apps/ui-demo/package.json)** – Offers a lightweight UI demo environment for rapid component testing.

## Summary

- The `dev` script in [`dev/package.json`](https://github.com/different-ai/openwork/blob/main/dev/package.json) is the canonical entry point for OpenWork development.

- It sets `OPENWORK_DEV_MODE=1` and `OPENWORK_ELECTRON_REMOTE_DEBUG_PORT=9823` to enable debugging and development features.

- The script filters to the `@openwork/desktop` workspace to launch the Electron application in watch mode.

- Alternative commands like `dev:ui` and `dev:electron:two` support specific testing scenarios without the full desktop wrapper.

## Frequently Asked Questions

### What does the dev script do in OpenWork?

The `dev` script initializes the complete OpenWork development environment by configuring development-specific environment variables and launching the Electron desktop application with hot-reloading enabled. It serves as the main entry point for developers building features or debugging the application locally.

### How do I change the debug port when running pnpm dev?

Set the `OPENWORK_ELECTRON_REMOTE_DEBUG_PORT` environment variable before executing the command. For example, run `OPENWORK_ELECTRON_REMOTE_DEBUG_PORT=9234 pnpm dev` to use port 9234 instead of the default 9823, allowing you to inspect the Electron renderer process in Chrome DevTools.

### What is the difference between pnpm dev and pnpm run dev:ui?

Running `pnpm dev` launches the full Electron desktop application with all development features, while `pnpm run dev:ui` starts only the web UI layer (`@openwork/app`) in a browser without the Electron wrapper. Use `dev:ui` for frontend-only work and `pnpm dev` for full desktop integration testing.

### Where is the dev script defined in the OpenWork codebase?

The primary `dev` script is defined in [`dev/package.json`](https://github.com/different-ai/openwork/blob/main/dev/package.json) at line 6, which references the workspace filter for `@openwork/desktop`. The actual Electron execution logic resides in [`apps/desktop/package.json`](https://github.com/different-ai/openwork/blob/main/apps/desktop/package.json) and the helper script at `scripts/electron-dev.mjs`.