github-code

star 1

GitHub code search, file reading, PR review, branch/file management, and commit operations. Use when you need to search code patterns, read repository files, review pull requests, create branches, commit files, or open PRs.

incidentfox By incidentfox schedule Updated 2/23/2026

name: github-code description: GitHub code search, file reading, PR review, branch/file management, and commit operations. Use when you need to search code patterns, read repository files, review pull requests, create branches, commit files, or open PRs. allowed-tools: Bash(python *)

GitHub Code & PR Integration

Authentication

Set the GITHUB_TOKEN environment variable with a GitHub personal access token or fine-grained token.


Available Scripts

All scripts are in .claude/skills/github-code/scripts/

Code Search & Reading

search_code.py - Search Code Patterns

python .claude/skills/github-code/scripts/search_code.py --query "SEARCH_TERM" [--repo OWNER/REPO]

# Examples:
python .claude/skills/github-code/scripts/search_code.py --query "authentication" --repo acme/webapp
python .claude/skills/github-code/scripts/search_code.py --query "def handle_webhook"
python .claude/skills/github-code/scripts/search_code.py --query "TODO" --repo acme/webapp --limit 50

read_file.py - Read File from Repository

python .claude/skills/github-code/scripts/read_file.py --repo OWNER/REPO --path FILE_PATH [--ref BRANCH]

# Examples:
python .claude/skills/github-code/scripts/read_file.py --repo acme/webapp --path src/main.py
python .claude/skills/github-code/scripts/read_file.py --repo acme/webapp --path package.json --ref develop

PR Review

get_pr_files.py - Get Files Changed in a PR

python .claude/skills/github-code/scripts/get_pr_files.py --repo OWNER/REPO --pr NUMBER [--show-patch]

# Examples:
python .claude/skills/github-code/scripts/get_pr_files.py --repo acme/webapp --pr 42
python .claude/skills/github-code/scripts/get_pr_files.py --repo acme/webapp --pr 42 --show-patch

get_review_context.py - Get Existing Review Context

python .claude/skills/github-code/scripts/get_review_context.py --repo OWNER/REPO --pr NUMBER [--bot-marker "Review"]

# Shows prior reviews, inline comments, and whether new commits exist since last review.
# Use before creating a review to avoid duplicating feedback.

create_review.py - Create a PR Review with Inline Comments

python .claude/skills/github-code/scripts/create_review.py --repo OWNER/REPO --pr NUMBER --body "Summary" --comments-file /tmp/comments.json
python .claude/skills/github-code/scripts/create_review.py --repo OWNER/REPO --pr NUMBER --body "LGTM" --event APPROVE

# --comments-file is a JSON array: [{"path": "src/app.py", "line": 42, "body": "Fix this"}]
# --event: COMMENT (default), APPROVE, REQUEST_CHANGES

Branch & File Management

create_branch.py - Create a New Branch

python .claude/skills/github-code/scripts/create_branch.py --repo OWNER/REPO --branch BRANCH_NAME
python .claude/skills/github-code/scripts/create_branch.py --repo OWNER/REPO --branch BRANCH_NAME --from-branch develop

create_or_update_file.py - Commit a File to a Branch

python .claude/skills/github-code/scripts/create_or_update_file.py --repo OWNER/REPO --path FILE_PATH --branch BRANCH --message "commit msg" --file /tmp/content.txt
echo "content" | python .claude/skills/github-code/scripts/create_or_update_file.py --repo OWNER/REPO --path FILE_PATH --branch BRANCH --message "commit msg"

# For updates, pass --sha with the current file SHA (get it from read_file_with_sha in github_client)

create_pull_request.py - Open a Pull Request

python .claude/skills/github-code/scripts/create_pull_request.py --repo OWNER/REPO --title "PR title" --head BRANCH_NAME
python .claude/skills/github-code/scripts/create_pull_request.py --repo OWNER/REPO --title "PR title" --head BRANCH_NAME --base main --body "Description"
python .claude/skills/github-code/scripts/create_pull_request.py --repo OWNER/REPO --title "PR title" --head BRANCH_NAME --body-file /tmp/pr_body.md

create_commit_status.py - Set Commit Status Check

python .claude/skills/github-code/scripts/create_commit_status.py --repo OWNER/REPO --sha COMMIT_SHA --state success --description "All checks passed"
python .claude/skills/github-code/scripts/create_commit_status.py --repo OWNER/REPO --sha COMMIT_SHA --state failure --description "Issues found" --context "ci/review"

# --state: error, failure, pending, success

Client Library Functions

The github_client.py module provides these functions for programmatic use:

Read Operations

Function Purpose
search_code(query, repo, per_page) Search code across repos
read_file(owner, repo, path, ref) Read a file's content
read_file_with_sha(owner, repo, path, ref) Read file content + SHA (needed for updates)
get_pr(owner, repo, pr_number) Get PR details
get_pr_files(owner, repo, pr_number) Get files changed in a PR
list_reviews(owner, repo, pr_number) List reviews on a PR
list_review_comments(owner, repo, pr_number) List inline review comments
list_pr_comments(owner, repo, pr_number) List general PR comments
compare_commits(owner, repo, base, head) Diff between commits

Write Operations

Function Purpose
create_review(owner, repo, pr_number, body, comments, event) Submit a PR review
add_pr_comment(owner, repo, pr_number, body) Add a general PR comment
create_branch(owner, repo, branch, from_branch) Create a new branch
create_or_update_file(owner, repo, path, content, message, branch, sha) Commit a file
create_pull_request(owner, repo, title, head, body, base) Open a PR
create_commit_status(owner, repo, sha, state, description, context) Set commit status

Formatting Helpers

Function Purpose
format_pr_summary(pr) Format PR details for display
format_file_changes(files) Format changed files list

Common Workflows

1. Review a Pull Request

# Check for prior reviews
python get_review_context.py --repo acme/webapp --pr 42

# Get the diff
python get_pr_files.py --repo acme/webapp --pr 42 --show-patch

# Read specific files for full context
python read_file.py --repo acme/webapp --path src/auth/handler.py --ref feature-branch

# Submit review with inline comments
python create_review.py --repo acme/webapp --pr 42 --body "Review summary" --comments-file /tmp/comments.json

2. Create a Fix PR

# Create a branch
python create_branch.py --repo acme/webapp --branch fix/auth-bug

# Commit the fix
python create_or_update_file.py --repo acme/webapp --path src/auth.py --branch fix/auth-bug --message "Fix auth token validation" --file /tmp/auth.py

# Open a PR
python create_pull_request.py --repo acme/webapp --title "Fix auth token validation" --head fix/auth-bug --body "Fixes #123"

3. Find and Understand Code

# Search for how authentication is implemented
python search_code.py --query "authenticate" --repo acme/webapp

# Read the file for context
python read_file.py --repo acme/webapp --path src/auth/handler.py

GitHub Code Search Syntax

Qualifier Example Purpose
repo: repo:acme/webapp Limit to repo
path: path:src/ Filter by path
extension: extension:py Filter by file type
language: language:python Filter by language
filename: filename:config Filter by filename

Combine qualifiers: "def handle" language:python repo:acme/webapp

Install via CLI
npx skills add https://github.com/incidentfox/self-learning-ai-agent --skill github-code
Repository Details
star Stars 1
call_split Forks 2
navigation Branch main
article Path SKILL.md
More from Creator