| name | git-pr-reader |
| description | Unified interface for GitHub PRs and GitLab MRs: read PR/MR data with file filtering, list changed files, get review comments, post inline review comments, reply to existing comment threads, extract line numbers from diffs, validate comments, auto-detect PR/MR for current branch, and get unified diffs. Automatically detects GitHub vs GitLab from URL. Use this skill for analyzing code changes, posting review feedback, and documentation workflows. |
| author | Gabriel McGoldrick (gmcgoldr@redhat.com) |
| allowed-tools | Read, Bash, Grep, Glob |
Git PR Reader Skill
Unified interface for GitHub Pull Requests and GitLab Merge Requests — read, review, and post comments.
Capabilities
- Auto-detect Git platform: Automatically identifies GitHub vs GitLab from URL
- Read PR/MR data: Fetch title, description, and file-level diffs with smart filtering
- List changed files: Get file paths, statuses, and line counts with optional glob filtering
- Review comments: Fetch existing review comments/discussions, filter bots, include/exclude resolved
- Post review comments: Post inline comments on specific diff lines with duplicate detection and fallback to PR-level comments
- Reply to comments: Reply to existing review comment threads on GitHub PRs and GitLab MRs
- Extract line numbers: Parse diffs to get added/modified line numbers for accurate comment placement
- Validate comments: Check comment line numbers against actual diff content
- Auto-detect PR/MR: Find the open PR/MR for the current git branch (GitHub via
gh CLI, GitLab via API)
- Smart file filtering: Exclude irrelevant files using configurable YAML patterns:
- Test files (test/, *_test.go, *.spec.ts, etc.)
- Lock files (package-lock.json, *.lock, Pipfile.lock, etc.)
- CI/CD configs (.gitlab-ci.yml, .github/workflows/, Dockerfile, etc.)
- Build artifacts (dist/, build/, target/, *.class, etc.)
- Generated code (*.pb.go, *.gen.go, etc.)
- Vendor directories (node_modules/, vendor/, etc.)
- Images and binaries (*.png, *.jpg, *.svg, etc.)
Usage
Subcommands
read — Read PR/MR data with diffs and file filtering
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py read --url "https://github.com/owner/repo/pull/123"
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py read --url "https://gitlab.com/group/project/-/merge_requests/456" --format markdown
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py read --url "https://github.com/owner/repo/pull/123" --no-filter
info — Get PR/MR information
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py info https://github.com/owner/repo/pull/123 --json
files — List changed files
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py files https://github.com/owner/repo/pull/123
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py files https://github.com/owner/repo/pull/123 --filter "*.adoc" --json
comments — List review comments
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py comments https://github.com/owner/repo/pull/123
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py comments https://github.com/owner/repo/pull/123 --include-resolved --json
diff — Get unified diff
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py diff https://github.com/owner/repo/pull/123
post — Post review comments
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py post https://github.com/owner/repo/pull/123 comments.json
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py post https://github.com/owner/repo/pull/123 comments.json --review-type technical
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py post https://github.com/owner/repo/pull/123 comments.json --review-type style --dry-run
reply — Reply to an existing review comment
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py reply https://github.com/owner/repo/pull/123 --comment-id 12345 --body "Applied the fix."
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py reply https://gitlab.com/group/project/-/merge_requests/456 --discussion-id "abc123" --body "Fixed." --signoff "CI bot"
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py reply https://github.com/owner/repo/pull/123 --comment-id 12345 --body "Test" --dry-run
extract — Extract line numbers from diff
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py extract https://github.com/owner/repo/pull/123 path/to/file.adoc "pattern"
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py extract --dump https://github.com/owner/repo/pull/123 path/to/file.adoc
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py extract --validate https://github.com/owner/repo/pull/123 comments.json
metadata — Get combined PR/MR metadata
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py metadata https://github.com/owner/repo/pull/123
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py metadata https://gitlab.com/group/project/-/merge_requests/456
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py metadata https://github.com/owner/repo/pull/123 --diff-output /path/to/diff.patch
Returns combined metadata: platform, pr_number, title, description, state, author, base_branch, head_branch, labels, commits, changed_files, and url. With --diff-output, also saves the unified diff to the specified file.
detect — Auto-detect PR/MR for current branch
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py detect
uv run --script ${CLAUDE_SKILL_DIR}/scripts/git_pr_reader.py detect --json
Authentication
Set in ~/.env (global) or .env in the project root (local override). See docs-skills README for setup:
GITHUB_TOKEN=your-github-pat
GITLAB_TOKEN=your-gitlab-pat
The script loads .env files automatically — do not prepend source ~/.env to bash commands.
Python Library Usage
from git_pr_reader import GitReviewAPI
api = GitReviewAPI.from_url("https://github.com/owner/repo/pull/123")
data = api.get_pr_data()
info = api.get_pr_info()
files = api.get_changed_files()
metadata = api.get_metadata()
comments = api.get_review_comments()
api.post_comments([
{"file": "path/to/file.adoc", "line": 42, "message": "Issue description"}
])
api.reply_to_comment(comment_id=12345, body="Fixed.")
lines = api.extract_line_numbers("path/to/file.adoc")
results = api.validate_comments(comments_list)
Comments JSON Format
[
{"file": "path/to/file.adoc", "line": 42, "message": "Issue: missing title", "severity": "suggestion"},
{"file": "path/to/other.adoc", "line": 10, "message": "Typo in description", "severity": "suggestion"}
]
Configuration
File filtering patterns are defined in config/git_filters.yaml. You can customize these patterns for your specific needs.
Dependencies
Dependencies (PyGithub, python-gitlab, pyyaml) are declared via PEP 723 inline metadata and installed automatically by uv run --script.
Integration with Other Skills
This skill works well with:
- jira-reader: Combine JIRA issue context with Git code changes
- jira-writer: Generate release notes from JIRA + Git data, then push back to JIRA
- docs-review-style: Post style review findings as inline PR/MR comments
- docs-review-technical: Post technical review findings as inline PR/MR comments
Limitations
- GitHub API rate limits: 60 requests/hour (unauthenticated), 5000/hour (authenticated)
- GitLab API rate limits: 10 requests/second
- Only fetches file-level diffs, not commit-level history
- Requires public PRs/MRs unless authentication tokens are provided