协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
lov-gh-contribute【开发与工程】Contribute a clean, professional pull request to someone else's GitHub repository: fork → clone → branch → commit → push → open PR, with smart splitting into one or multiple PRs based on the scope of changes. Trigger when the user says "给这个 repo 提 PR"、"贡献代码"、"fork 然后改再 PR"、 "contribute to this repo", "open a PR to upstream", "submit a PR to <owner>/<…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
gh CLI (authenticated via gh auth login) and git.
Targets GitHub repositories only. Cross-platform: macOS, Windows, Linux.
metadata:
author: contributors
version: "0.2.1"
tags: [github, pr, contribute, fork, open-source]Turn local changes into a clean, professional pull request against an upstream repo you don't own. Handles the full fork → branch → commit → push → PR pipeline, and splits work into multiple PRs when the changes span unrelated concerns.
gh-tidy)Execute steps in order. Do not skip confirmations.
Determine the upstream owner/repo:
owner/repo string → use itgit remote -v in the current directory and pick the origin
(if origin is already the user's fork, find the upstream via
gh repo view --json parent)Record three facts:
UPSTREAM — e.g. ZenMux/zenmux-docDEFAULT_BRANCH — from gh repo view $UPSTREAM --json defaultBranchRef -q .defaultBranchRef.nameUSER_LOGIN — from gh api user -q .loginFetch CONTRIBUTING.md and CODE_OF_CONDUCT.md from upstream (if present) and
skim for: commit message format, DCO/CLA requirements, branch naming, PR template.
Carry these constraints into subsequent steps.
gh api repos/$UPSTREAM/contents/CONTRIBUTING.md -q .content 2>/dev/null | base64 -d
If the repo has .github/PULL_REQUEST_TEMPLATE.md, use it as the PR body skeleton.
Gather the change set that needs to become PR(s):
git status --porcelain
git diff --stat $DEFAULT_BRANCH...HEAD # committed
git diff --stat # unstaged
git diff --stat --cached # staged
Classify files into logical groups. Typical axes:
Use AskUserQuestion to present the plan. Options must include at least:
Show the plan like:
PR #1 (docs): Update CLAUDE.md to reflect current scripts
- CLAUDE.md
PR #2 (feat): Add gh-contribute skill bootstrap
- scripts/new.ts
- .prompts/contribute.xml
Do not proceed until the user picks an option.
gh repo view $USER_LOGIN/$REPO_NAME >/dev/null 2>&1 \
|| gh repo fork $UPSTREAM --clone=false --remote=false
Ensure a fork remote exists in the local clone:
git remote get-url fork 2>/dev/null \
|| git remote add fork git@github.com:$USER_LOGIN/$REPO_NAME.git
If origin already points at the user's fork, skip the fork remote and use origin.
For each PR in the plan:
git fetch origin $DEFAULT_BRANCH
git checkout -b $BRANCH_NAME origin/$DEFAULT_BRANCH
git checkout <sha> -- <paths>
or git stash + selective git checkout from a working branch).<type>(<scope>): <subject>. Otherwise mirror the style of the
last 10 commits on $DEFAULT_BRANCH.CONTRIBUTING.md requires DCO: git commit -s ....Branch naming (when upstream doesn't dictate): <type>/<short-slug>, e.g.
docs/update-claude-md, feat/add-contribute-skill.
git push -u fork $BRANCH_NAME
If origin is already the fork, use origin instead.
gh pr create \
--repo $UPSTREAM \
--base $DEFAULT_BRANCH \
--head $USER_LOGIN:$BRANCH_NAME \
--title "$TITLE" \
--body "$BODY"
PR body template (adapt to PR template if present):
## Summary
<1-3 bullets explaining what and why>
## Changes
- <bullet per logical change>
## Test plan
- [ ] <how to verify>
## Related
<!-- Link follow-up PRs if split, e.g. "Depends on #123" or "Part 2 of 3" -->
When opening multiple PRs, cross-link them in each body:
## Related
- PR 1/3: #<url>
- PR 2/3: (this PR)
- PR 3/3: #<url>
Output a compact summary:
Opened 2 PRs against ZenMux/zenmux-doc:
#201 docs: update CLAUDE.md → https://github.com/.../pull/201
#202 feat: add gh-contribute skill → https://github.com/.../pull/202
Prefer one PR when:
Prefer multiple PRs when:
scripts/ + docs_source/)When in doubt, ask the user.
--no-verify) or skip signing (--no-gpg-sign)
unless CONTRIBUTING.md says to or the user explicitly says so# gh CLI (https://cli.github.com/)
brew install gh # macOS
gh auth login # one-time
No Python dependencies. This skill is pure gh + git orchestration.
运行前读取本 Skill 包的 skill.yaml,由宿主提供 skill-runtime/v1 上下文。字段解析顺序为:当前请求、项目上下文、个人 Preferences、品牌 Profile、通用默认值。
required: true 字段缺失时,按 Manifest 的问题配置向用户提出一个聚焦问题;用户明确同意后再保存回答。context_id、字段路径与来源,诊断内容避开秘密、完整私人路径和原始配置。用户在 Skill 驱动任务中提出修改意见时,继续当前产物前必须执行:
task-specific(仅本次)还是 reusable(可跨任务复用)。task-specific 只修改当前任务,不改 Skill。reusable 先确定作用域:领域规则先更新对应 canonical Skill;适用于所有 Skill 的规则先更新共享规范。reusable 修改会使此前的“确认”“继续”“发吧”失效;完成当前产物修改和回读后必须停下,等待用户下一步指示,不自动进入发布、提交或其他外部写入。