Skip to content

feat(repos): worktrees add takes over the staged branch of an issue instead of refusing it #2657

Description

@dan-petty

Problem or Motivation

Parent: #2653. devops repos worktrees add refuses an issue when origin holds a branch <type>/<issue>-<slug> for it (#2337). After the stage job (#2654) pushes such a branch, no agent can make the worktree of a staged item, and the staged change is lost to them.

Proposed Solution & Architectural Design

  • worktrees add <issue> reads the pushed branch of the issue. When every commit past origin/<default> has the App's bot login as its author (service.github_app.slug with the [bot] suffix), the command takes the branch over: it makes the worktree on that branch, tracking origin, and reports that it took over a staged branch with the number of commits. A branch with a commit by any other author is refused as today, naming the author.
  • When the staged branch exists, the command takes type and slug from it. A --type or --slug that differs from the branch is an error that names the branch.
  • A stopped implement run (the sibling job of the parent) leaves the App's code commits on the branch. The same rule takes them over, so an agent continues where the job stopped.
  • --dry-run lists the ls-remote and log reads it makes.
  • CONTRIBUTING.md ("Naming", the worktree row), docs/ROUTINE_TASKS.md and docs/SDLC.md Phase 1 say that worktrees add takes over a staged branch.

Target Subsystem

src/devops_cli/git/worktree_add.py, src/devops_cli/commands/repos.py.

Existing Tool Considered

git (ls-remote, log --format=%an, worktree add --track). Nothing new is built.

Acceptance criteria

  • With git faked at the process edge, worktrees add on an issue whose pushed branch holds only the App's commits makes the worktree on that branch and reports the takeover.
  • A pushed branch with one commit by another author is refused, naming the author.
  • A --slug that differs from the slug of the staged branch is an error.
  • uv run devops ci passes, and devops docs generate --sync-readme is run.

Depends on: #2654.

Source: #2653

Activity

  1. added
    source/agent
    type/feature
    status/new
    value/medium
    effort/medium
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 2026

    @dan-petty
    OwnerAuthor

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

    • Type: type/feature. The title uses the feat prefix and the body proposes new behaviour for worktrees add.
    • Priority: P2-Medium. It blocks the agent workflow after a stage job pushes a branch, but it is one step in the pipeline, not a total outage.
    • Value: Medium. It unblocks agents from creating worktrees on staged items, which is a recurring step in the SDLC.
    • Effort: Medium. It needs author-check logic, error paths for conflicting flags, dry-run output, docs updates, and tests with faked git.
    • Related: feat(cli): worktree inventory & safe orphan reclamation (devops repos worktrees) #700, which asks for a different change. Both target the devops repos worktrees subsystem, but 700 adds inventory and orphan reclamation while this adds branch takeover on add.
  3. added
    priority/p2-medium
    on Oct 29, 2026
  4. removed
    status/new
    on Oct 30, 2026
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

    effort/mediumpriority/p2-mediumsource/agenttype/featurevalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions