Skip to main content

Pull requests to task management

Project description

uv logo pre-commit logo ruff logo bandit logo pytest logo

Docker logo GitHub Actions logo

GitHub PR Comments Fetcher

A Python CLI tool to fetch GitHub PR comments and optionally generate Claude Code hooks for processing them.

CodeQL GitHub CI GitHub license


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

  1. Clone the git repository

    git clone https://github.com/arthrod/pr_to_task.git
    
  2. Go into the project directory

    cd python-boilerplate/
    
  3. Checkout working branch

    git checkout <branch>
    
  4. Enable pre-commit hooks

    pre-commit install
    
  5. 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 configuration
  • process_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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pr_to_task-0.1.0.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pr_to_task-0.1.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

Details for the file pr_to_task-0.1.0.tar.gz.

File metadata

  • Download URL: pr_to_task-0.1.0.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pr_to_task-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34d0dec6f70d6c1d746b1a76e4b994dcdbc972de94aeb6e0b83d3bad6b42c7f9
MD5 d0bbbdc02b42cc92d4ed75503ecd391d
BLAKE2b-256 9ec72fb57be276f833a3512ac7259e4804afeea5c3310b5ae51996103b7f90e5

See more details on using hashes here.

File details

Details for the file pr_to_task-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pr_to_task-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 19.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for pr_to_task-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d9171073b44fe4a641d86b9353cc0fcdf11061f2e3e56c80f971d8d4813a465
MD5 682664e3a97ff7ea9cd2715fa646d807
BLAKE2b-256 042ce671cf7814b1e402df379e66a7cc74d44bb168cfbbdc814bf651335486d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page