Skip to content

feat: add port allocation for task worktrees#104

Merged
bborn merged 1 commit intomainfrom
task/207-tasks-app-should-be-able-to-run-repo
Jan 11, 2026
Merged

feat: add port allocation for task worktrees#104
bborn merged 1 commit intomainfrom
task/207-tasks-app-should-be-able-to-run-repo

Conversation

@bborn
Copy link
Copy Markdown
Owner

@bborn bborn commented Jan 11, 2026

Summary

  • Add unique port allocation (3100-4099) for each task worktree to avoid port conflicts
  • Pass environment variables (TASK_ID, TASK_PORT, TASK_WORKTREE_PATH) to Claude when executing tasks
  • Ports are reused when tasks are marked as done
  • Document how to configure Rails apps (or any application) to use these variables

Test plan

  • Tests for port allocation functions pass
  • Tests for port reuse when tasks complete pass
  • All existing tests still pass
  • Manual testing: create multiple tasks and verify unique ports are allocated
  • Manual testing: verify Rails app can boot on $TASK_PORT

🤖 Generated with Claude Code

Each task now gets a unique port (from range 3100-4099) allocated when
its worktree is set up. This enables running applications in isolation
without port conflicts between concurrent tasks.

Environment variables passed to Claude:
- TASK_ID: Task identifier for hooks
- TASK_PORT: Unique port for running the application
- TASK_WORKTREE_PATH: Path to the task's git worktree

Applications can use these environment variables to:
- Boot on the unique port (e.g., PORT=$TASK_PORT bin/dev)
- Configure isolated databases (e.g., myapp_db_$TASK_ID)
- Avoid conflicts with other running task worktrees

Ports are reused when tasks are marked as done.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@bborn bborn force-pushed the task/207-tasks-app-should-be-able-to-run-repo branch from 62d33d1 to 239998a Compare January 11, 2026 17:56
@bborn bborn merged commit df78613 into main Jan 11, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant