You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -126,3 +126,42 @@ Clean up Docker containers:
126
126
}
127
127
}
128
128
```
129
+
130
+
## Workspace Environment Variables
131
+
132
+
Array automatically sets environment variables in all workspace terminals and scripts. These are available in `init`, `start`, and `destroy` scripts, as well as any terminal sessions opened within a workspace.
133
+
134
+
| Variable | Description | Example |
135
+
|----------|-------------|---------|
136
+
|`ARRAY_WORKSPACE_NAME`| Worktree name, or folder name in root mode |`my-feature-branch`|
137
+
|`ARRAY_WORKSPACE_PATH`| Absolute path to the workspace |`/Users/dev/.array/worktrees/repo/my-feature`|
138
+
|`ARRAY_ROOT_PATH`| Absolute path to the repository root |`/Users/dev/repos/my-project`|
139
+
|`ARRAY_DEFAULT_BRANCH`| Default branch detected from git |`main`|
140
+
|`ARRAY_WORKSPACE_BRANCH`| Initial branch when workspace was created |`array/my-feature`|
141
+
|`ARRAY_WORKSPACE_PORTS`| Comma-separated list of allocated ports |`50000,50001,...,50019`|
142
+
|`ARRAY_WORKSPACE_PORTS_RANGE`| Number of ports allocated |`20`|
143
+
|`ARRAY_WORKSPACE_PORTS_START`| First port in the range |`50000`|
144
+
|`ARRAY_WORKSPACE_PORTS_END`| Last port in the range |`50019`|
145
+
146
+
Note: `ARRAY_WORKSPACE_BRANCH` reflects the branch at workspace creation time. If you or the agent checks out a different branch, this variable will still show the original branch name.
147
+
148
+
### Port Allocation
149
+
150
+
Each workspace is assigned a unique range of 20 ports starting from port 50000. The allocation is deterministic based on the task ID, so the same workspace always receives the same ports across restarts.
151
+
152
+
### Usage Examples
153
+
154
+
Use ports in your start scripts:
155
+
```json
156
+
{
157
+
"scripts": {
158
+
"start": "npm run dev -- --port $ARRAY_WORKSPACE_PORTS_START"
0 commit comments