Skip to content

Docs: mention managed port/DB/compose isolation as a create-hook option? #3358

Description

@rohansx

worktrunk's hook docs are great — the pre-start + {{ branch | hash_port }}.env.local example is a clean per-worktree port setup.

Running several agent worktrees at once, I hit two limits with the stateless approach: hash_port can collide across branches (there's no record of what's already taken), and I also wanted each worktree to get its own Postgres database + COMPOSE_PROJECT_NAME, so multiple docker compose ups don't clash.

I built a small single-binary tool for that layer — workz — that slots straight into a pre-start hook:

# .config/wt.toml
pre-start = "workz sync --isolated --quiet"

It allocates a collision-free port range from a small registry (not a hash), plus DB_NAME / COMPOSE_PROJECT_NAME / a DATABASE_URL derived from your existing one, merged idempotently into .env.local alongside any existing secrets.

Two questions:

  1. Would you be open to a one-line "see also" in hook.md for people who need managed port/DB/compose isolation? Totally fine to keep the docs tool-agnostic — happy to just leave this here for anyone who searches.
  2. Is registry-backed (vs. stateless-hash) port allocation ever something worktrunk would want natively? If so I'm glad to share notes on the aligned-range + collision-check approach.

Either way, thanks for worktrunk — the hook design is a nice thing to build on.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions