К основному содержанию
скилл CX Codex

push-to-forked-pr — скилл для Claude Code: отправка в PR

Скилл push-to-forked-pr отправляет текущие изменения в ветку PR, которая находится в чужом форке. Он пригодится, когда нужно обновить PR без создания новой ветки.

MIT ★ 1 198 обновлён 2026-10-23

Установить в Claude Code · Через Skills CLI (Vercel) Все способы и платформы ↓
npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill push-to-forked-pr -a claude-code
Открыть на GitHub

Что делает push-to-forked-pr

Скилл проверяет метаданные PR через gh, сверяет ветку и текущий коммит, а затем отправляет изменения в репозиторий форка. Это помогает не перепутать форк с origin, который обычно указывает на основной репозиторий. Для внутреннего PR предусмотрен отдельный путь отправки в origin.

Перед отправкой скилл проверяет права на запись, автора коммита и состояние локальной ветки. Он также запускает проверки проекта до push и останавливается при первой ошибке. Если вы не владелец форка, для отправки нужны права записи в основном репозитории и maintainerCanModify: true; иначе скилл прекращает работу. Принудительная отправка без разрешения пользователя запрещена.

Какие задачи решает

  • отправить изменения в ветку PR из форка
  • обновить PR, не создавая новую ветку
  • проверить, что origin не указывает на форк
  • остановить отправку при проблемах с правами или проверками

Примеры запросов агенту

  • Отправь текущие изменения прямо в PR #42 из форка, не создавая новую ветку.
  • Проверь права и отправь коммит в ветку форка для PR #42.
  • Обнови PR #42, сначала запусти проверки проекта и не отправляй изменения при ошибке.

Как установить push-to-forked-pr

1Через Skills CLI (Vercel)

npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill push-to-forked-pr -a claude-code

2Вручную: положить файлы

~/.claude/skills/push-to-forked-pr/SKILL.md

Папка скилла целиком; для одного проекта — .claude/skills/push-to-forked-pr/

По шагам, с командами для каждой платформы: Как установить скилл в Claude Code: пять способов

Вопросы о push-to-forked-pr

Как установить push-to-forked-pr в Claude Code?

Выполните npx skills add hoangsonww/Claude-Code-Agent-Monitor --skill push-to-forked-pr -a claude-code. Файл скилла устанавливается по пути ~/.claude/skills/push-to-forked-pr/SKILL.md.

Что делает push-to-forked-pr?

Он проверяет PR и локальную ветку, затем отправляет текущий коммит в ветку PR на форке, а не в origin. Перед отправкой скилл запускает проверки проекта.

Какие права нужны, чтобы отправить изменения в форк?

Нужно быть владельцем форка либо иметь права записи в основном репозитории, если для PR включено maintainerCanModify: true. Иначе скилл останавливается.

Исходный текст

SKILL.md · MIT
---
name: push-to-forked-pr
description: Push the current working tree directly to a GitHub PR whose head lives on a **fork**, without creating a new branch and without pushing to `origin` (which is usually the upstream). Invoke when the user says things like "push straight to PR #N", "push to the forked PR", "update PR from fork", "push these changes to #N directly", "commit and push to the PR" — *especially* when they emphasise not creating a new branch or not pushing into the upstream repo. Use this **instead of** plain `git push origin` whenever the PR head repo differs from the local `origin` repo.
---

# push-to-forked-pr

The whole point of this skill: **`origin` is usually the upstream, but the PR's head is on someone else's fork.** Pushing to `origin` updates the upstream's branch, not the PR. You have to push to the fork.

GitHub allows this in two situations:

1. You are the **fork owner** — straightforward, you own that branch.
2. You are an **upstream maintainer** and the PR has `maintainerCanModify: true` (the "Allow edits from maintainers" checkbox the PR author leaves on by default). GitHub then lets the upstream's auth push to the fork branch.

If neither holds, abort and tell the user only the fork owner can push.

---

## Procedure

### 1. Read the PR's head metadata

```bash
PR_NUMBER=<N>
gh pr view "$PR_NUMBER" --json state,headRefName,headRefOid,headRepository,headRepositoryOwner,maintainerCanModify,url
```

Capture:

- `state` — bail if not `"OPEN"`.
- `headRepository.nameWithOwner` → the **fork** (e.g. `someone/Repo`).
- `headRepositoryOwner.login` → the fork owner.
- `headRefName` → the branch on the fork (usually matches local).
- `headRefOid` → the PR's current head SHA. Your local HEAD must be a descendant.
- `maintainerCanModify` → must be `true` if you are not the fork owner.

If `headRepository.nameWithOwner` matches the upstream's `nameWithOwner`, this PR is **internal**:

```bash
HEAD_BRANCH=$(gh pr view "$PR_NUMBER" --json headRefName --jq .headRefName)
HEAD_REF_OID=$(gh pr view "$PR_NUMBER" --json headRefOid --jq .headRefOid)
git merge-base --is-ancestor "$HEAD_REF_OID" HEAD && echo ok || echo NOT-DESCENDANT   # abort if NOT-DESCENDANT
git push origin "HEAD:${HEAD_BRANCH}"
```

Exit the skill once this push lands — do not continue to the fork-push steps below.

### 2. Confirm you can actually push

```bash
gh auth status                        # who am I?
git remote get-url origin             # fetch URL — confirm origin is the UPSTREAM, not the fork
git remote get-url --push origin      # push URL — can differ from the fetch URL if `pushurl` is configured
```

For the internal-PR path above, compare the **push** URL (not just the fetch URL) against the expected upstream `nameWithOwner` before relying on `git push origin` — a configured `pushurl` can silently redirect the push to a different destination than the fetch URL suggests.

You may push to the fork branch iff the active gh user is:

- the fork owner, **or**
- a writer on the upstream **and** `maintainerCanModify == true`.

Otherwise stop. Tell the user the PR doesn't allow maintainer edits.

### 3. Sanity-check the local branch

```bash
git branch --show-current
git rev-parse HEAD
git merge-base --is-ancestor <headRefOid> HEAD && echo ok || echo NOT-DESCENDANT
```

- If `headRefName` differs from the current local branch, that's fine — you'll push with an explicit refspec `local:headRefName` in step 6.
- If local HEAD is **not** a descendant of `headRefOid`, stop. Either you're on the wrong branch, or someone else has pushed to the PR since you forked from it. Do not force-push without explicit user permission.

### 4. Verify commit author identity before committing

```bash
git config user.email
```

If it is empty, hostname-shaped (`[email protected]`, `*@*.tail*.ts.net`, etc.), or otherwise not a real email tied to a GitHub account, the commit will appear "unverified" on GitHub and won't link to a profile. Override per-commit:

```bash
git -c user.name="<Name>"  -c user.email="<email>"  commit -F /tmp/commit-msg.txt
```

To correct an already-made commit before push:

```bash
git -c user.name="..." -c user.email="..." commit --amend --reset-author -C HEAD --no-edit
```

Prefer the user's documented identity (e.g. from `CLAUDE.md` or earlier in the session) over the local git config when the local config is clearly machine-generated.

### 5. Run the repo's full verification suite — **before** pushing

The user almost always asks for this explicitly. In this repo (see `CLAUDE.md` for the authoritative list):

```bash
npm run format:check                        # tracked files only; local .worktrees/ noise is not yours to fix
npm run test:server                         # backend touched
npm run test:client                         # frontend, wiki i18n, screen snapshots
npm run mcp:typecheck && npm run mcp:build  # mcp/ touched
npm --prefix mcp test                       # mcp unit suite
npm run build                               # production client build
bash .claude/skills/file-headers/scripts/check-headers.sh
```

Per-package extras when those areas are touched:

```bash
npm --prefix desktop run build && npm --prefix desktop test
node scripts/validate-agent-extensions.js
```

Stop on the first red. Report which check failed and **do not push**.

### 6. Stage, commit, push to the fork (not origin)

Exclude session-local noise (`.claude/settings.local.json` is harness state, not work) and never stage blindly:

```bash
git status                          # review exactly what changed
git add <path1> <path2> ...         # stage only the files for this PR's change — never `git add -A`
git status                          # confirm the staged diff matches intent (and excludes .claude/settings.local.json) before committing
```

Commit with a real body (use `-F` for multi-paragraph messages), ending with the `Co-Authored-By` trailer your harness requires — copy it verbatim from the harness instructions rather than from this file, so the model name never goes stale.

Then push to the fork. Add a one-off remote so it's clear in `git remote -v` and the destination URL doesn't end up in the user's shell history:

```bash
FORK_REPO=$(gh pr view "$PR_NUMBER" --json headRepository --jq '.headRepository.nameWithOwner')
HEAD_BRANCH=$(gh pr view "$PR_NUMBER" --json headRefName   --jq .headRefName)
LOCAL_BRANCH=$(git branch --show-current)

if [ -z "$LOCAL_BRANCH" ]; then
  echo "Detached HEAD — refusing to push (source ref would be empty and delete ${HEAD_BRANCH} on the fork)." >&2
  exit 1
fi

git remote add "pr${PR_NUMBER}-fork" "https://github.com/${FORK_REPO}.git"
git push "pr${PR_NUMBER}-fork" "HEAD:${HEAD_BRANCH}"    # push HEAD itself, not "$LOCAL_BRANCH" — safe even if the local branch name differs
```

`gh` configures git's credential helper, so HTTPS pushes pick up the right token automatically. Don't rewrite to SSH unless asked.

### 7. Verify the push landed on the PR

```bash
LOCAL_HEAD=$(git rev-parse HEAD)
PR_HEAD=$(gh pr view "$PR_NUMBER" --json headRefOid --jq .headRefOid)
[ "$LOCAL_HEAD" = "$PR_HEAD" ] && echo "PR updated ✓" || echo "MISMATCH — push went somewhere else"
```

Report the new HEAD SHA, the PR URL, and the diff stat back to the user.

---

## Common failure modes

| Symptom | Cause | Fix |
|---|---|---|
| `Permission denied` on push | Authenticated as the wrong user, or `maintainerCanModify: false` and you are not the fork owner | Abort. Only the fork owner can push to the branch. |
| `! [rejected] non-fast-forward` | Someone else pushed to the PR since you started | `git fetch "pr${PR_NUMBER}-fork" "${HEAD_BRANCH}"`, then rebase or merge. **Never** force-push someone else's PR branch without explicit permission. |
| Push succeeds, but PR head SHA doesn't update | You pushed to a branch with a different name on the fork | Re-check `headRefName` and use explicit refspec `LOCAL:HEAD_BRANCH`. |
| Commit shows "unverified" on the PR | Author email isn't tied to a verified GitHub account | Amend with the user's real identity (step 4) and push again (fast-forward, not force). |
| `Could not resolve host` | Network or proxy issue | Surface the error. Don't blanket-retry. |

---

## Hard rules

- **Never push to `origin`** when origin is the upstream and the PR head is a fork. Always verify with `git remote -v` and `gh pr view`.
- **Never create a new branch.** The user pushed because they want *this* PR updated; a new branch defeats that.
- **Never force-push** to a fork PR branch without explicit user permission. The fork owner will lose any commits they had locally.
- **Always run the repo's tests/builds first.** A fork-PR push triggers CI on the fork *and* surfaces on the upstream's PR view — pushing red code is doubly visible.
- **Always exclude `.claude/settings.local.json`** unless the user explicitly says to include it. It's harness session state, not the work.
- **Never stage with `git add -A`.** Stage explicit paths for the requested change so unrelated files or local secrets can't ride along.

© hoangsonww · MIT · hoangsonww/Claude-Code-Agent-Monitor

Похожие скиллы

Все скиллы по теме «Git и GitHub» →
ce-commit-push-pr EveryInc Скилл ce-commit-push-pr коммитит изменения, отправляет ветку и открывает PR. Отдельно умеет составлять или переписывать описание PR без публикации кода. CX Codex +1 3 600установок Push to GitHub официальный google Скилл Push to GitHub запускает тесты, проверяет код и отправляет изменения в GitHub. Используй его перед финальным push, чтобы не сломать CI. CX Codex +1 21установок commit-push-pr dyoshikawa Скилл commit-push-pr коммитит текущие изменения, отправляет ветку в remote и создаёт или обновляет pull request. Подходит для отправки готовой работы через GitHub. CX Codex +1 ★ 1 636звёзд репо GitHub SSH Setup for Students (Existing Repository, Clone & Push Ready) senoldak GitHub SSH Setup for Students (Existing Repository, Clone & Push Ready) — промпт для ChatGPT, Claude.ai и Claude Code: пошагово настраивает SSH-доступ к GitHub и клонирует существующий проект без токенов и паролей. GP ChatGPT ★ 178 201звёзд репо w-fix-push blockmatic-icebox Скилл w-fix-push для Claude Code исправляет перечисленные ошибки, запускает подходящую проверку, затем коммитит и отправляет изменения. Работает по запросу на исправление конкретных проблем. CX Codex +1 647установок w-push blockmatic-icebox Скилл w-push для Claude Code проверяет изменения и отправляет нужную ветку в удалённый репозиторий. Запускается по запросу отправить текущую задачу. CX Codex +1 647установок

Из того же набора155

Весь набор →
token-economist Субагент token-economist анализирует расходы токенов и кэш в Claude Code через дашборд Agent Monitor, переводя метрики сессий в понятные расчёты экономии в долларах. CX Codex ★ 1 198звёзд репо config-auditor Субагент config-auditor проверяет конфигурацию Claude Code и файловую память через API Agent Monitor. Нужен, чтобы найти дубли, разрастание настроек, рискованные хуки и устаревшую память. CX Codex ★ 1 198звёзд репо budget-sentinel Субагент budget-sentinel сравнивает реальные траты Claude с заданным бюджетом, прогнозирует конец месяца и показывает, какие сессии тянут расход вверх. CX Codex ★ 1 198звёзд репо wiki-i18n Правило wiki-i18n контролирует переводы статической вики на китайский, вьетнамский, корейский и испанский языки при правках HTML и скриптов проекта. CX Codex +1 ★ 1 198звёзд репо update-project-docs Скилл update-project-docs для Claude Code обновляет документацию после изменений кода, конфигурации, API, БД или интерфейсов. Агент запускает его при изменении env-переменных, хуков, событий, WebSocket-сообщений и CLI-команд. CX Codex +1 ★ 1 198звёзд репо version-release Скилл version-release помогает выбрать тип релиза по SemVer и синхронизировать версию приложения во всех манифестах, пакетах и файлах деплоя. CX Codex +1 ★ 1 198звёзд репо i18n-parity Скилл i18n-parity для Claude Code помогает сохранять переводы проекта синхронными на всех языковых поверхностях. Он подключается при изменении интерфейсного текста, ключей i18n, README или wiki. CX Codex +1 ★ 1 198звёзд репо ccam-workflows Плагин ccam-workflows для Claude Code и Codex анализирует запуски многоагентных рабочих процессов через API Agent Monitor на localhost:4820. CX Codex ★ 1 198звёзд репо

Спонсоры проекта

Компании, которые помогают держать аналитику открытой