> ## Documentation Index
> Fetch the complete documentation index at: https://radiusbrowser.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a workspace for every worktree

> Open chat, diffs, a terminal, and localhost in a reusable worktree layout.

Use project setup to give every new worktree the same browser workspace.

<Prompt description={"**Adapt this recipe to your project**  \nCopy a ready-to-use prompt for your coding agent."} icon="sparkles" iconType="solid" actions={["copy"]}>
  Adapt this recipe to the currently selected project:
  [https://radiusbrowser.com/docs/cookbook/worktree-workspace](https://radiusbrowser.com/docs/cookbook/worktree-workspace)

  If .radius/settings.toml does not exist, create it. Merge with existing settings
  instead of replacing them. If project metadata is unavailable, use the recipe
  defaults, including [http://localhost:3000](http://localhost:3000), and continue rather than stopping.

  Do not search outside the selected project. If it is not a Git repository,
  initialize one and create a first commit containing .radius/settings.toml.
  Include other existing files only when they are clearly safe to commit; never
  commit secrets, environment files, generated dependencies, or build output.

  Validate the resulting settings without running setup, then summarize the
  changes, the initial commit when one was needed, and any defaults you used.
</Prompt>

## What you'll build

You'll make it so that when you click the create worktree button in Radius, that
the setup script automatically opens two tab slots with two split tabs, opening
your chat, diff viewer, localhost, and terminal.

<video controls muted playsInline src="https://mintcdn.com/inspector-12805d8f/UfEFJHyUKRUXCcSJ/videos/worktree-workspace.mp4?fit=max&auto=format&n=UfEFJHyUKRUXCcSJ&q=85&s=ecacf028dd02fc9d02ee0f943fc67634" data-path="videos/worktree-workspace.mp4" />

## Before you start

* On a new tab, select **Work in a project** below the chat input, then choose
  your project.
* Choose the local URL your development server uses. This recipe defaults to
  `http://localhost:3000`.

## Configure the recipe

Add this directly to `.radius/settings.toml`, changing `DEV_URL` if your
development server uses a different address:

```toml theme={"theme":{"light":"github-light","dark":"github-dark"}}
[environment.variables]
DEV_URL = "http://localhost:3000"

[scripts]
setup = """
set -euo pipefail

: "${RADIUS_GROUP_ID:?This command must run during Radius worktree setup}"
: "${RADIUS_TAB_ID:?This command must run during Radius worktree setup}"
: "${RADIUS_WORKSPACE_NAME:?Radius did not provide a worktree name}"
: "${RADIUS_WORKSPACE_PATH:?Radius did not provide a worktree path}"

radius group rename "$RADIUS_GROUP_ID" "$RADIUS_WORKSPACE_NAME"

radius tab open "radius://diffs" \
  --project-path "$RADIUS_WORKSPACE_PATH" \
  --right-of "$RADIUS_TAB_ID" --size 50% --keep-anchor-active >/dev/null

localhost="$(radius tab open "${DEV_URL:-http://localhost:3000}" --background)"
terminal="$(radius tab open "radius://terminal" \
  --project-path "$RADIUS_WORKSPACE_PATH" --background)"

radius tab split "$localhost" \
  --right "$terminal" --size 50% --keep-anchor-active >/dev/null

radius tab focus "$RADIUS_TAB_ID"
"""
```

If the project already has a setup command, keep it in the same multiline
value and place these Radius commands after the existing commands.

## Try it

Create a new worktree in Radius. Radius runs the setup command from that
worktree, builds the two split tab slots, and leaves the chat ready for your
next message.

## How it works

* `RADIUS_TAB_ID` is the chat Radius opened for the new worktree. The setup
  command uses it as the first split anchor instead of opening another chat.
* Opening the diff viewer to the right of chat creates the first tab slot.
* The setup command opens localhost and the terminal as ordinary background
  tabs, then combines them into a second tab slot with `tab split`.
* `--project-path` explicitly tells chats, the diff viewer, and the terminal
  which worktree to open. The tab IDs determine layout only.
* Background opens avoid presenting temporary ordinary tabs before the second
  split is assembled. The final command explicitly restores focus to chat.

## Adapt it

Set a different `DEV_URL` in the same project settings block when the
development server uses another address.

You can also replace the localhost URL with any project-specific page without
changing the split commands.

To open another chat that is attached to the same worktree, use:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
radius tab open "radius://chat/" --project-path "$RADIUS_WORKSPACE_PATH"
```

If the development server is not running yet, Radius still opens the localhost
pane. Start the server from the terminal and reload the page when it is ready.
Because the setup command uses `set -e`, a failed Radius command stops setup
instead of leaving a partially configured workspace without reporting the
failure.
