Skip to content

Add Beads integration for Git worktrees #32

@v2nic

Description

@v2nic

Problem

Beads is tied to Git worktrees because bd init cannot run inside a worktree:

Error: cannot run 'bd init' from within a git worktree

Git worktrees share the .beads database from the main repository.

This makes it cumbersome to use Beads with Git Workbench's worktree-based workflow.

Solution

Add optional Beads integration to Git Workbench that automatically manages Beads lifecycle across repositories and worktrees.

Core features

  • Automatic base initialization: When a new repository is created or cloned, run bd init in the bare repository directory
  • Worktree awareness: When creating worktrees, ensure Beads is initialized in the parent bare repo
  • Startup guard: If Beads is enabled in config but bd is not installed, refuse to start with a clear error message

Shared database (default)

By default, all worktrees share a single Beads database from the bare repository ($git-root/repo-name.git/.beads). This is the Beads-recommended behavior.

A shareBetweenWorktrees option can be set globally or per-repo to give each worktree its own independent database:

{
  "beads": {
    "enabled": true,
    "shareBetweenWorktrees": false
  }
}

Per-repo override:

{
  "repos": [
    {
      "repoName": "standalone-project",
      "beads": {
        "enabled": true,
        "shareBetweenWorktrees": false
      }
    }
  ]
}

Worktree creation toggle

The Create Worktree dialog should include a "Share beads with main repo" toggle. Default resolution: repo override → global config → true.

Configuration

Beads is disabled by default. Enable via data/repos-tracked.json:

{
  "beads": {
    "enabled": true,
    "shareBetweenWorktrees": true
  }
}

Behavior matrix

Action Behavior
New repo created bd init --prefix <repo-name> -q in bare repo dir
Repo cloned bd init after clone completes
Worktree created (shared) Ensure bare repo has .beads; no per-worktree init
Worktree created (not shared) bd init --prefix <repo-name>-<worktree-name> -q in worktree dir
App startup Validate bd installed if Beads enabled anywhere
Init failure Log warning, do not block repo/worktree creation

Files to change

  • src/types/config.tsBeadsConfig interface (enabled, shareBetweenWorktrees)
  • src/lib/config.ts — Default config, startup validation
  • src/lib/beads.ts — Core helper module (new file)
  • src/app/api/repos/create/route.ts — Init Beads after repo creation
  • src/app/api/clone/route.ts — Init Beads after clone
  • src/app/api/worktrees/create/route.ts — Accept shareBeads, init accordingly
  • src/app/api/worktrees/route.ts (POST) — Same
  • src/app/api/worktrees/create-from-branch/route.ts — Same
  • src/app/api/worktrees/create-from-main/route.ts — Same
  • src/app/_client/components/CreateWorktreeModal.tsx — "Share beads" toggle
  • README.md — Documentation

Requirements

References

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