Skip to content

✨ feat(slash-command): create /pr-workflow command for guided PR creation and management#385

Merged
codekiln merged 6 commits intomainfrom
claude/377-pr-workflow-command
Nov 28, 2025
Merged

✨ feat(slash-command): create /pr-workflow command for guided PR creation and management#385
codekiln merged 6 commits intomainfrom
claude/377-pr-workflow-command

Conversation

@codekiln
Copy link
Owner

Summary

  • Implements autonomous PR workflow command that guides Claude agents through complete PR lifecycle
  • Covers all phases from pre-PR validation through iterative CI/CD monitoring to merge-ready state
  • Integrates with existing pr-lifecycle and resolve-pr-comments skills for comprehensive PR management

Changes

  • Created .claude/commands/pr-workflow.md with 5-phase autonomous workflow:
    • Phase 1: Pre-PR validation (worktree, branch naming, issue linking, uncommitted changes)
    • Phase 2: PR creation preparation (commit history analysis, base branch determination, PR drafting)
    • Phase 3: PR creation (with proper formatting, milestone attachment, issue linking)
    • Phase 4: CI/CD monitoring loop (continuous status checks, automatic fix attempts, review comment handling)
    • Phase 5: Completion verification (final status checklist, cleanup reminders)
  • Added special case handling for hierarchical merging, CI failures, rebase conflicts, and review comments
  • Updated CLAUDE.md with token budget documentation referencing CLAUDE_CODE_MAX_OUTPUT_TOKENS

Related Issues

Fixes #377

Test Plan

  • Command file follows slash command conventions
  • All phases documented with clear actions and commands
  • Integration points with existing skills identified
  • Error handling and special cases covered
  • Token budget awareness documented

🤖 Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

Copilot AI review requested due to automatic review settings November 28, 2025 16:55
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a comprehensive autonomous PR workflow command that guides Claude agents through the entire pull request lifecycle, from pre-PR validation through CI/CD monitoring to merge-ready state.

Key changes:

  • Created a detailed 675-line /pr-workflow command with 5-phase autonomous workflow covering validation, preparation, creation, CI/CD monitoring, and completion
  • Added token budget documentation to CLAUDE.md referencing the CLAUDE_CODE_MAX_OUTPUT_TOKENS environment variable
  • Integrated with existing pr-lifecycle, resolve-pr-comments, and git-worktrees skills for comprehensive PR management

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 15 comments.

File Description
CLAUDE.md Added output token budget documentation with guidance on managing API costs and staying within configured limits
.claude/commands/pr-workflow.md New comprehensive slash command providing autonomous PR workflow from validation through merge, with special case handling and skill integration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@codekiln codekiln force-pushed the claude/377-pr-workflow-command branch from 030ea5a to 578b893 Compare November 28, 2025 17:02
codekiln added a commit that referenced this pull request Nov 28, 2025
Substantive improvements:
- Fixed PR number capture by extracting from gh pr create output
- Added explicit sleep command in CI monitoring loop
- Fixed run ID extraction with proper JSON query
- Updated to use .resolved field for unresolved comment detection
- Added iteration tracking mechanism with example code
- Added validation to prevent empty PRs (check commit count)

Documentation/formatting improvements:
- Added clarifying comment for three-dot diff usage
- Added concrete commit examples (not placeholders)
- Clarified template placeholder replacement
- Added bash language identifiers to all code fences
- Added 🩹 emoji to type list with project convention note
- Enhanced token budget documentation with defaults and limits
- Added error handling guidance for git operations

Fixes review comments from @Copilot in PR #385

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings November 28, 2025 17:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

codekiln added a commit that referenced this pull request Nov 28, 2025
Substantive improvements:
- Fixed PR number capture by extracting from gh pr create output
- Added explicit sleep command in CI monitoring loop
- Fixed run ID extraction with proper JSON query
- Updated to use .resolved field for unresolved comment detection
- Added iteration tracking mechanism with example code
- Added validation to prevent empty PRs (check commit count)

Documentation/formatting improvements:
- Added clarifying comment for three-dot diff usage
- Added concrete commit examples (not placeholders)
- Clarified template placeholder replacement
- Added bash language identifiers to all code fences
- Added 🩹 emoji to type list with project convention note
- Enhanced token budget documentation with defaults and limits
- Added error handling guidance for git operations

Fixes review comments from @Copilot in PR #385

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings November 28, 2025 17:32
@codekiln codekiln force-pushed the claude/377-pr-workflow-command branch from cb97fe0 to d5ee8b9 Compare November 28, 2025 17:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

codekiln added a commit that referenced this pull request Nov 28, 2025
Substantive improvements:
- Fixed PR number capture by extracting from gh pr create output
- Added explicit sleep command in CI monitoring loop
- Fixed run ID extraction with proper JSON query
- Updated to use .resolved field for unresolved comment detection
- Added iteration tracking mechanism with example code
- Added validation to prevent empty PRs (check commit count)

Documentation/formatting improvements:
- Added clarifying comment for three-dot diff usage
- Added concrete commit examples (not placeholders)
- Clarified template placeholder replacement
- Added bash language identifiers to all code fences
- Added 🩹 emoji to type list with project convention note
- Enhanced token budget documentation with defaults and limits
- Added error handling guidance for git operations

Fixes review comments from @Copilot in PR #385

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings November 28, 2025 17:49
@codekiln codekiln force-pushed the claude/377-pr-workflow-command branch from 5ad8e2b to dd51824 Compare November 28, 2025 17:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 15 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Copilot AI review requested due to automatic review settings November 28, 2025 18:58
codekiln and others added 5 commits November 28, 2025 14:00
…tion and management

Implements a comprehensive slash command that guides Claude agents through the
complete pull request lifecycle from pre-PR validation through to successful merge.

Changes:
- Created .claude/commands/pr-workflow.md with autonomous PR workflow
  - Phase 1: Pre-PR validation (worktree, branch naming, issue linking)
  - Phase 2: PR creation preparation (commit analysis, draft generation)
  - Phase 3: PR creation (with proper formatting and milestone)
  - Phase 4: CI/CD monitoring loop (iterative fixes until ready)
  - Phase 5: Completion verification
- Added integration with pr-lifecycle and resolve-pr-comments skills
- Added CLAUDE_CODE_MAX_OUTPUT_TOKENS documentation to CLAUDE.md

Fixes #377

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Substantive improvements:
- Fixed PR number capture by extracting from gh pr create output
- Added explicit sleep command in CI monitoring loop
- Fixed run ID extraction with proper JSON query
- Updated to use .resolved field for unresolved comment detection
- Added iteration tracking mechanism with example code
- Added validation to prevent empty PRs (check commit count)

Documentation/formatting improvements:
- Added clarifying comment for three-dot diff usage
- Added concrete commit examples (not placeholders)
- Clarified template placeholder replacement
- Added bash language identifiers to all code fences
- Added 🩹 emoji to type list with project convention note
- Enhanced token budget documentation with defaults and limits
- Added error handling guidance for git operations

Fixes review comments from @Copilot in PR #385

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
…ents

**Changes:**
- Added step 7 to Phase 1: Check if PR already exists before attempting creation
- If PR exists and is OPEN, skip directly to Phase 4 monitoring
- Restructured Phase 4 to prioritize review comments FIRST (before CI checks)
- Added automatic rebase handling with conflict detection
- Added 5-7 minute stability monitoring after all fixes
- Made command fully idempotent - safe to run multiple times
- Removed interactive prompts for review comments - now fully autonomous

**Phase 4 new order:**
1. Review comments (highest priority - human feedback)
2. Rebase check (ensure up-to-date with base)
3. CI/CD checks (code quality)
4. Stability monitoring (5-7 minutes)

**Goal:** Run `/pr-workflow`, walk away, come back to ready PR with:
- All review comments addressed and replied to
- Branch rebased to main (no conflicts)
- All CI checks passing
- No manual intervention needed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Critical fixes:
- Fixed review comment detection: use .resolved == null (not false)
- Fixed PR number extraction from gh pr create output
- Added explicit sleep command in CI check loop
- Fixed gh pr checks to document run ID extraction with --json

Documentation improvements:
- Clarified git diff three-dot usage with explanatory comment
- Clarified commit message template with interpolation note
- Fixed bash code block formatting in cleanup sections
- Enhanced CLAUDE_CODE_MAX_OUTPUT_TOKENS guidance with defaults

All 30 review comments addressed (15 Copilot + 15 user acknowledgments)

Fixes #377
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@codekiln codekiln force-pushed the claude/377-pr-workflow-command branch from a242d53 to 58a88b4 Compare November 28, 2025 19:00
@codekiln codekiln merged commit c2984e6 into main Nov 28, 2025
@codekiln codekiln deleted the claude/377-pr-workflow-command branch November 28, 2025 19:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

# Recommended: use gh pr comment to reply to a review comment
gh pr comment <pr-number> --reply <comment-id> --body "..."
# Or, using the API directly:
gh api repos/<owner>/<repo>/pulls/<num>/comments/<comment-id>/replies -f body="..."
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The API endpoint path is incorrect. According to the GitHub API documentation and the existing gh-pr-comment-reply.md command (lines 70-72), replies to PR review comments should use the endpoint repos/<owner>/<repo>/pulls/<num>/comments with the in_reply_to parameter, not a /replies subpath. The correct command should be: gh api repos/<owner>/<repo>/pulls/<num>/comments -f body=\"...\" -F in_reply_to=<comment-id>

Suggested change
gh api repos/<owner>/<repo>/pulls/<num>/comments/<comment-id>/replies -f body="..."
gh api repos/<owner>/<repo>/pulls/<num>/comments -f body="..." -F in_reply_to=<comment-id>

Copilot uses AI. Check for mistakes.
Comment on lines +283 to +288
# NOTE: GitHub API returns `null` for unresolved comments, not `false`
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
gh api repos/$REPO/pulls/$PR_NUM/comments \
--jq '.[] | select(.resolved == null) | {id, path, line, user: .user.login, body}'
```
- Count unresolved review comments (where `.resolved == null`)
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for detecting unresolved comments is inverted. In the GitHub API, the resolved field is true for resolved comments and is either false or null for unresolved comments. However, the comment says 'GitHub API returns null for unresolved comments' which contradicts GitHub's API behavior. The filter should check for both false and null, or use .resolved != true to properly identify unresolved comments. The current filter select(.resolved == null) will miss comments where resolved is explicitly false.

Suggested change
# NOTE: GitHub API returns `null` for unresolved comments, not `false`
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
gh api repos/$REPO/pulls/$PR_NUM/comments \
--jq '.[] | select(.resolved == null) | {id, path, line, user: .user.login, body}'
```
- Count unresolved review comments (where `.resolved == null`)
# NOTE: GitHub API returns `true` for resolved comments, and `false` or `null` for unresolved comments
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
gh api repos/$REPO/pulls/$PR_NUM/comments \
--jq '.[] | select(.resolved != true) | {id, path, line, user: .user.login, body}'
  • Count unresolved review comments (where .resolved != true)

Copilot uses AI. Check for mistakes.
Comment on lines +283 to +288
# NOTE: GitHub API returns `null` for unresolved comments, not `false`
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
gh api repos/$REPO/pulls/$PR_NUM/comments \
--jq '.[] | select(.resolved == null) | {id, path, line, user: .user.login, body}'
```
- Count unresolved review comments (where `.resolved == null`)
Copy link

Copilot AI Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This instruction is inconsistent with the actual GitHub API behavior. As noted in comment 2, the filter should identify comments where .resolved != true to catch both false and null values for unresolved comments, not just null values.

Suggested change
# NOTE: GitHub API returns `null` for unresolved comments, not `false`
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
gh api repos/$REPO/pulls/$PR_NUM/comments \
--jq '.[] | select(.resolved == null) | {id, path, line, user: .user.login, body}'
```
- Count unresolved review comments (where `.resolved == null`)
# NOTE: GitHub API returns `false` or `null` for unresolved comments
REPO=$(gh repo view --json nameWithOwner -q .nameWithOwner)
gh api repos/$REPO/pulls/$PR_NUM/comments \
--jq '.[] | select(.resolved != true) | {id, path, line, user: .user.login, body}'
  • Count unresolved review comments (where .resolved != true)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

✨ feat(slash-command): create /pr-workflow command for guided PR creation and management

2 participants