Skip to content

Multi-repo workflows: repo picker + global worktree switch/list (and expose project_identifier to templates) #980

@prateek

Description

@prateek

Summary

I use Worktrunk daily, but across many repositories, and I’d love guidance (or upstream support) for “multi-repo” workflows: pick a repo, then create/switch/list worktrees without first cd’ing into that repo.

Worktrunk’s per-repo UX is excellent (wt switch picker, wt list --full, hooks, CI links). The gap for me is “which repo?” + “show/switch existing worktrees across repos”.

Current workaround (wrapper)

I wrote a thin zsh wrapper w that:

  • Selects a repo (fzf over a local index of canonical clones)
  • Sets a centralized worktree root per invocation (so worktrees from many repos live under one root)
  • Defers the core operations to Worktrunk (wt -C <repo_root> switch …)

It also adds:

  • w <branch> → create/switch + cd (multi-repo by default)
  • w <branch> -- <agent args…> → create/switch + run an agent command (via wt switch -x …)
  • w switch → fzf-pick an existing worktree directory (across repos) and cd into it
  • w ls → a lightweight cross-repo listing for the centralized root (coarse; rich status still comes from wt list)

Wrapper code/docs (for concrete context):

  • https://github.com/prateek/dotfiles/blob/master/zsh/autoload/w
  • https://github.com/prateek/dotfiles/blob/master/zsh/autoload/repo_select
  • https://github.com/prateek/dotfiles/blob/master/docs/worktrees.md

Questions / potential upstream improvements

  1. Is a wrapper the intended approach for multi-repo workflows?

If yes: are there recommended extension points (config conventions, helper commands, JSON output fields, etc.) to make wrappers more robust?

  1. Expose a “repo slug” to templates

Worktrunk already has a stable “project identifier” (used for [projects."…"] and approvals), typically like github.com/owner/repo.

Could Worktrunk expose something like:

  • {{ project_identifier }} (or {{ project }} / {{ repo_slug }})

…as a template variable for worktree-path (and/or hook templates)?

This would make it easy to create a collision-free centralized layout across many repos (and hosts) without custom code:

# ~/.config/worktrunk/config.toml
worktree-path = "~/code/wt/{{ project_identifier | sanitize }}/{{ repo }}/{{ branch | sanitize }}"

Today, a centralized template like ~/worktrees/{{ repo }}/{{ branch | sanitize }} can collide if you have multiple repos with the same directory name.

  1. Optional multi-repo list/switch

Would you be open to an opt-in “workspace” concept, e.g.:

  • wt list --workspace <dir>: scan a centralized worktree root and show an aggregated table (maybe by grouping by git common dir / repo)
  • wt switch --workspace <dir> (or --repos-from <file|cmd>): interactive picker over (repo, branch) pairs

Even if it’s out of scope, I’d love to know if there’s a preferred direction.

Notes

  • I searched issues for “multi repo”, “workspace”, “global list”, “repo picker”, etc. and didn’t see an obvious duplicate; happy to be pointed at an existing thread if I missed it.
  • This issue is intentionally sanitized (no private repo names/paths); I can provide more details if useful.
  • This draft was generated with the help of AI tools and then reviewed by a human; any mistakes or “slop” are the human author’s responsibility.

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