-
Notifications
You must be signed in to change notification settings - Fork 31
Add fork-first PR workflow skill #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # fork-first-pr-workflow | ||
|
|
||
| Guide OpenHands through a safe GitHub contribution workflow that prefers a personal fork over direct upstream branch creation. | ||
|
|
||
| ## Triggers | ||
|
|
||
| This skill is activated by requests such as: | ||
|
|
||
| - "use my fork" | ||
| - "create a branch" | ||
| - "push my changes" | ||
| - "open a PR" | ||
| - "draft a PR to upstream" | ||
| - direct-push failures caused by missing upstream permissions | ||
|
|
||
|
Comment on lines
+5
to
+15
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion - Trigger Documentation Inconsistency: The README lists 6 trigger scenarios, but the SKILL.md frontmatter only defines 3. This confuses users about when the skill activates. Fix: Sync this list with the actual |
||
| ## What it does | ||
|
|
||
| - inspects remotes before choosing a push target | ||
| - treats upstream write access as unknown until confirmed | ||
| - prefers pushing feature branches to a fork | ||
| - opens pull requests from fork to upstream | ||
| - avoids auto-merge or branch-update loops when the real blocker is permissions | ||
|
|
||
| ## Notes | ||
|
|
||
| - Designed for reusable GitHub contribution workflows, not repository-specific rules. | ||
| - Works best alongside the existing `github` skill for GitHub CLI and API operations. | ||
| - Requires GitHub authentication for fork discovery, pushing, and pull request creation. | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,133 @@ | ||||||||||||||||||
| --- | ||||||||||||||||||
| name: fork-first-pr-workflow | ||||||||||||||||||
| description: This skill should be used when the user asks to "use my fork", "create a branch", "push my changes", "open a PR", "draft a PR to upstream", or when upstream repository permissions are missing or unclear. It guides a safe fork-first GitHub contribution workflow that prefers pushing to a personal fork and opening a pull request back to upstream. | ||||||||||||||||||
| triggers: | ||||||||||||||||||
| - use my fork | ||||||||||||||||||
| - draft a PR to upstream | ||||||||||||||||||
| - fork first | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔴 Critical - Trigger Mismatch: The triggers array only lists 3 items, but your description (line 3) and README.md claim this skill should trigger on "create a branch", "push my changes", and "open a PR". Either add those to the triggers array or remove them from the docs.
Suggested change
|
||||||||||||||||||
| --- | ||||||||||||||||||
|
|
||||||||||||||||||
| # Fork-First PR Workflow | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Objective | ||||||||||||||||||
|
Comment on lines
+10
to
+12
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion - Missing Progressive Disclosure: Per AgentSkills spec and this repo's rules, skills should start with a minimal summary. The agent should be able to decide "is this relevant?" from the first few lines. Current structure dumps everything upfront. Consider: ## Summary
Use fork-based workflow when upstream write access is unavailable or uncertain. Push to personal fork, open PR from fork→upstream.
## When to Use
[current "When to Apply" section]
<details>
<summary>Detailed Workflow (expand only if needed)</summary>
[current 14-step workflow]
</details> |
||||||||||||||||||
| Contribute through a personal fork when upstream branch creation or pushes are unavailable, undesirable, or uncertain. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## When to Apply | ||||||||||||||||||
| Apply this workflow when any of the following is true: | ||||||||||||||||||
|
|
||||||||||||||||||
| - The user explicitly asks to work from a fork. | ||||||||||||||||||
| - The repository is hosted on GitHub and upstream write access is unknown. | ||||||||||||||||||
| - Direct branch creation on the upstream repository fails. | ||||||||||||||||||
| - The user wants a PR from a fork to upstream. | ||||||||||||||||||
| - The user prefers a predictable contributor workflow instead of relying on upstream push permissions. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Core Workflow | ||||||||||||||||||
|
|
||||||||||||||||||
| 1. Inspect the repository state before making GitHub changes. | ||||||||||||||||||
| 2. Identify the upstream repository, default branch, current branch, and configured remotes. | ||||||||||||||||||
| 3. Treat upstream write access as unknown until it is confirmed. | ||||||||||||||||||
| 4. Prefer pushing to a fork remote when one exists and the user has not explicitly requested an upstream branch. | ||||||||||||||||||
| 5. If no fork remote exists, look up the authenticated GitHub user and check whether a fork already exists. | ||||||||||||||||||
| 6. If a fork exists, add it as a remote and push there. | ||||||||||||||||||
| 7. If no fork exists and the user asked to push or open a PR, create the fork or ask for confirmation when the request is ambiguous. | ||||||||||||||||||
| 8. Create a feature branch locally if the current branch is unsuitable. | ||||||||||||||||||
| 9. Push the branch to the fork remote. | ||||||||||||||||||
| 10. Open a pull request from the fork branch to the upstream base branch. | ||||||||||||||||||
| 11. Reuse the same PR and branch for follow-up commits unless the user explicitly asks for a new branch. | ||||||||||||||||||
|
Comment on lines
+23
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 Important - Violates Repository Principles: This repo's AGENTS.md explicitly states: "Prefer minimal, composable skills" and "SKILL.md should be progressive disclosure." This 14-step procedural workflow (133 lines total) violates both rules. The Problem: You're writing a manual, not a skill. The agent doesn't need step-by-step git commands—those belong in the Better Approach: Focus on the decision logic:
Compress this to ~30 lines of decision rules, then reference the |
||||||||||||||||||
|
|
||||||||||||||||||
| ## Remote Selection Rules | ||||||||||||||||||
|
|
||||||||||||||||||
| - Run `git remote -v` before choosing a push target. | ||||||||||||||||||
| - Distinguish the fork remote from the upstream remote explicitly. | ||||||||||||||||||
| - If `origin` points to upstream and a fork remote exists, push to the fork remote by name. | ||||||||||||||||||
| - If `origin` already points to the fork, keep `upstream` configured separately for fetches and PR targeting. | ||||||||||||||||||
| - Do not fail the workflow merely because upstream rejects branch creation or push access. | ||||||||||||||||||
| - Do not assume the remote named `origin` is always the correct push target. | ||||||||||||||||||
|
|
||||||||||||||||||
|
Comment on lines
+38
to
+46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟠 Important - Overlap with Existing Skill: The Risk: When the Suggestion: Reference the |
||||||||||||||||||
| ## Branching Rules | ||||||||||||||||||
|
|
||||||||||||||||||
| - Never push directly to `main` or `master`. | ||||||||||||||||||
| - Create a descriptive feature branch before pushing. | ||||||||||||||||||
| - Check `git status --short` before switching branches or committing. | ||||||||||||||||||
| - Stop and ask the user if unrelated uncommitted changes are present. | ||||||||||||||||||
| - Keep later fixes on the same branch when updating an existing PR. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Pull Request Rules | ||||||||||||||||||
|
|
||||||||||||||||||
| - Prefer the GitHub API or `gh` CLI over browser-based GitHub flows. | ||||||||||||||||||
| - Target the upstream repository's default branch unless the user requests another base branch. | ||||||||||||||||||
| - Use a draft PR when the user explicitly asks for a draft. | ||||||||||||||||||
| - After opening the PR, report the PR link and summarize the source branch, head repository, and base branch. | ||||||||||||||||||
| - When posting a PR title or description for humans, include a short AI disclosure note required by the environment policy. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Approval and Merge Follow-up | ||||||||||||||||||
|
|
||||||||||||||||||
| - After approval, check mergeability and actor permissions before attempting to merge. | ||||||||||||||||||
| - If merge permissions are missing, leave a concise maintainer-facing follow-up comment instead of looping on auto-merge. | ||||||||||||||||||
| - Avoid repeated branch-update or auto-merge retries when the blocker is repository permissions. | ||||||||||||||||||
| - If the PR needs a base-branch update, confirm with the user before performing a rebase or merge that could affect review state. | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Useful Commands | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Inspect remotes and branch state | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| git remote -v | ||||||||||||||||||
| git branch --show-current | ||||||||||||||||||
| git status --short | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Identify the authenticated GitHub user | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| export GH_TOKEN="$GITHUB_TOKEN" | ||||||||||||||||||
| gh api user --jq .login | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Check whether a fork already exists | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| export GH_TOKEN="$GITHUB_TOKEN" | ||||||||||||||||||
| gh api repos/<login>/<repo> --jq '{full_name: .full_name, parent: .parent.full_name}' | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Add a fork remote | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| git remote add fork https://github.com/<login>/<repo>.git | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Push the current branch to the fork explicitly | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| git push -u fork HEAD | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ### Create a PR from fork to upstream | ||||||||||||||||||
|
|
||||||||||||||||||
| ```bash | ||||||||||||||||||
| export GH_TOKEN="$GITHUB_TOKEN" | ||||||||||||||||||
| gh pr create \ | ||||||||||||||||||
| --repo <upstream-owner>/<repo> \ | ||||||||||||||||||
| --head <fork-owner>:<branch> \ | ||||||||||||||||||
| --base <base-branch> \ | ||||||||||||||||||
| --title "<title>" \ | ||||||||||||||||||
|
Comment on lines
+69
to
+114
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 Suggestion - Command Reference Bloat: These 45 lines of bash commands are maintenance burden and duplicate what's already in the Pragmatic Take: If the agent needs git command syntax, it already has the Consider: Keep 2-3 key examples (e.g., fork detection, remote setup) and remove the rest. Or extract to a separate reference doc. |
||||||||||||||||||
| --body-file <body-file> | ||||||||||||||||||
| ``` | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Output Expectations | ||||||||||||||||||
|
|
||||||||||||||||||
| Provide a short final update that includes: | ||||||||||||||||||
|
|
||||||||||||||||||
| - which remote was treated as upstream | ||||||||||||||||||
| - which remote was used for pushing | ||||||||||||||||||
| - the created or reused branch name | ||||||||||||||||||
| - whether the PR is draft or ready for review | ||||||||||||||||||
| - the PR link or the blocker that prevented opening it | ||||||||||||||||||
|
|
||||||||||||||||||
| ## Failure Handling | ||||||||||||||||||
|
|
||||||||||||||||||
| - If GitHub authentication fails, refresh the token-backed remote or re-run the GitHub command with `GH_TOKEN` exported. | ||||||||||||||||||
| - If no fork is available and the user did not clearly authorize creating one, stop and ask. | ||||||||||||||||||
| - If upstream PR creation fails because the head branch is missing, verify the push target and branch name before retrying. | ||||||||||||||||||
| - If permissions block merging after approval, report the blocker and prepare a maintainer handoff message. | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟢 Acceptable: JSON structure looks fine and alphabetically placed. Keywords are reasonable.