Skip to content

feat(repos): add devops repos worktrees add that refuses an issue another agent already holds #2337

Description

@dan-petty

Problem or Motivation

Agents work in parallel, each in its own git worktree. Nothing creates a worktree in a standard way, and nothing tells an agent that another agent already works on an issue.

Evidence from devops repos worktrees status --json on this host (125 worktrees besides the main one):

  • 107 are under ~/.gemini/antigravity/worktrees/, 12 under .data/agent/worktrees/, 3 under .claude/worktrees/, 1 under .kilo/worktrees/, and 2 elsewhere. CONTRIBUTING.md says that a worktree goes under .data/agent/, but each agent tool picks its own root.
  • Branch and directory names follow no rule: implement_issue_five_ninety_six holds branch implement_issue_five_ninety_six, while implement_issue_eleven_forty holds fix/1140-scanner-failed-manifest. The pre-commit hook requires <type>/<issue>-<slug> only at commit time.
  • A person or agent cannot tell from the name whether an issue has an owner. Two agents can start the same issue, and the loser finds out at the pull request.

Proposed Solution & Architectural Design

Add devops repos worktrees add <issue> [--type fix|feat|...] [--slug <slug>].

  • It fetches origin/main and creates the worktree under .data/agent/worktrees/w-<issue> on the branch <type>/<issue>-<slug>, based on origin/main. This follows the rule "branch current before first push".
  • It first looks for a claim on the issue and refuses when it finds one. A claim is any of: a worktree in git worktree list whose branch matches */<issue>-*; a remote branch origin/*/<issue>-*; an open pull request that closes the issue. The error names the holder (path, branch or pull request number).
  • --dry-run prints the claim check and the planned git commands and makes no request.
  • status marks a worktree by its issue number, so a person sees the owner of each issue.

Target Subsystem

SDLC, Git & PR Governance

Existing Tool Considered

git worktree add creates the worktree and is the only git command used. No open tool checks for a claim on an issue: gh issue develop links a branch to an issue but does not refuse a second branch. The claim check reads git worktree list, git ls-remote and devops pr list, and adds no new dependency.

Activity

  1. added
    source/agent
    type/feature
    on Oct 27, 2026
  2. dan-petty commented on Oct 27, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones on the board.

    • Type: type/feature. The candidate adds a new command with new functionality for managing worktrees and claims.
    • Priority: P2-Medium. The change helps with parallel agent work and prevents conflicts. It is important but not critical.
    • Value: High. The change helps agents avoid working on the same issue and improves workflow coordination.
    • Effort: Medium. Adding a new command with claim checking logic and git operations requires moderate effort.
    • Related: feat(repos): Add a gitea remote to every clone under repos/ #1090, which asks for a different change. Both items relate to repository management but the candidate focuses on worktree handling while item #1090 focuses on remote setup.
  3. added 2 commits that reference this issue on Oct 27, 2026
    a3b164d
    c845583
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    source/agenttype/feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions