Skip to content

Add gh-knowledge-base.sh script for GitHub issue/PR archival#1

Open
kertal wants to merge 1 commit into
mainfrom
claude/github-pr-issues-downloader-ryaPl
Open

Add gh-knowledge-base.sh script for GitHub issue/PR archival#1
kertal wants to merge 1 commit into
mainfrom
claude/github-pr-issues-downloader-ryaPl

Conversation

@kertal

@kertal kertal commented Feb 13, 2026

Copy link
Copy Markdown
Owner

Summary

This PR introduces gh-knowledge-base.sh, a comprehensive Bash script that downloads GitHub Issues and Pull Requests filtered by label, along with all their comments, and saves them as organized Markdown files. The output is structured by year/month and optimized for searching in LLM-powered tools like Cursor and GitHub Copilot.

Key Changes

  • New script: gh-knowledge-base.sh — A 597-line Bash utility that:

    • Fetches issues and/or PRs from a GitHub repository filtered by label and state
    • Downloads all associated comments (including PR review comments with diff context)
    • Organizes output into YYYY/MM-month/ directory structure
    • Generates beautifully formatted Markdown files with metadata tables, author badges, and reaction counts
    • Includes PR-specific details (merge status, branch info, file/line changes)
    • Implements rate-limiting pauses to respect GitHub API quotas
    • Builds an auto-generated index file with statistics and file listings
  • Configuration files:

    • .gitignore — Excludes .env and the knowledge-base/ output directory
    • .env.example — Template for GITHUB_TOKEN environment variable with setup instructions

Notable Implementation Details

  • Flexible filtering: Supports filtering by label, state (open/closed/all), and type (issues/prs/all) with configurable limits
  • Rich metadata: Each file includes author, creation/update dates, labels, assignees, and direct GitHub links in structured table format
  • Comment rendering: Distinguishes comment authors by role (Owner, Member, Collaborator, Contributor) and includes reaction counts
  • PR-specific features: Captures merge status, branch information, commit/file/addition/deletion counts, and inline diff context for review comments
  • Robust error handling: Validates dependencies (gh CLI, jq), authentication, and provides helpful error messages
  • Colorized output: Uses ANSI colors for clear, readable console feedback during execution
  • Pagination support: Uses gh api --paginate to handle repositories with many comments

Usage Example

./gh-knowledge-base.sh --repo facebook/react --label bug --state closed --output ./my-kb

This creates a searchable knowledge base ideal for context injection into LLM-powered development tools.

https://claude.ai/code/session_017Miq8dGAzuYS2Lng1stFUs

Bash script using gh CLI to download Issues and PRs filtered by label,
with all comments, formatted as Markdown files organized by year/month.
Designed for searchability in Cursor, Copilot, and other LLM tools.

https://claude.ai/code/session_017Miq8dGAzuYS2Lng1stFUs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants