| 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]
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]
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]
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"]
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
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"
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"
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
python get_review_context.py --repo acme/webapp --pr 42
python get_pr_files.py --repo acme/webapp --pr 42 --show-patch
python read_file.py --repo acme/webapp --path src/auth/handler.py --ref feature-branch
python create_review.py --repo acme/webapp --pr 42 --body "Review summary" --comments-file /tmp/comments.json
2. Create a Fix PR
python create_branch.py --repo acme/webapp --branch fix/auth-bug
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
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
python search_code.py --query "authenticate" --repo acme/webapp
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