Problem
When /ride-workspace is invoked with a GitHub/GitLab issue URL that already has an open PR, the skill creates a fresh branch from origin/main. This means the existing work on the PR is ignored and a duplicate branch is created, requiring the user to manually switch to the correct branch.
Expected Behavior
Before creating a worktree, the skill should check if the issue already has an open PR. If so, it should:
- Use the PR's branch (
headRefName) instead of generating a new feature/{repo}-{number}-{slug} branch
- Create the worktree tracking that existing remote branch
- Add the PR URL as a session link (
ride add-link ... --type pr)
- Include an "Existing Pull Request" section in the Claude Code prompt so the spawned session knows there's prior work
Proposed Changes to SKILL.md
1. Add PR detection step (between ticket metadata and worktree creation)
GitHub:
gh pr list --repo {owner}/{repo} --search "{issue_number}" --state open \
--json number,title,headRefName,url --limit 5
GitLab:
GITLAB_HOST={host} glab mr list --repo {org/repo} --search "{issue_number}"
If a PR is found, prefer PRs whose headRefName contains the issue number. Use the PR branch for the worktree instead of creating a new one.
2. Add third git worktree path
# If PR found — use PR's branch:
git -C {repo_path} worktree add {path} \
-b {pr_branch_name} \
--track origin/{pr_branch_name}
3. Add PR link to session
ride add-link --session {session_id} --label "Pull Request" --url "{pr_url}" --type pr
4. Update prompt template
When a PR exists, add to the prompt:
## Existing Pull Request
There is an existing open PR for this issue. Review it before planning:
\`\`\`bash
gh pr view {pr_url} --comments
\`\`\`
This workspace is checked out on the PR's branch. Review existing changes with `git log origin/main..HEAD` before adding new work.
And update instructions to include "Review the existing PR and its changes" before planning.
Acceptance Criteria
Problem
When
/ride-workspaceis invoked with a GitHub/GitLab issue URL that already has an open PR, the skill creates a fresh branch fromorigin/main. This means the existing work on the PR is ignored and a duplicate branch is created, requiring the user to manually switch to the correct branch.Expected Behavior
Before creating a worktree, the skill should check if the issue already has an open PR. If so, it should:
headRefName) instead of generating a newfeature/{repo}-{number}-{slug}branchride add-link ... --type pr)Proposed Changes to SKILL.md
1. Add PR detection step (between ticket metadata and worktree creation)
GitHub:
gh pr list --repo {owner}/{repo} --search "{issue_number}" --state open \ --json number,title,headRefName,url --limit 5GitLab:
GITLAB_HOST={host} glab mr list --repo {org/repo} --search "{issue_number}"If a PR is found, prefer PRs whose
headRefNamecontains the issue number. Use the PR branch for the worktree instead of creating a new one.2. Add third git worktree path
# If PR found — use PR's branch: git -C {repo_path} worktree add {path} \ -b {pr_branch_name} \ --track origin/{pr_branch_name}3. Add PR link to session
ride add-link --session {session_id} --label "Pull Request" --url "{pr_url}" --type pr4. Update prompt template
When a PR exists, add to the prompt:
And update instructions to include "Review the existing PR and its changes" before planning.
Acceptance Criteria