Skip to content

feat: prevent duplicate agent PRs via claimed labels and umbrella issues #75

@don-petry

Description

@don-petry

Problem

During compliance remediation (2026-04-06), multiple autonomous agents independently picked up related compliance issues and produced overlapping/conflicting PRs:

This wasted effort and required manual triage to pick winners and close duplicates.

Solution: Claimed Labels + Umbrella Issues

1. Claimed labels (in-progress)

When an agent begins work on an issue, it immediately adds an in-progress label before writing any code. Other agents MUST skip issues with this label.

Changes needed:

  • Add in-progress label (color: #fbca04, description: "An agent is actively working this issue") to the standard label set in github-settings.md and apply-repo-settings.sh
  • Update AGENTS.md (org-level and per-repo) with the rule:
    Before starting work on any issue:
    1. Check if the issue has an `in-progress` label — if so, skip it
    2. Check if any open PR already references the issue — if so, skip it
    3. Add the `in-progress` label to the issue before writing code
    4. Remove the label if you abandon the issue without a PR
    
  • Update the Claude Code workflow to grant the claude job permission to add labels

2. Umbrella issues for compliance audit runs

The compliance audit script (compliance-audit.sh) should create a single umbrella issue per audit run that:

  • Lists all findings grouped by remediation category (not individual findings)
  • Links to the individual finding issues
  • Provides a suggested work breakdown so one agent handles related findings together

Remediation categories (group these together):

Category Findings Grouped Rationale
Repo settings allow_auto_merge, delete_branch_on_merge, has_wiki, has_discussions All fixed by apply-repo-settings.sh
Labels All missing-label-* findings All fixed by apply_labels() in one script
Rulesets missing-pr-quality, missing-code-quality Both managed by apply-rulesets.sh
Workflows missing-ci.yml, missing-codeql.yml, missing-agent-shield.yml, etc. Per-repo workflow additions
CLAUDE/AGENTS refs claude-md-missing-agents-ref, agents-md-missing-org-ref Per-repo doc updates
CODEOWNERS missing-codeowners Per-repo file addition

Changes needed in compliance-audit.sh:

  • After all findings are processed, emit a summary issue titled "Compliance audit — YYYY-MM-DD" with findings grouped by category
  • Each category links to the individual issues and names the remediation script/approach
  • Assign the claude label to the umbrella issue (not individual findings) to trigger one coordinated agent run

3. Agent file-conflict check

Add to AGENTS.md:

Before creating a new file, check if any open PR already creates that file:
  gh pr list --repo <repo> --state open --json files --jq '.[].files[].path' | grep <filename>
If found, comment on the existing PR instead of creating a competing one.

Acceptance criteria

  • in-progress label exists in standard label set and is created by apply-repo-settings.sh
  • Org-level AGENTS.md includes claim-before-work and file-conflict-check rules
  • compliance-audit.sh creates a grouped umbrella issue per audit run
  • Individual finding issues get the compliance-audit label but NOT the claude label
  • Only the umbrella issue gets the claude label to trigger coordinated remediation

Context

Discovered during review of 9 compliance PRs where 3 had to be closed as duplicates. See conversation on PRs #64, #65, #66 for details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    claudeFor Claude agent pickupenhancementFeature requests

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions