Pr shepherd

From DogaOztuzun/branchdeck · View interactive version

Pr shepherd is an AI agent skill from the GitHub repository DogaOztuzun/branchdeck. Analyze and fix failing GitHub PRs. Check .branchdeck/analysis.json to determine current state. If no analysis exists, analyze the PR. If analysis is approved, execute the fix plan.

How to use this skill

Skill file

PR Shepherd Workflow

You are shepherding a GitHub PR to get it ready to merge.

Get PR context

Read .branchdeck/pr-context.json for the PR you're working on:

Use these values in all gh commands below.

Determine your phase

Check if .branchdeck/analysis.json exists in the current worktree.

If it does NOT exist → Analyze

  1. Read PR status: gh pr checks <number> --repo <repo>
  2. Read review comments: gh pr view <number> --repo <repo> --comments
  3. Read inline review comments: gh api repos/<owner>/<repo>/pulls/<number>/comments
  4. Search codebase for relevant patterns
  5. Check recent git history: git log --oneline -20
  6. Classify confidence:
  1. Write .branchdeck/analysis.json with your findings:

```json

{

"pr": { "repo": "<repo>", "number": <number>, "branch": "<branch>" },

"confidence": "HIGH|MEDIUM|LOW",

"failures": [

{

"check_name": "<CI check name>",

"error_summary": "<one-line summary>",

"root_cause": "<what actually went wrong>",

"fix_approach": "<how to fix it>"

}

],

"reviews": [

{

"reviewer": "<username>",

"comment": "<review comment>",

"proposed_response": "<how you'd address it>"

}

],

"plan_steps": [

{

"description": "<what to do>",

"file": "<file path>",

"change_type": "modify|create|delete"

}

],

"affected_files": ["<file1>", "<file2>"],

"reasoning": "<brief explanation of your analysis>",

"approved": false,

"approved_plan": null,

"resolved": false

}

```

  1. End your session. A human will review your analysis.

If it exists with approved: true → Fix

  1. Read approved_plan from .branchdeck/analysis.json

(the human may have edited the plan)

  1. Execute each plan step in order
  2. Follow the project's code standards (see CLAUDE.md)
  3. Run the project's check suite (see CLAUDE.md for commands)
  4. Stage, commit, push:

```

git add <affected files>

git commit -m "fix: <concise summary>"

git push

```

  1. Verify CI: gh pr checks <number> --repo <repo> --watch
  2. If CI still fails, analyze the new failure and fix it (up to 3 attempts)
  3. When done, update analysis.json: set resolved: true

If it exists with approved: false → Wait

Do nothing. End your session. The human hasn't reviewed yet.

Troubleshooting

If gh commands fail with 403/404, verify authentication: gh auth status

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.