计划执行与检查节点
executing-plans
按既定实施计划完成工作,保持过程检查和反馈。
create-pr-from-commits【效率与协作】Use when user asks to create a pull request - automates PR creation by analyzing commits, filling PR template, and submitting with gh pr create
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Automate pull request creation by extracting information from git commits and filling the repository's PR template. This eliminates manual repetition while ensuring PRs contain complete, accurate information.
Use when:
Don't use when:
digraph pr_workflow {
"User requests PR" [shape=doublecircle];
"Gather git context" [shape=box];
"Find PR template" [shape=box];
"Analyze commits" [shape=box];
"Fill template" [shape=box];
"Create PR with gh pr create" [shape=box];
"Return PR URL" [shape=doublecircle];
"User requests PR" -> "Gather git context";
"Gather git context" -> "Find PR template";
"Find PR template" -> "Analyze commits";
"Analyze commits" -> "Fill template";
"Fill template" -> "Create PR with gh pr create";
"Create PR with gh pr create" -> "Return PR URL";
}
For internal Tableau contributors, ask for the GUS work item ID:
What is the GUS work item ID for this PR? (Format: W-12345678)
If you're an external contributor, press Enter to skip.
GUS ID format:
@W-@W-22802840If the user provides just the number (e.g., "22802840"), prepend @W-.
If they provide "W-12345678", prepend @.
If no GUS ID provided: Continue without it - external contributors don't need GUS IDs.
Run these commands in parallel with Bash tool:
# Get all commits since main
git log main..HEAD --format="%h %s%n%b"
# Get full diff
git diff main...HEAD
# Get changed files
git diff main...HEAD --stat
# Check branch tracking
git branch -vv
Read the PR template at .github/pull_request_template.md to identify required sections.
Extract information for PR title and template sections:
PR Title:
@W-12345678: Short description (internal contributors with GUS ID)Short description (external contributors without GUS ID)@W-22802840: Remove sensitive data from error logsRemove sensitive data from error logsDescription/Summary:
Motivation/Context:
Type of Change:
Testing:
*.test.ts, *.spec.js)Breaking Changes:
Create PR with GUS ID in title using HEREDOC format:
gh pr create --title "@W-12345678: Short description from commits" --body "$(cat <<'EOF'
## Description
- Bullet point 1 from commit
- Bullet point 2 from commit
## Motivation and Context
[Extracted from commit bodies or inferred from changes]
## Type of Change
- [x] Bug fix
- [ ] New feature
...
## How Has This Been Tested?
[List test files changed or mention manual testing]
## Related Issues
Closes #123, W-45678
## Checklist
- [x] Tests added
- [x] Tests pass
- [ ] Documentation updated
EOF
)"
Template mapping patterns:
| Template Section | Information Source |
|---|---|
| Description/Summary | Commit subjects (bullets) |
| Motivation | Commit bodies + issue refs |
| Type of Change | Keywords in commits + diff analysis |
| Testing | Test file changes + commit messages |
| Breaking Changes | BREAKING in commits + env var changes |
| Checklist items | Verify against actual changes |
# Push if needed
[[ $(git branch -vv | grep 'gone\]') ]] && git push -u origin HEAD
# Create PR with GUS ID in title
gh pr create --title "@W-12345678: Description" --body "..."
If no template exists, create minimal but complete PR:
gh pr create --title "..." --body "$(cat <<'EOF'
## Summary
- [commit-based bullets]
## Changes
- [files changed summary]
## Testing
[test coverage or manual testing note]
EOF
)"
Check project conventions:
mainmaster, develop, trunkUse gh pr create --base <branch> to specify.
If gh pr create fails with "pull request already exists":
gh pr edit <number>ALWAYS ask for GUS ID (but allow skipping for external contributors).
Don't say: "I'll create the PR now" without prompting for GUS ID first.
Don't ask: "What should I put in the description?"
The commits contain this information. Extract it (except for GUS ID).
Don't write: "Various bug fixes and improvements"
Extract specifics: "Fix memory leak in auth flow, improve error logging for failed requests"
Don't leave sections empty with "TODO".
If information is missing, infer from code changes or use reasonable defaults:
Always verify branch is pushed before creating PR:
git branch -vv # Check tracking
Use single quotes in <<'EOF' to prevent variable expansion in PR body.
Full workflow:
# 1. Ask user for GUS ID (allow skip for external contributors)
# "What is the GUS work item ID? (Format: W-12345678, or press Enter to skip)"
# 2. Gather context (parallel)
git log main..HEAD --format="%h %s%n%b" &
git diff main...HEAD --stat &
wait
# 3. Find and read template
cat .github/pull_request_template.md
# 4. Create PR with GUS ID in title
gh pr create --title "@W-12345678: Short description" --body "$(cat <<'EOF'
[filled template here]
EOF
)"
Title format examples:
@W-22802840: Remove sensitive data from error logs (internal)@W-12345678: Add user management feature (internal)Remove sensitive data from error logs (external contributor)W-22802840: Fix bug (missing @ symbol for internal contributor)Before this skill:
After this skill: