| name | create-pr |
| description | Create an Azure DevOps pull request from the current branch. Default target is development, but if on development branch, creates PR to main. Extracts work item ID from branch name, generates PR title and description from commits, and links the work item to the PR. |
| disable-model-invocation | true |
Create Azure DevOps Pull Request
This skill creates a pull request with automatic work item linking for the montra.io project.
Default Behavior:
- Feature/bug/user/user-story/task branches →
development branch
development branch → main branch (release PR)
Branch Naming Pattern
Your branch must follow this pattern:
{type}-{workItemId}-descriptive-text
Supported types: bug, story, user,userstory, feature, task
Examples:
bug-3855-onboard-device-reserve
feature-4201-asset-search-optimization
story-1923-user-authentication-flow
Special Case: The development branch doesn't need to follow this pattern - it creates a release PR to main.
What This Skill Does
- Detects current branch and determines target (development → main, others → development)
- Validates branch name matches pattern (unless on development)
- Extracts work item ID from branch name
- Collects all commits from current branch vs target
- Generates PR title and description from commits
- Creates the PR in Azure DevOps using MCP tools
- Links the work item to the PR automatically (feature branches only)
- Shows you the PR URL
- Switches back to the target branch and pulls latest, so you're ready for the next task
Implementation
When invoked, follow these steps:
Step 1: Get and validate current branch
Run:
git branch --show-current
Special Case - Development Branch:
If the current branch is development:
- Target branch:
main
- Skip work item extraction
- Use different commit summary (see Step 3b)
- Skip work item linking (Step 6)
Regular Feature/Bug Branches:
The branch name must match the pattern: {type}-{workItemId}-descriptive-text
Valid types: bug, story, user, feature, task
Extract the work item ID by:
- Split the branch name by hyphens
- The first part is the type (e.g., "bug")
- The second part is the work item ID (e.g., "3855")
- The rest is the description
If the branch doesn't match the pattern, show an error message with the expected format and stop.
Step 2: Get repository information
IMPORTANT: Always use project name montra.io for this repository.
Run:
git remote get-url origin
Parse the repository name from the Azure DevOps URL.
Typical format: https://dev.azure.com/montraio/montra.io/_git/{repo}
Use the MCP tool to get the repository ID:
mcp__ado__repo_get_repo_by_name_or_id(
project="montra.io",
repositoryNameOrId="{repo_name}"
)
This returns the repository ID which you'll need for creating the PR.
Step 3: Determine target branch and collect commits
Determine target branch:
- If current branch is
development → target is main
- Otherwise → target is
development
Step 3a: Regular Feature/Bug Branch Commits
Run:
git log {target}..HEAD --pretty=format:"%s" --reverse
This gives you all commit messages from target to your current branch.
Also get the full commit details:
git log {target}..HEAD --pretty=format:"- %s (%an)" --reverse
Step 3b: Development → Main Release PR Commits
When creating a PR from development to main, get commits since the last merge to main:
git log main..development --pretty=format:"%s" --reverse
Summarize the changes by grouping related commits and features.
Step 4: Generate PR title and description
For Regular Feature/Bug Branches:
Title: Use the most recent meaningful commit message (skip "Auto increment build version" and version number commits)
Description: Format as:
## Summary
[Brief description based on commits]
## Changes
[List of meaningful commits with authors - skip build version commits]
## Related Work Item
#{workItemId}
🤖 Generated by Claude Code `/create-pr` skill
For Development → Main Release PR:
Title: Generate a release title like: "Release: [version] - [brief summary of major changes]"
Description: Format as:
## Release Summary
[High-level summary of features, fixes, and changes since last release]
## Major Changes
[Grouped by feature/fix with commit details]
## Statistics
- Total commits: {count}
- Contributors: {list}
🤖 Generated by Claude Code `/create-pr` skill
Step 5: Create the PR using ADO MCP
Use the tool: mcp__ado__repo_create_pull_request
IMPORTANT: Always use project="montra.io" and the repository ID from Step 2.
Parameters:
project: Always "montra.io"
repositoryId: Repository ID from Step 2 (e.g., "24c6d396-1646-4a49-8210-08514daf78d3")
sourceRefName: refs/heads/{current_branch_name} (from Step 1)
targetRefName: refs/heads/development OR refs/heads/main (if on development)
title: Generated title from Step 4
description: Generated description from Step 4
workItems: The work item ID extracted from the branch name (as string) - ONLY for feature/bug branches, omit for development → main
Example for feature branch:
mcp__ado__repo_create_pull_request(
project="montra.io",
repositoryId="24c6d396-1646-4a49-8210-08514daf78d3",
sourceRefName="refs/heads/bug-3855-onboard-device-reserve",
targetRefName="refs/heads/development",
title="refactor: improve device selection filtering in onboarding process",
description="## Summary\nImprove device selection...\n\n## Changes\n- refactor: improve device selection...\n\n## Related Work Item\n#3855\n\n🤖 Generated by Claude Code",
workItems="3855"
)
Example for development → main:
mcp__ado__repo_create_pull_request(
project="montra.io",
repositoryId="24c6d396-1646-4a49-8210-08514daf78d3",
sourceRefName="refs/heads/development",
targetRefName="refs/heads/main",
title="Release: v4.5.1 - User management and shipping fixes",
description="## Release Summary\n...\n\n🤖 Generated by Claude Code"
)
Note: No workItems parameter for release PRs.
Step 6: Link work item to PR (if Step 5 succeeded)
ONLY for feature/bug branches - Skip this step for development → main PRs.
If the PR was created successfully for a feature/bug branch, you'll receive a PR ID in the response.
Use the tool: mcp__ado__wit_link_work_item_to_pull_request
Parameters:
projectId: Use "a981dbda-560b-4103-afb3-cd2fc8714caf" (montra.io project ID)
repositoryId: Repository ID from Step 2
pullRequestId: PR ID from the Step 5 response
workItemId: Work item ID extracted from branch name (as number)
Example:
mcp__ado__wit_link_work_item_to_pull_request(
projectId="a981dbda-560b-4103-afb3-cd2fc8714caf",
repositoryId="24c6d396-1646-4a49-8210-08514daf78d3",
pullRequestId=1234,
workItemId=3855
)
Step 6b: Add required reviewers
Always add both reviewers to every PR (feature/bug branches AND release PRs).
Use the tool: mcp__ado__repo_update_pull_request_reviewers
Parameters:
repositoryId: Repository ID from Step 2
pullRequestId: PR ID from the Step 5 response
reviewerIds: ["442380c5-133d-63ea-a886-fb08335095b4", "1615a47d-6752-6912-b1cd-11fd6eccb6ce"]
action: "add"
These are the required reviewers:
| Name | ADO Identity ID |
|---|
| Ryan Gordon | 442380c5-133d-63ea-a886-fb08335095b4 |
| Jim Stott | 1615a47d-6752-6912-b1cd-11fd6eccb6ce |
Example:
mcp__ado__repo_update_pull_request_reviewers(
repositoryId="24c6d396-1646-4a49-8210-08514daf78d3",
pullRequestId=1234,
reviewerIds=["442380c5-133d-63ea-a886-fb08335095b4", "1615a47d-6752-6912-b1cd-11fd6eccb6ce"],
action="add"
)
Step 7: Display results
For feature/bug branches:
✅ Pull Request Created Successfully
PR URL: https://dev.azure.com/montraio/montra.io/_git/{repo}/pullrequest/{prId}
Work Item: #{workItemId}
Source: {sourceBranch}
Target: development
Commits: {commitCount} commits
Title: {prTitle}
For development → main release PR:
✅ Release Pull Request Created Successfully
PR URL: https://dev.azure.com/montraio/montra.io/_git/{repo}/pullrequest/{prId}
Source: development
Target: main
Commits: {commitCount} commits
Title: {prTitle}
Step 8: Reset all core repos to development
After displaying the results, switch all core repos back to development (or main/master for repos that don't use development) so the workspace is ready for the next task. This prevents leftover feature branches from cluttering the dashboard.
Resolve the base project directory:
if [[ -d "/c/Users/Ryan Gordon/Projects/montra-via-web" ]]; then
BASE_DIR="/c/Users/Ryan Gordon/Projects"
elif [[ -d "/Volumes/ext2G/Developer/montraio/montra-via-web" ]]; then
BASE_DIR="/Volumes/ext2G/Developer/montraio"
fi
For each of these repos, switch to their default working branch and pull:
| Repo | Default branch |
|---|
montra-via-api | development |
montra-via-web | development |
montra-via-db | development |
claude-shared | development |
docs | development |
For each repo:
cd "$BASE_DIR/{repo}"
git checkout {default_branch} 2>/dev/null && git pull 2>/dev/null
Important:
- Only switch repos that have a clean working tree (
git status --porcelain is empty). If a repo has uncommitted changes, skip it and warn the user.
- If checkout fails (e.g. branch doesn't exist locally), try
git checkout -b {branch} origin/{branch}.
- This is best-effort — failures here should warn but not block the PR result.
Display the result:
🔄 All repos reset to default branches
montra-via-api → development
montra-via-web → development
montra-via-db → development
claude-shared → development
docs → development
If any repo was skipped:
⚠️ Skipped {repo} — has uncommitted changes
Error Handling
Invalid branch name (for feature/bug branches):
❌ Invalid branch name: {branchName}
Expected format: {type}-{workItemId}-descriptive-text
Supported types: bug, story, user, feature, task
Example: bug-3855-fix-asset-state
Note: If you're on 'development' branch, this creates a release PR to 'main'
No commits to merge:
❌ No commits found between {target} and {branchName}
Please ensure:
1. Your branch has commits
2. You've pulled the latest {target} branch
3. Your commits are ahead of {target}
Azure DevOps API errors:
❌ Failed to create PR: {error_message}
Please check:
1. Your Azure DevOps permissions
2. Repository and project names are correct
3. The target branch exists
Work item linking errors:
⚠️ PR created but work item linking failed: {error_message}
PR URL: {prUrl}
Work Item #{workItemId}: Link manually in Azure DevOps
Notes
- The skill uses the Azure DevOps MCP server configured in your Claude Code settings
- Project is always
montra.io
- Default target is
development branch
- Special case:
development branch creates PR to main (release PR)
- Requires git repository with remote pointing to Azure DevOps
- Requires at least one commit ahead of the target branch
- Work item must exist in Azure DevOps (the skill will warn but continue if not found)
- Work item linking only happens for feature/bug branches, not for release PRs