Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Commit c8f1528

Browse files
matejvasekclaude
andcommitted
docs: add --randomize-ports flag and agent awareness to init.sh spec
Port randomization is opt-in via --randomize-ports so human testers get predictable defaults. Agents discover ports via .dev-env.json, referenced in CLAUDE.md, WORKFLOW.md, and init-session command. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e8ec5ca commit c8f1528

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

docs/superpowers/specs/2026-05-14-better-init-sh-design.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ Multiple repos/worktrees running dev environments simultaneously. Each gets its
2929

3030
**New:**
3131

32-
- On startup, init.sh picks three random available ports from range 10000-60000
32+
- By default, init.sh uses the same hardcoded defaults as today (8080, 9001, 9000) so human testers are not surprised
33+
- When `--randomize-ports` flag is passed, init.sh picks three random available ports from range 10000-60000
3334
- A `random_free_port()` helper function loops until it finds an unused port (TCP probe check)
34-
- Ports written to `.dev-env.json` at project root:
35+
- `.dev-env.json` is always written at project root, regardless of whether ports are randomized or default:
3536
```json
3637
{
3738
"backendPort": 12345,
@@ -82,15 +83,26 @@ PLUGIN_PORT="$PLUGIN_PORT" yarn start > "$LOG_DIR/webpack.log" 2>&1 &
8283
> "$LOG_DIR/console.log" 2>&1 &
8384
```
8485

86+
### 5. Agent Awareness
87+
88+
Agents need to know where the dev server is running so they can connect to it (e.g. for browser testing or API calls).
89+
90+
- **CLAUDE.md**: Add `.dev-env.json` to the knowledge base table, noting it contains the running dev server ports
91+
- **WORKFLOW.md**: Add a step to the Startup Sequence (after "Run `./init.sh`") to read `.dev-env.json` and note the ports
92+
- **`.claude/commands/init-session.md`**: Add a step to read `.dev-env.json` and report the ports to the user
93+
8594
## Files Modified
8695

8796
| File | Change |
8897
|------|--------|
89-
| `init.sh` | PID files, random port allocation, `.dev-env.json` output, inotifywait backend watcher, pass ports downstream, `--stop` reads PIDs/CID |
98+
| `init.sh` | PID files, `--randomize-ports` flag, `.dev-env.json` output, inotifywait backend watcher, pass ports downstream, `--stop` reads PIDs/CID |
9099
| `start-console.sh` | Accept `--backend-port`, `--plugin-port`, `--console-port` CLI args with fallback defaults |
91100
| `webpack.config.ts` | Read `PLUGIN_PORT` env var with fallback to 9001 |
92101
| `.gitignore` | Add `.dev-pids/` and `.dev-env.json` |
93102
| `.dockerignore` | Add `.dev-pids/` and `.dev-env.json` |
103+
| `CLAUDE.md` | Add `.dev-env.json` to knowledge base table |
104+
| `docs/WORKFLOW.md` | Add port discovery step to Startup Sequence |
105+
| `.claude/commands/init-session.md` | Add step to read and report dev server ports |
94106

95107
No new files created (besides runtime artifacts which are gitignored/dockerignored).
96108

0 commit comments

Comments
 (0)