Skip to content

Commit e098f05

Browse files
LeeCampbellclaude
andauthored
Add structured PR body with Closes keyword to auto-close issues (#120)
Build PR description from plan artifacts (brief.md and task.md) instead of posting them as separate comments. Append `Closes #N` so GitHub automatically closes the linked issue on merge. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0040042 commit e098f05

1 file changed

Lines changed: 25 additions & 12 deletions

File tree

.devcontainer/agent-loop.sh

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,31 @@ case "$STATE" in
7575
exit 1
7676
fi
7777

78-
if ! PR_URL=$(GH_TOKEN="$GH_TOKEN_UPSTREAM" gh pr create --fill \
78+
PR_TITLE="feat(#${ISSUE_NUM}): $(gh issue view "$ISSUE_NUM" \
79+
--repo "$UPSTREAM_REPO" --json title --jq .title)"
80+
81+
# Build PR body from plan artifacts
82+
PR_BODY=""
83+
if [ -f /tmp/plan-backup/done/brief.md ]; then
84+
PR_BODY=$(cat /tmp/plan-backup/done/brief.md)
85+
fi
86+
if [ -f /tmp/plan-backup/done/task.md ]; then
87+
PR_BODY="${PR_BODY}
88+
89+
<details>
90+
<summary>Task breakdown</summary>
91+
92+
$(cat /tmp/plan-backup/done/task.md)
93+
94+
</details>"
95+
fi
96+
PR_BODY="${PR_BODY}
97+
98+
Closes #${ISSUE_NUM}"
99+
100+
if ! PR_URL=$(GH_TOKEN="$GH_TOKEN_UPSTREAM" gh pr create \
101+
--title "$PR_TITLE" \
102+
--body "$PR_BODY" \
79103
--repo "$UPSTREAM_REPO" \
80104
--head "${GIT_USER_NAME}:${BRANCH}" \
81105
--base "$UPSTREAM_BASE_BRANCH"); then
@@ -85,17 +109,6 @@ case "$STATE" in
85109
exit 1
86110
fi
87111

88-
PR_NUM=$(echo "$PR_URL" | grep -oP '\d+$')
89-
90-
[ -f /tmp/plan-backup/done/brief.md ] && \
91-
GH_TOKEN="$GH_TOKEN_UPSTREAM" gh pr comment "$PR_NUM" \
92-
--repo "$UPSTREAM_REPO" \
93-
--body-file /tmp/plan-backup/done/brief.md
94-
[ -f /tmp/plan-backup/done/task.md ] && \
95-
GH_TOKEN="$GH_TOKEN_UPSTREAM" gh pr comment "$PR_NUM" \
96-
--repo "$UPSTREAM_REPO" \
97-
--body-file /tmp/plan-backup/done/task.md
98-
99112
if [ -n "$ISSUE_NUM" ]; then
100113
GH_TOKEN="$GH_TOKEN_UPSTREAM" gh issue comment "$ISSUE_NUM" \
101114
--repo "$UPSTREAM_REPO" --body "PR created: $PR_URL"

0 commit comments

Comments
 (0)