Skillpedia
برمجة عامة41k · #6818

stacking-prs

ما الذي تفعله

تُري هذه المهارة الذكاء الاصطناعي كيف ينشئ طلبات الدمج المتراكمة على GitHub ويديرها باستخدام أداة سطر الأوامر gh stack. وهي مناسبة للمطورين الذين يريدون تقسيم تغيير كبير إلى طبقات أصغر أسهل في المراجعة.

متى تستخدمها

  • ✓عندما يكون تغيير الشيفرة كبيراً جداً لمراجعته في طلب دمج واحد، وتريد تقسيمه إلى طبقات.
  • ✓عندما يتغير طلب دمج في أسفل السلسلة، ويجب تحديث الطبقات التي فوقه.
  • ✓عندما تريد دمج سلسلة من طلبات الدمج بالترتيب الصحيح.

رابط المهارة

https://github.com/PostHog/posthog/blob/master/.agents/skills/stacking-prs/SKILL.md

انسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.

طريقة الاستخدام

أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.

رسالة جاهزة للصق

استخدم هذه المهارة لمساعدتي: https://github.com/PostHog/posthog/blob/master/.agents/skills/stacking-prs/SKILL.md اقرأ ملف SKILL.md في هذا الرابط ونفّذ تعليماته لمهمتي.
تريد أن يجد الذكاء الاصطناعي مهارات مثل هذه بنفسه؟ثبّت خادم Skillpedia MCP المجاني: سطر واحد، ويبحث في 15,000+ مهارة قبل كل مهمة.ثبّته في دقيقة واحدة →

مثال على ما تطلبه من الذكاء الاصطناعي

“قسّم فرع الميزة الكبير لديّ إلى سلسلة من طلبات الدمج الأصغر، أستطيع مراجعتها واحداً تلو الآخر.”

5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.

كيف تعمل

السلسلة تسلسل مرتب، يعتمد فيه كل طلب دمج على الذي تحته. يستخدم الذكاء الاصطناعي أداة gh stack لإنشاء كل طبقة وإرسالها وتحديثها، ولإعادة تأسيس الطبقات التي فوقها عند تغيّر إحداها.

المحتوى التقني (ملف SKILL.md الأصلي)

النص الأصلي من المؤلف، مباشرة من GitHub.

Stacked PRs with gh stack

Before you divide a change into layers, check things already tried. It records when a stack cost more review effort than one PR.

GitHub's native stacked PRs are enabled on this repo. A stack is an ordered chain of PRs where each one targets the branch of the PR below it; the bottom PR targets master. GitHub tracks the chain as a first-class object: the PR UI shows a stack map, branch protections (code owner approval, required checks) apply to every layer including mid-stack ones, and CI that runs on master PRs runs on every layer.

Setup (this skill is written against gh-stack v0.1.0):

gh extension install github/gh-stack   # or: gh extension upgrade stack

Upstream docs: about stacked PRs, CLI commands.

In a cloud task sandbox, use gh_stack instead

The rest of this skill assumes a developer machine. Cloud task runs block git commit and git push so unsigned commits cannot leave the sandbox, which takes out every gh stack command that publishes a stack — submit, sync, push, and link with branch arguments all push, and gh stack add -m commits.

There, build the stack from the signed-commit tooling and link it with the gh_stack MCP tool, which drives GitHub's Stacks REST API and never pushes:

  1. Commit each layer with git_signed_commit, passing a new branch — the checkout already sits on the layer below, so the branch starts there.
  2. Open each layer's PR with gh pr create --base <branch of the layer below>.
  3. Link them with gh_stack, operation create, passing pull_requests bottom to top.

To restack a layer: check that layer out, git rebase <its parent branch>, then republish it with git_signed_rewrite passing onto = the parent branch. gh stack rebase still does the rebase itself, but nothing may publish the result — gh stack push and gh stack sync both push. git_signed_rewrite replays whatever local HEAD points at and uses branch only to pick which remote ref moves, so the layer has to be the checked-out branch or you publish the wrong history to it.

Create a stack

gh stack init my-feature-db        # bottom branch, based on master
# ...commit...
gh stack add my-feature-api        # next layer, based on the previous branch
# ...commit...
gh stack add -Am "add UI" my-feature-ui   # stage all + commit in one step
  • Adopt existing local branches (bottom to top): gh stack init branch1 branch2 branch3.
  • Link PRs that already exist on GitHub, without local tracking: gh stack link <pr> <pr> <pr>, bottom to top (branch names and PR URLs work too). Pass a stack number first to append to an existing stack: gh stack link <stack> <pr>.
  • Slice by reviewable unit: migration / backend / frontend, or mechanical-rename / behavior-change. Each PR must make sense to review and merge alone.
  • Keep stacks shallow (2–4 layers). Every layer multiplies CI cost and rebase churn, and deep-stack pushes can trip GitHub's dispatch cap (see AGENTS.md, "Stacked PRs"). The pre-push hook and the Stack depth check block a layer above the fifth open one (merged layers don't count). For more work on top, run gh stack init --base <top branch> <new branch> from master, because gh-stack refuses to start a stack from a layer of another one. Rebase the new stack onto master once the lower stack lands.
  • Place a CI-heavy layer by how CI diffs it:
    • Most jobs pick their work from the layer's own diff against its parent, so such a layer does not make the layers above it heavy. A push to any layer below it starts its jobs again (see the duplicate-run note under "Iterate and keep in sync"). Put it low, unless it is the layer that still changes most.
    • A few steps diff against master, so they repeat on layers above the change. Trunk's impacted-targets job runs on every layer and computes affected crates when rust/ or proto/ differs. Backend jobs build the HogQL parser from source when common/hogql_parser/ or rust/hogql/parser/ differs, and Playwright jobs when common/hogql_parser/ differs. Those builds repeat only on upper layers whose own diff starts backend or Playwright jobs. If upper layers do, put the parser change in the top layer.
  • Put every change that moves a visual review snapshot, Storybook
الأسئلة الشائعة

ما طلب الدمج المتراكم؟

هو سلسلة من طلبات الدمج، يستهدف كل منها فرع الطلب الذي تحته، ويستهدف الطلب الأسفل الفرع الرئيسي.

هل أحتاج إلى أداة سطر الأوامر gh؟

نعم. تستخدم هذه المهارة إضافة gh stack لـ GitHub، وتثبّتها مرة واحدة مع GitHub CLI.

هل تبدأ طلبات الدمج الجديدة كمسودات؟

تُنشئ المهارة السلاسل كمسودات أولاً، حتى تُفحص كل طبقة قبل أن يراجعها أحد.

التفاصيل

الوصف الأصلي من المؤلف

Create and manage GitHub native Stacked PRs in this repo with the `gh stack` CLI. Use when asked to stack PRs, split a large change into a stack, add a layer to a stack, restack or rebase a stack, adopt existing branches or PRs into a stack, check out someone else's stack, or land a stack. Covers creating and submitting stacks (draft-first), cascade rebases with `gh stack sync`, and landing one through the Trunk merge queue via `/merging-prs` — whole-stack via `trunk merge` on the top layer, or bottom-first — never `gh stack merge`.

repo: PostHog/posthog

الشعبية

نجوم GitHub
41k
الترتيب
#6818
الترخيص
—
آخر تحديث
2‏/11‏/2026

هل هذه المهارة مفيدة؟

0

سجّل الدخول للتصويت.

التعليقات

  • …

المزيد من المهارات من هذا المستودع

مهارات مشابهة