review-external-pr

bởi microsoft

Phân loại PR từ người đóng góp bên ngoài và chuẩn bị để hợp nhất. Phát hiện quyền push, nhánh cơ sở, trạng thái nháp, kích thước và chất lượng lịch sử, sau đó chọn một trong…

npx skills add https://github.com/microsoft/vscode-documentdb --skill review-external-pr

Review External PR Workflow

A triage-first workflow for handling community PRs. The skill inspects first, asks two questions, then executes. It never creates branches preemptively.

When to Use

  • A contributor PR is open and you want to review and merge it
  • Trigger phrases: "prepare this external PR", "review PR #N", "let's review this contribution", or invocation while the user is on a pr/<owner>/<PR_NUMBER> branch (created by gh pr checkout)
  • You want a recommendation on push path and merge strategy before doing anything

Phase 1 — Triage (read-only, no prompts)

Identify the PR

Resolve, in order:

  1. The PR number the user mentioned.
  2. Current branch matches pr/<owner>/<PR_NUMBER> → extract <PR_NUMBER>.
  3. gh pr status → active PR for current branch.

Fetch metadata in one call

gh pr view <PR_NUMBER> --json number,title,author,url,state,isDraft,\
headRefName,baseRefName,headRepositoryOwner,maintainerCanModify,\
mergeable,mergeStateStatus,additions,deletions,changedFiles,commits,labels

Derive signals

| Signal | Rule | | --------------- | ----------------------------------------------------------------------------------------------------------------------------- | ----- | -------------- | ---- | ------ | ----- | | canPushToHead | headRepositoryOwner.login == "microsoft" OR maintainerCanModify | | baseBranch | baseRefName (do not hardcode main) | | isDraft | warn if true | | mergeable | warn if mergeable != "MERGEABLE" (values: MERGEABLE, CONFLICTING, UNKNOWN) | | mergeReady | warn if mergeStateStatus is not CLEAN (other values: DIRTY, BLOCKED, BEHIND, UNSTABLE, HAS_HOOKS, UNKNOWN) | | commitCount | commits.length | | messyHistory | any commits[].messageHeadline (the first line of the commit message, returned by gh pr view --json commits) matches /wip | fixup | address review | typo | merge( | $)/i | | changedLines | additions + deletions | | sizeBucket | small ≤ 50 changed lines, medium ≤ 300, large > 300 (uses changedLines) |

Squash recommendation

ConditionRecommend
commitCount == 1No squash (rebase or merge) — history already clean
commitCount ≤ 3 AND no messy subjects AND smallAsk, default no squash
commitCount > 3 OR messy subjects detectedSquash (default)

Print the triage report

PR #<PR_NUMBER> — <title>
  Author:        <login>  (<fork|same-repo>)
  Base:          <baseBranch>
  State:         <state>, <draft?>, mergeable=<mergeable>, mergeStateStatus=<mergeStateStatus>
  Push to head:  <✅ allowed reason | ❌ blocked reason>
  Size:          +<additions> / -<deletions> across <changedFiles> file(s), <commitCount> commit(s)
  History:       <clean | messy: "<sample messageHeadline>">

Recommendation:
  • Path:  <direct push | reviews/ branch | review-only>
  • Merge: <--squash | --merge | --rebase> (<reason>)

Stop here and present the report.

Phase 2 — Two questions

Ask only these. Pre-select the recommended option.

Q1: Do you need to add changes before merging?

  • No → Path A (review & merge)
  • Yes, small tweaks → Path B (direct push) if canPushToHead, otherwise Path C
  • Yes, heavy rework / contributor unresponsive → Path C (reviews/ staging branch)

If canPushToHead == false, omit the "direct push" option and explain: "Contributor disabled maintainer edits; we must use a reviews/ branch."

Q2: Merge strategy?

Offer --squash, --merge, --rebase with the recommended option marked. Justify the default in one short sentence (e.g., "4 commits including 'fix typo' — squash recommended").

Phase 3 — Execute

Run commands non-interactively, echoing each one. After merge, print a one-line summary with the merged commit/PR URL.

Path A — Review & merge (no maintainer changes)

gh pr checkout <PR_NUMBER>                  # optional, for local inspection
# review, leave comments via the PR UI or `gh pr review`
gh pr merge <PR_NUMBER> --<strategy>        # against the PR's actual base

Path B — Direct push to the contributor's branch

Requires canPushToHead == true.

gh pr checkout <PR_NUMBER>                  # sets up a remote tracking the fork branch
# make changes, commit
git push                                    # updates the existing PR in place
gh pr merge <PR_NUMBER> --<strategy>

The existing PR updates in place; the contributor keeps authorship of their commits and maintainer commits are attributed to the maintainer. No second PR is needed.

Path C — reviews/ staging branch

Use when push to head is blocked, or when the maintainer explicitly wants to isolate rework.

Branch slug sanitization — derive <slug> from the PR title:

  1. Lowercase.
  2. Replace every run of non-[a-z0-9] characters with a single -.
  3. Trim leading/trailing -.
  4. Truncate to 30 characters; trim trailing - again if the cut left one.

Example: "fix(tree): sort _id_ index first / cleanup" → fix-tree-sort-id-index-first-c.

Full branch name: reviews/<slug>-pr-<PR_NUMBER>.

git fetch origin
git checkout -b reviews/<slug>-pr-<PR_NUMBER> origin/<baseBranch>
git push -u origin reviews/<slug>-pr-<PR_NUMBER>

Retarget the contributor's PR:

gh pr edit <PR_NUMBER> --base reviews/<slug>-pr-<PR_NUMBER>
gh pr view <PR_NUMBER> --json baseRefName    # verify

⚠️ gh pr edit --base may print a deprecation warning about Projects (classic). Cosmetic only — the base change succeeds.

Merge the contributor's PR into the review branch:

gh pr merge <PR_NUMBER> --<strategy>

Pull and create the finalization PR back to the original base:

git checkout reviews/<slug>-pr-<PR_NUMBER>
git pull origin reviews/<slug>-pr-<PR_NUMBER>

gh pr create \
  --base <baseBranch> \
  --head reviews/<slug>-pr-<PR_NUMBER> \
  --title "<original title> [reviewed]" \
  --body "Finalizes review of @<author>'s contribution in #<PR_NUMBER>.

Original PR: <PR_URL>"

Comment on the original PR:

gh pr comment <PR_NUMBER> \
  --body "Thanks for the contribution! Review continues in #<NEW_PR_NUMBER> where maintainer changes are finalized before merging to \`<baseBranch>\`."

Merge Strategy Reference

StrategyWhen to use
--squashDefault for messy/multi-commit external PRs. One revert undoes the change. Contributor still gets authorship credit.
--mergeLarge feature where individual commits are meaningful and worth preserving.
--rebaseSingle clean commit, or a series of clean atomic commits you want linear on the base.

Hard Rules

  • Never hardcode main as the base — always read baseRefName.
  • Never create a reviews/ branch in Phase 1.
  • Never force-push to a contributor's branch.
  • If the PR is a draft, refuse to merge and report it back to the maintainer.
  • If mergeable == "CONFLICTING" or mergeStateStatus != "CLEAN", stop and surface that before any merge command.

Summary

PhaseWhat happensOutput
1Read PR metadata, derive push capability + recommendationsTriage report
2Ask Q1 (path) and Q2 (merge strategy)Decision
3Execute the chosen path with the chosen merge strategyMerged PR / finalization PR

Thêm skills từ microsoft

oss-growth
microsoft
Cá tính tăng trưởng OSS
agent-framework-azure-ai-py
microsoft
Xây dựng các tác nhân Azure AI Foundry bằng SDK Python của Microsoft Agent Framework (agent-framework-azure-ai). Sử dụng khi tạo các tác nhân bền vững với AzureAIAgentsProvider, sử dụng các công cụ được lưu trữ (trình thông dịch mã, tìm kiếm tệp, tìm kiếm web), tích hợp máy chủ MCP, quản lý chuỗi hội thoại hoặc triển khai phản hồi phát trực tuyến. Bao gồm các công cụ hàm, đầu ra có cấu trúc và các tác nhân đa công cụ.
development
airunway-aks-setup
microsoft
Thiết lập AI Runway trên AKS — từ cụm trống đến mô hình đang chạy. Bao gồm xác minh cụm, cài đặt controller, đánh giá GPU, thiết lập nhà cung cấp và triển khai đầu tiên. KHI NÀO: "thiết lập AI Runway", "onboard cụm AKS", "cài đặt AI Runway", "thiết lập airunway", "triển khai mô hình lên AKS", "suy luận GPU trên AKS", "thiết lập KAITO trên AKS", "chạy LLM trên AKS", "vLLM trên AKS", "thiết lập phục vụ mô hình trên AKS", "AI Runway controller".
devops
appinsights-instrumentation
microsoft
Hướng dẫn để instrument các ứng dụng web với Azure Application Insights. Cung cấp các mẫu telemetry, thiết lập SDK, và tài liệu tham khảo cấu hình. KHI NÀO: cách instrument ứng dụng, App Insights SDK, các mẫu telemetry, App Insights là gì, hướng dẫn Application Insights, ví dụ instrumentation, các phương pháp tốt nhất APM.
devops
applicationinsights-web-ts
microsoft
Instrument các ứng dụng trình duyệt/web bằng SDK JavaScript Application Insights (@microsoft/applicationinsights-web). Dùng cho Real User Monitoring (RUM) — lượt xem trang, nhấp chuột, phụ thuộc AJAX/fetch, ngoại lệ, sự kiện tùy chỉnh và dấu vết tác nhân GenAI phía trình duyệt tương quan với dấu vết OpenTelemetry phía backend. Bao gồm thiết lập SDK Loader Script và npm, tiện ích mở rộng framework (React, React Native, Angular), Click Analytics, trình khởi tạo telemetry và quy ước ngữ nghĩa OTel GenAI cho các span tác nhân/công cụ/mô hình phát ra từ trình duyệt.
devops
azure-ai-anomalydetector-java
microsoft
Xây dựng ứng dụng phát hiện bất thường với Azure AI Anomaly Detector SDK cho Java. Sử dụng khi triển khai phát hiện bất thường đơn biến/đa biến, phân tích chuỗi thời gian hoặc giám sát hỗ trợ AI.
development
azure-ai-language-conversations-py
microsoft
Triển khai Conversational Language Understanding (CLU) bằng SDK Python azure-ai-language-conversations. Sử dụng khi làm việc với ConversationAnalysisClient để phân tích ý định và thực thể trong hội thoại, xây dựng tính năng NLP, hoặc tích hợp hiểu ngôn ngữ vào ứng dụng.
development
azure-ai-ml-py
microsoft
Azure Machine Learning SDK v2 cho Python. Dùng cho không gian làm việc ML, công việc, mô hình, tập dữ liệu, tính toán và quy trình. Kích hoạt: "azure-ai-ml", "MLClient", "không gian làm việc", "đăng ký mô hình", "công việc đào tạo", "tập dữ liệu".
development