Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions marketplaces/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@
"demo"
]
},
{
"name": "fork-first-pr-workflow",
"source": "./fork-first-pr-workflow",
"description": "Guide a safe GitHub contribution workflow that prefers pushing to a personal fork and opening a pull request back to upstream when direct upstream branch access is missing or unclear.",
Copy link
Copy Markdown
Contributor

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.

"category": "productivity",
"keywords": [
"github",
"git",
"fork",
"pull-request",
"workflow"
]
},
{
"name": "frontend-design",
"source": "./frontend-design",
Expand Down
28 changes: 28 additions & 0 deletions skills/fork-first-pr-workflow/README.md
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 triggers: array in SKILL.md (after you fix that).

## 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.
133 changes: 133 additions & 0 deletions skills/fork-first-pr-workflow/SKILL.md
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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
triggers:
- use my fork
- create a branch
- push my changes
- open a PR
- draft a PR to upstream
- fork first

---

# Fork-First PR Workflow

## Objective
Comment on lines +10 to +12
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 github skill's command reference.

Better Approach: Focus on the decision logic:

  • When should I use a fork vs. direct push?
  • How do I detect if I have upstream write access?
  • What's the fallback when direct push fails?

Compress this to ~30 lines of decision rules, then reference the github skill for actual git mechanics.


## 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 Important - Overlap with Existing Skill: The github skill already covers remote management, PR creation, and GitHub API usage. This creates two sources of truth.

Risk: When the github skill gets updated (e.g., new gh CLI syntax), this skill won't be, causing drift.

Suggestion: Reference the github skill for mechanics: "Use the github skill's PR creation workflow, but select the fork remote as push target." Don't redefine the entire GitHub workflow here.

## 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
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 github skill documentation.

Pragmatic Take: If the agent needs git command syntax, it already has the github skill and gh CLI docs. This skill should focus on workflow logic, not command syntax.

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.
Loading