Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix(ci): let triage own all new issues to avoid mention/triage race (#1556)

worktrunk-botad08ff4a911c
diff --git a/.github/CLAUDE.md b/.github/CLAUDE.md
index 0d2f3fe24..b910dab50 100644
--- a/.github/CLAUDE.md
+++ b/.github/CLAUDE.md
@@ -119,9 +119,13 @@ This is why release secrets must be in a protected environment, not repo-level s
## Triage ↔ mention handoff
-These two workflows explicitly exclude each other to avoid double-processing:
-- Issue body contains `@worktrunk-bot` → triage skips, mention handles it
-- Issue body does not contain `@worktrunk-bot` → triage handles it, mention ignores it
+New issues are always handled by the triage workflow — `claude-mention` only
+triggers on issue **edits** (not opens) to avoid two workflows racing to create
+fix PRs for the same bug.
+
+- **New issue** (opened) → triage handles it, regardless of `@worktrunk-bot` mentions
+- **Issue edited** to add `@worktrunk-bot` → mention handles it
+- **Comment** on an issue/PR → mention handles it (via `issue_comment` trigger)
The mention workflow runs for any user who includes `@worktrunk-bot` — the merge restriction (ruleset) is the safety boundary, not access control on the workflow itself.
@@ -132,10 +136,11 @@ The mention workflow runs for any user who includes `@worktrunk-bot` — the mer
**Triggers a response:**
- Non-draft PR opened or updated → automatic code review (`claude-review`)
- Formal review submitted on a `worktrunk-bot`-authored PR, with body or non-approval → `claude-review` responds
-- `@worktrunk-bot` mentioned in an issue body → `claude-mention` responds
+- `@worktrunk-bot` mentioned in a new issue body → `claude-issue-triage` handles it (triage owns all new issues)
+- `@worktrunk-bot` mentioned via issue edit → `claude-mention` responds
- `@worktrunk-bot` mentioned in any comment (issue or PR) → `claude-mention` responds
- Any comment on a PR or issue that `worktrunk-bot` has engaged with (authored, mentioned in the issue body, reviewed, or commented on) → `claude-mention` runs (verify step confirms engagement via API), but the prompt instructs Claude to only respond if the comment needs bot input — otherwise exit silently. When the bot authored the PR/issue, it leans toward responding since commenters expect the author to engage.
-- Editing a comment or issue body re-triggers the same response
+- Editing a comment or issue body re-triggers the mention workflow
**Does not trigger:**
- Issues authored by `worktrunk-bot` (prevents self-triggering when bot-created issues incidentally mention `@worktrunk-bot` in body text)
diff --git a/.github/workflows/claude-issue-triage.yaml b/.github/workflows/claude-issue-triage.yaml
index 1f6ec70de..0b033941c 100644
--- a/.github/workflows/claude-issue-triage.yaml
+++ b/.github/workflows/claude-issue-triage.yaml
@@ -18,16 +18,17 @@ env:
jobs:
triage:
- # Skip bot-created issues, @worktrunk-bot mentions (handled by claude-mention.yaml),
- # and issues from worktrunk-bot (nightly workflows, ci-fix, etc.). Nightly
- # workflows handle their own remediation because they have richer context
- # (session logs, aggregate diffs) that would be lost if the triager
- # re-derived it from the issue body alone.
+ # Skip bot-created issues and issues from worktrunk-bot (nightly workflows,
+ # ci-fix, etc.). Nightly workflows handle their own remediation because they
+ # have richer context (session logs, aggregate diffs) that would be lost if
+ # the triager re-derived it from the issue body alone.
+ #
+ # Issues mentioning @worktrunk-bot are handled here too — claude-mention
+ # only triggers on issue edits (not opens) to avoid duplicate workflows
+ # racing to create fix PRs.
if: >-
github.event.issue.user.type != 'Bot' &&
- github.event.issue.user.login != 'worktrunk-bot' &&
- !contains(github.event.issue.body, '@worktrunk-bot') &&
- !contains(github.event.issue.title, '@worktrunk-bot')
+ github.event.issue.user.login != 'worktrunk-bot'
runs-on: ubuntu-24.04
permissions:
contents: write
diff --git a/.github/workflows/claude-mention.yaml b/.github/workflows/claude-mention.yaml
index 6c5a80c44..3fff2d82d 100644
--- a/.github/workflows/claude-mention.yaml
+++ b/.github/workflows/claude-mention.yaml
@@ -3,7 +3,7 @@ name: claude-mention
on:
issues:
- types: [opened, edited]
+ types: [edited]
issue_comment:
types: [created, edited]
pull_request_review_comment:
@@ -19,6 +19,8 @@ jobs:
claude:
# Two triggers:
# 1. @worktrunk-bot mentions — explicit requests on any issue/PR.
+ # New issues (opened) go to claude-issue-triage instead; this
+ # workflow only handles issue edits that add @worktrunk-bot.
# 2. Bot-engaged PRs/issues — any non-bot comment on a PR or issue
# where the bot has authored, reviewed, or commented. The verify step
# checks engagement via API and skips the job if the bot has not
@@ -61,7 +63,7 @@ jobs:
# Verify bot engagement — gate for non-mention comments.
#
# Skipped (all subsequent steps run) when:
- # - Event is not a comment (issues opened/edited with @worktrunk-bot)
+ # - Event is not a comment (issues edited with @worktrunk-bot)
# - Comment body contains @worktrunk-bot (explicit mention)
#
# When it runs, checks engagement in order (first match exits 0):
@@ -211,7 +213,7 @@ jobs:
# 1. Inline review comment (pull_request_review_comment) → reply in thread
# 2. Explicit @worktrunk-bot mention in a comment → always respond
# 3. Comment on bot-engaged issue/PR (no mention) → only if helpful
- # 4. Issue opened/edited with @worktrunk-bot mention → always respond
+ # 4. Issue edited with @worktrunk-bot mention → always respond
prompt: >-
${{ github.event_name == 'pull_request_review_comment'
&& (contains(github.event.comment.body, '@worktrunk-bot')
@@ -240,7 +242,7 @@ jobs:
github.event.comment.html_url
))
|| format(
- 'An issue was opened or updated with a mention of you ({0}). Read it and respond.',
+ 'An issue was updated with a mention of you ({0}). Read it and respond.',
github.event.issue.html_url
) }}