GitHub PR Comments Fetcher
A Python CLI tool to fetch GitHub PR comments and optionally generate Claude Code hooks for processing them.
Table of Contents
Prerequisites
- Python >=3.11.0 (tested with 3.11.14 and 3.13.7)
- pre-commit >=3.2.0 <5.0.0 (tested with 4.3.0)
- uv >=0.8.17 (tested with 0.8.24)
- docker (optional)
Installation
-
Clone the git repository
git clone https://github.com/arthrod/pr_to_task.git
-
Go into the project directory
cd python-boilerplate/
-
Checkout working branch
git checkout <branch>
-
Enable pre-commit hooks
pre-commit install -
Configure Python environment
uv python install uv venv source .venv/bin/activate uv sync
Usage
The get-pr-comments CLI tool fetches GitHub PR comments and generates a JSONL file. It can optionally generate Claude Code hooks for processing comments one at a time.
Basic Usage
# Activate virtual environment
source .venv/bin/activate
# Fetch comments from a public repository
uv run get-pr-comments --project owner/repo --pr 123
# With authentication (for private repos or higher rate limits)
export GITHUB_TOKEN=your_token_here
uv run get-pr-comments --project owner/repo --pr 123
# Or provide token directly
uv run get-pr-comments --project owner/repo --pr 123 --token your_token_here
Command Options
--user TEXT: GitHub username (default: "arthrod")--token TEXT: GitHub personal access token (optional for public repos)--project TEXT: GitHub repository in format "owner/repo" (required)--pr INTEGER: Pull request number (required)--since TEXT: Filter comments since date in ISO 8601 format (optional)--quantity INTEGER: Number of comments to fetch from most recent (optional)--output PATH: Output JSONL file path (default: "pr_comments.jsonl")--hooks: Generate Claude Code hooks configuration (default: false)
With Claude Code Hooks
Generate hooks to process comments automatically in Claude Code:
uv run get-pr-comments --project owner/repo --pr 123 --hooks
This creates:
.claude/settings.json: Claude Code hooks configurationprocess_comments.py: Script to process comments one at a time
The SessionStart hook will automatically present comments to Claude one line at a time.
Examples
# Fetch last 10 comments from a PR
uv run get-pr-comments --project arthrod/my-repo --pr 42 --quantity 10
# Fetch comments since a specific date
uv run get-pr-comments --project arthrod/my-repo --pr 42 --since "2024-01-01T00:00:00Z"
# Generate hooks and custom output file
uv run get-pr-comments --project arthrod/my-repo --pr 42 --output my_comments.jsonl --hooks
# Get help
uv run get-pr-comments --help
Output Format
The tool generates a JSONL file where each line is a JSON object representing one complete comment:
{
"comment_id": 123456,
"comment_url": "https://github.com/owner/repo/pull/42#discussion_r123456",
"author": "username",
"created_at": "2024-01-01T12:00:00Z",
"updated_at": "2024-01-01T12:00:00Z",
"comment_type": "review",
"path": "src/file.py",
"position": 10,
"line": 42,
"text": "This is the full comment text.\nIt can contain multiple lines.\nAll preserved in a single JSON object."
}
What's in the box ?
uv
uv is an extremely fast Python package and project manager, written in Rust.
pyproject.toml file (pyproject.toml): orchestrate your project and its dependencies
uv.lock file (uv.lock): ensure that the package versions are consistent for everyone
working on your project
For more configuration options and details, see the configuration docs.
pre-commit
pre-commit is a framework for managing and maintaining multi-language pre-commit hooks.
.pre-commit-config.yaml file (.pre-commit-config.yaml): describes what repositories and
hooks are installed
For more configuration options and details, see the configuration docs.
ruff
ruff is an extremely fast Python linter, written in Rust.
Rules are defined in the pyproject.toml.
For more configuration options and details, see the configuration docs.
mypy
mypy is an optional static type checker for Python that aims to combine the benefits of dynamic (or "duck") typing and static typing.
Rules are defined in the pyproject.toml.
For more configuration options and details, see the configuration docs.
bandit
bandit is a tool designed to find common security issues in Python code.
Rules are defined in the pyproject.toml.
For more configuration options and details, see the configuration docs.
docformatter
docformatter is a tool designed to format docstrings to follow PEP 257.
Options are defined in the .pre-commit-config.yaml.
Testing
We are using pytest & pytest-cov to write tests.
To run tests:
uv run pytest tests
Output
collected 1 item
tests/test_python_boilerplate.py::test_hello_world PASSED
To run tests with coverage:
uv run pytest tests --cov=src
Output
collected 1 item
tests/test_python_boilerplate.py::test_hello_world PASSED
---------- coverage: platform linux, python 3.13.7-final-0 -----------
Name Stmts Miss Cover
--------------------------------------------------------
src/python_boilerplate/__init__.py 1 0 100%
src/python_boilerplate/main.py 6 2 67%
--------------------------------------------------------
TOTAL 7 2 71%
Docker
Build
To build the docker production image using Dockerfile:
docker build . -t my-python-application:latest
To build the docker development image using Dockerfile:
docker build . --target development -t my-python-application:dev
Run
To run the python app example inside Docker:
docker run -it --rm my-python-application:latest # or :dev for development
Output
Hello World
Execute command inside container
docker run -it --rm my-python-application:latest bash
Metadata
Release files for pr-to-task 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pr_to_task-0.1.0.tar.gz | 14.9 kB | Without provenance | Details for pr_to_task-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pr_to_task-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pr_to_task-0.1.0-py3-none-any.whl |
Total release size: 34.2 kB
Release files / pr_to_task-0.1.0.tar.gz
| Download URL | pr_to_task-0.1.0.tar.gz |
|---|---|
| Size | 14.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34d0dec6f70d6c1d746b1a76e4b994dcdbc972de94aeb6e0b83d3bad6b42c7f9
|
|
BLAKE2b-256 checksum How to use checksums |
9ec72fb57be276f833a3512ac7259e4804afeea5c3310b5ae51996103b7f90e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / pr_to_task-0.1.0-py3-none-any.whl
| Download URL | pr_to_task-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d9171073b44fe4a641d86b9353cc0fcdf11061f2e3e56c80f971d8d4813a465
|
|
BLAKE2b-256 checksum How to use checksums |
042ce671cf7814b1e402df379e66a7cc74d44bb168cfbbdc814bf651335486d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for pr-to-task 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.