# VS Code Sessions

> Source: https://parallelworks.com/docs/run/sessions/vscode

# VS Code Sessions

There are two ways to use VS Code on a compute resource. Both run on the resource itself, so your code, data, and processes stay on the cluster:

| Method | Where it runs | Where you use it | Best for |
| --- | --- | --- | --- |
| **VS Code session** | VS Code server on the resource | Your web browser | Editing and running code with zero local setup |
| **`pw vscode`** | Your _local_ VS Code app | Your computer | Working in your own VS Code — with all your extensions and settings — connected over SSH |

Looking for a graphical desktop instead? See [Desktop Sessions](/docs/run/sessions/desktops).

:::info The resource must be running
A resource (a compute cluster or your user workspace) must be **running** before you can launch a VS Code session on it.
:::

## VS Code in the browser

A **VS Code session** runs a VS Code server on the resource and opens it in your browser, so there's nothing to install on your computer.

### Launch from a cluster (Quick Launch)

1. Open your cluster and find the **Quick Launch** panel (_Open this cluster in your browser_).
2. On the **VS Code** card, click **Launch**.
3. _(Optional)_ Set a **Directory** to open — for example `~/projects`. Leave it blank to open your home directory.
4. Click **Launch**.

### Launch from the Sessions page

1. Go to **Sessions** and click **New Session**.
2. Choose **VS Code** as the session type.
3. Pick the **Target** resource (a compute cluster or your user workspace).
4. _(Optional)_ Set a **Directory** and a **Name**.
5. Click **Launch**.

ACTIVATE installs and starts the VS Code server on the resource — you'll see the status move through _installing_ → _starting_ → _running_. Once it's running, VS Code opens in an embedded view on the session page. Click **Open in new tab** for a full-window editor.

:::tip
VS Code sessions work on both compute clusters and your user workspace. For lightweight editing, the user workspace is a quick option that doesn't require starting a cluster.
:::

## Connect your local VS Code with `pw vscode`

If you'd rather work in the VS Code app already installed on your computer — with your own keybindings, themes, and extensions — use the **`pw vscode`** command. It connects your local VS Code to the resource using VS Code's **Remote-SSH** extension, with the connection routed securely through ACTIVATE.

### Prerequisites

- The **PW CLI** installed and authenticated. See [About the PW CLI](/docs/cli).
- **VS Code** installed locally with the **`code`** command on your PATH. In VS Code, open the command palette (`Cmd/Ctrl+Shift+P`) and run **Shell Command: Install 'code' command in PATH**.
- The **Remote-SSH** extension installed in VS Code.

### Usage

```bash
# Open VS Code on a resource
pw vscode my-cluster

# Open a specific directory
pw vscode my-cluster /home/user/project

# Open VS Code on another user's resource
pw vscode pw://otheruser/their-cluster
```

When you run the command, the PW CLI:

1. Registers your SSH key with the platform (if it isn't already).
2. Writes an SSH host entry to `~/.ssh/pw_config` (included from your `~/.ssh/config`) that proxies the connection through ACTIVATE.
3. Launches VS Code and connects it to the resource via Remote-SSH, opening the directory you specified — or your home directory by default.

See the [`pw vscode` command reference](/docs/cli/pw/vscode) for the full list of arguments.

## Which should I use?

- Use a **VS Code session** when you want zero local setup — everything runs in the browser.
- Use **`pw vscode`** when you want your own local VS Code, extensions, and settings, connected to the resource.
