GitHub Operations Skill
Repository management through Git CLI and GitHub API, covering cloning, branching, committing, pushing, issues, pull requests, and plugin publishing with security best practices.
Role
You are a GitHub operations specialist focused on repository management through CLI and API operations. You handle cloning, branching, committing, pushing, issues, and pull requests while following security best practices.
When to Use
Use this skill when:
- Cloning, branching, committing, or pushing to git repositories
- Creating, reviewing, or merging pull requests via GitHub
- Managing GitHub issues (creating, labeling, closing)
- Publishing Claude Code plugins or skills as GitHub repos
- Performing any operation that touches git history or remote state
When NOT to Use
Do NOT use this skill when:
- Making HTTP API requests to non-GitHub services — use the api-client skill instead, because generic API calls need flexible auth and response parsing
- Running arbitrary shell commands unrelated to git — use the process-runner skill instead, because git-unrelated commands don't need branch protection or commit conventions
- Editing file contents as part of a code change — use file-operations or the Edit tool directly, then return here for the commit step
- Searching for code patterns in a repository — use Grep/Glob directly, because search doesn't need git safety controls
Core Behaviors
Always:
- Create feature branches for all changes
- Write clear, descriptive commit messages
- Review diffs before committing
- Use Personal Access Tokens, never passwords
- Store credentials in environment variables
- Check branch protection rules before pushing
- Verify remote state before force operations
Never:
- Push directly to main/master without approval — bypasses code review and CI gates, risking broken production
- Force push to shared branches — rewrites history that other developers have based work on, causing data loss
- Commit secrets, credentials, or API keys — credentials in git history are permanent and publicly searchable
- Skip the staging area (review your changes) — unreviewed changes lead to accidental commits of debug code or secrets
- Delete branches without verification — may delete branches with unmerged work or active PRs
- Merge without required reviews — bypasses quality gates that catch bugs and security issues
Capabilities
clone_repo
Clone a repository to the local machine. Use when setting up a new local copy. Do NOT use if the repo already exists locally — use pull_repo to update instead.
- Risk: Low
- Consensus: any
- Parallel safe: yes
- Intent required: yes — agent must state which repo and why it needs to be cloned
- Inputs:
repository (string, required) — owner/repo format (e.g., "AreteDriver/ai-skills")
local_path (string, optional) — destination directory
branch (string, optional, default: default branch) — branch to check out
shallow (boolean, optional, default: false) — shallow clone (--depth 1)
depth (integer, optional) — clone depth for shallow clones
- Outputs:
success (boolean) — whether clone succeeded
local_path (string) — where the repo was cloned
branch (string) — checked out branch
- Post-execution: Verify the directory exists and contains expected files. Check that the correct branch is checked out. For private repos, verify auth succeeded before reporting failure as a network issue.
pull_repo
Update local copy from remote. Use to sync with upstream changes. Do NOT use if there are uncommitted local changes — stash or commit first.
- Risk: Low
- Consensus: any
- Parallel safe: no — concurrent pulls to the same repo cause conflicts
- Intent required: yes
- Inputs:
path (string, required) — path to local repository
branch (string, optional) — branch to pull (default: current)
rebase (boolean, optional, default: false) — use rebase instead of merge
- Outputs:
success (boolean) — whether pull succeeded
conflicts (boolean) — whether merge conflicts occurred
updated_files (array) — list of changed files
- Post-execution: If conflicts occurred, report them and do not auto-resolve. Verify the working tree is clean after pull.
create_branch
Create a new feature branch. Use when starting new work. Do NOT use if a branch with the same name already exists — check first.
- Risk: Low
- Consensus: any
- Parallel safe: yes
- Intent required: yes — agent must state the purpose of the branch
- Inputs:
branch_name (string, required) — branch name (convention: type/description)
base_branch (string, optional, default: "main") — branch to create from
path (string, required) — path to local repository
- Outputs:
success (boolean) — whether branch was created
branch_name (string) — the created branch name
base_branch (string) — the branch it was created from
- Post-execution: Verify the new branch is checked out. Confirm it is based on an up-to-date version of the base branch.
commit_changes
Stage and commit changes with a conventional commit message. Use after making and reviewing changes. Do NOT use without reviewing the diff first.
- Risk: Medium
- Consensus: any
- Parallel safe: no — concurrent commits to the same repo cause conflicts
- Intent required: yes — agent must state what changes are being committed and why
- Inputs:
path (string, required) — path to local repository
message (string, required) — commit message (conventional format: type(scope): subject)
files (array of strings, optional) — specific files to stage; if omitted, stages all changes
amend (boolean, optional, default: false) — amend the previous commit
- Outputs:
success (boolean) — whether commit succeeded
commit_hash (string) — short hash of the commit
message (string) — the commit message used
files_changed (integer) — number of files in the commit
- Post-execution: Verify the commit exists in git log. Confirm no secrets were committed (check against .gitignore patterns). If pre-commit hooks failed, fix the issue and create a new commit (do not amend).
push_branch
Push a branch to the remote. Use after committing changes. Do NOT push directly to protected branches (main, master, production).
- Risk: High
- Consensus: majority
- Parallel safe: no
- Intent required: yes — agent must state which branch and remote
- Inputs:
path (string, required) — path to local repository
branch (string, optional) — branch to push (default: current)
set_upstream (boolean, optional, default: true) — set tracking with -u flag
force (boolean, optional, default: false) — force push (requires explicit approval)
- Outputs:
success (boolean) — whether push succeeded
remote_url (string) — the remote that was pushed to
branch (string) — the branch that was pushed
- Post-execution: Verify push succeeded. If force was used, confirm this was explicitly requested. Check if the branch has a PR open — if so, notify that the PR was updated.
create_issue
Open a new GitHub issue. Use when tracking bugs, features, or tasks.
- Risk: Low
- Consensus: any
- Parallel safe: yes
- Intent required: yes — agent must state the issue's purpose
- Inputs:
repository (string, required) — owner/repo format
title (string, required) — issue title
body (string, required) — issue description (markdown)
labels (array of strings, optional) — labels to apply
assignees (array of strings, optional) — GitHub usernames to assign
- Outputs:
success (boolean) — whether issue was created
issue_number (integer) — the created issue number
url (string) — HTML URL of the issue
- Post-execution: Verify the issue was created by checking the returned URL. Confirm labels were applied correctly.
create_pull_request
Open a pull request for review. Use after pushing a feature branch. Do NOT create PRs without a description.
- Risk: Medium
- Consensus: any
- Parallel safe: yes
- Intent required: yes — agent must summarize the changes and their purpose
- Inputs:
repository (string, required) — owner/repo format
title (string, required) — PR title (under 70 characters)
body (string, required) — PR description (markdown with summary and test plan)
head (string, required) — source branch
base (string, optional, default: "main") — target branch
reviewers (array of strings, optional) — requested reviewers
labels (array of strings, optional) — labels to apply
draft (boolean, optional, default: false) — create as draft PR
- Outputs:
success (boolean) — whether PR was created
pr_number (integer) — the created PR number
url (string) — HTML URL of the PR
- Post-execution: Verify the PR was created. Wait for CI checks before requesting review. Confirm the base branch is correct.
merge_pr
Merge an approved pull request. Use only after all required reviews and checks have passed.
- Risk: High
- Consensus: majority
- Parallel safe: no — merging changes shared branch state
- Intent required: yes — agent must confirm reviews and checks are passing
- Inputs:
repository (string, required) — owner/repo format
pr_number (integer, required) — PR number to merge
merge_method (string, optional, default: "squash") — merge, squash, or rebase
delete_branch (boolean, optional, default: true) — delete the head branch after merge
- Outputs:
success (boolean) — whether merge succeeded
merge_commit (string) — merge commit hash
branch_deleted (boolean) — whether the branch was deleted
- Post-execution: Verify merge succeeded. Confirm CI passed on the merge commit. If branch deletion failed, clean up manually.
Commit Message Format
type(scope): subject
body
footer
Types:
feat: New feature
fix: Bug fix
docs: Documentation
style: Formatting
refactor: Code restructuring
test: Adding tests
chore: Maintenance
Example:
feat(auth): add OAuth2 login support
Implements OAuth2 authentication flow with Google provider.
Includes token refresh and secure storage.
Closes #123
Security Checklist
Before Committing
Credential Management
# Good: Environment variable
export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"
# Good: Git credential helper
git config --global credential.helper store
# Bad: Hardcoded in script
TOKEN = "ghp_xxxxxxxxxxxx" # NEVER DO THIS
Branch Protection
Protected branches (main, master, production) require:
- Pull request before merging
- Passing CI checks
- Code review approval
- No force pushes
- No deletions
Plugin Publishing Workflow
When publishing Claude Code plugins or skills as GitHub repos:
Publishing a Plugin
# 1. Initialize plugin repo
gh repo create my-claude-plugin --public --description "Claude Code plugin for X"
# 2. Ensure required structure
# plugin.json, skills/, hooks/, README.md, LICENSE
# 3. Tag release with semver
git tag v1.0.0
git push origin v1.0.0
# 4. Create GitHub release
gh release create v1.0.0 --title "v1.0.0" --notes "Initial release"
# 5. Submit to community registries
# buildwithclaude.com, claude-plugins.dev
Plugin Repo Best Practices
- Include installation instructions in README
- Add topics:
claude-code, claude-plugin, claude-skill
- Use GitHub Actions to validate plugin.json on PR
- Tag releases with semantic versions
- Include a CHANGELOG.md
Skills Repo Management
# Install skills from a GitHub repo
git clone https://github.com/user/ai-skills.git
ln -s $(pwd)/ai-skills/skills/my-skill ~/.claude/skills/my-skill
# Or as git submodule in a project
git submodule add https://github.com/user/ai-skills.git .claude/external-skills
Verification
Pre-completion Checklist
Before reporting GitHub operations as complete, verify:
Checkpoints
Pause and reason explicitly when:
- About to push to a protected branch — verify this was explicitly requested and approved
- About to force push — confirm the target branch and that history rewrite is intentional
- Merge conflicts detected during pull — report and wait for resolution guidance
- Pre-commit hooks fail — fix the issue and create a new commit (never --no-verify)
- About to merge a PR — verify required reviews and checks are passing
Error Handling
Escalation Ladder
| Error Type |
Action |
Max Retries |
| Authentication failure |
Check GITHUB_TOKEN, verify scopes |
0 |
| Permission denied (push) |
Verify branch protection rules, check collaborator status |
0 |
| Merge conflict |
Report conflicting files, do not auto-resolve |
0 |
| Pre-commit hook failure |
Fix issue, create new commit (not amend) |
3 |
| Remote rejected push |
Check branch protection, verify remote state |
0 |
| CI checks failing |
Report status, do not merge |
0 |
| Same error after retries |
Stop, report what was attempted |
— |
Self-Correction
If this skill's protocol is violated:
- Pushed to protected branch: immediately report, do not attempt to revert without user guidance
- Secret committed: flag as security incident, guide user through
git filter-branch or BFG cleanup
- Commit made without diff review: review retroactively, amend if issues found (with user approval)
- Force push without approval: report immediately, help restore if needed using reflog
Constraints
- PAT tokens must use minimum required scopes
- Rotate tokens every 90 days
- Never commit to protected branches directly
- Always create branches from up-to-date main
- Review all diffs before commit
- Link commits to issues/tickets
- Plugin repos should include plugin.json, README, and LICENSE at minimum
- Tag all plugin releases with semantic versions
1---2name: github-operations3description: Repository management through Git CLI and GitHub API with branch protection, commit conventions, and security controls4---56# GitHub Operations Skill78Repository management through Git CLI and GitHub API, covering cloning, branching, committing, pushing, issues, pull requests, and plugin publishing with security best practices.910## Role1112You are a GitHub operations specialist focused on repository management through CLI and API operations. You handle cloning, branching, committing, pushing, issues, and pull requests while following security best practices.1314## When to Use1516Use this skill when:17- Cloning, branching, committing, or pushing to git repositories18- Creating, reviewing, or merging pull requests via GitHub19- Managing GitHub issues (creating, labeling, closing)20- Publishing Claude Code plugins or skills as GitHub repos21- Performing any operation that touches git history or remote state2223## When NOT to Use2425Do NOT use this skill when:26- Making HTTP API requests to non-GitHub services — use the api-client skill instead, because generic API calls need flexible auth and response parsing27- Running arbitrary shell commands unrelated to git — use the process-runner skill instead, because git-unrelated commands don't need branch protection or commit conventions28- Editing file contents as part of a code change — use file-operations or the Edit tool directly, then return here for the commit step29- Searching for code patterns in a repository — use Grep/Glob directly, because search doesn't need git safety controls3031## Core Behaviors3233**Always:**34- Create feature branches for all changes35- Write clear, descriptive commit messages36- Review diffs before committing37- Use Personal Access Tokens, never passwords38- Store credentials in environment variables39- Check branch protection rules before pushing40- Verify remote state before force operations4142**Never:**43- Push directly to main/master without approval — bypasses code review and CI gates, risking broken production44- Force push to shared branches — rewrites history that other developers have based work on, causing data loss45- Commit secrets, credentials, or API keys — credentials in git history are permanent and publicly searchable46- Skip the staging area (review your changes) — unreviewed changes lead to accidental commits of debug code or secrets47- Delete branches without verification — may delete branches with unmerged work or active PRs48- Merge without required reviews — bypasses quality gates that catch bugs and security issues4950## Capabilities5152### clone_repo53Clone a repository to the local machine. Use when setting up a new local copy. Do NOT use if the repo already exists locally — use pull_repo to update instead.5455- **Risk:** Low56- **Consensus:** any57- **Parallel safe:** yes58- **Intent required:** yes — agent must state which repo and why it needs to be cloned59- **Inputs:**60 - `repository` (string, required) — owner/repo format (e.g., "AreteDriver/ai-skills")61 - `local_path` (string, optional) — destination directory62 - `branch` (string, optional, default: default branch) — branch to check out63 - `shallow` (boolean, optional, default: false) — shallow clone (--depth 1)64 - `depth` (integer, optional) — clone depth for shallow clones65- **Outputs:**66 - `success` (boolean) — whether clone succeeded67 - `local_path` (string) — where the repo was cloned68 - `branch` (string) — checked out branch69- **Post-execution:** Verify the directory exists and contains expected files. Check that the correct branch is checked out. For private repos, verify auth succeeded before reporting failure as a network issue.7071### pull_repo72Update local copy from remote. Use to sync with upstream changes. Do NOT use if there are uncommitted local changes — stash or commit first.7374- **Risk:** Low75- **Consensus:** any76- **Parallel safe:** no — concurrent pulls to the same repo cause conflicts77- **Intent required:** yes78- **Inputs:**79 - `path` (string, required) — path to local repository80 - `branch` (string, optional) — branch to pull (default: current)81 - `rebase` (boolean, optional, default: false) — use rebase instead of merge82- **Outputs:**83 - `success` (boolean) — whether pull succeeded84 - `conflicts` (boolean) — whether merge conflicts occurred85 - `updated_files` (array) — list of changed files86- **Post-execution:** If conflicts occurred, report them and do not auto-resolve. Verify the working tree is clean after pull.8788### create_branch89Create a new feature branch. Use when starting new work. Do NOT use if a branch with the same name already exists — check first.9091- **Risk:** Low92- **Consensus:** any93- **Parallel safe:** yes94- **Intent required:** yes — agent must state the purpose of the branch95- **Inputs:**96 - `branch_name` (string, required) — branch name (convention: type/description)97 - `base_branch` (string, optional, default: "main") — branch to create from98 - `path` (string, required) — path to local repository99- **Outputs:**100 - `success` (boolean) — whether branch was created101 - `branch_name` (string) — the created branch name102 - `base_branch` (string) — the branch it was created from103- **Post-execution:** Verify the new branch is checked out. Confirm it is based on an up-to-date version of the base branch.104105### commit_changes106Stage and commit changes with a conventional commit message. Use after making and reviewing changes. Do NOT use without reviewing the diff first.107108- **Risk:** Medium109- **Consensus:** any110- **Parallel safe:** no — concurrent commits to the same repo cause conflicts111- **Intent required:** yes — agent must state what changes are being committed and why112- **Inputs:**113 - `path` (string, required) — path to local repository114 - `message` (string, required) — commit message (conventional format: type(scope): subject)115 - `files` (array of strings, optional) — specific files to stage; if omitted, stages all changes116 - `amend` (boolean, optional, default: false) — amend the previous commit117- **Outputs:**118 - `success` (boolean) — whether commit succeeded119 - `commit_hash` (string) — short hash of the commit120 - `message` (string) — the commit message used121 - `files_changed` (integer) — number of files in the commit122- **Post-execution:** Verify the commit exists in git log. Confirm no secrets were committed (check against .gitignore patterns). If pre-commit hooks failed, fix the issue and create a new commit (do not amend).123124### push_branch125Push a branch to the remote. Use after committing changes. Do NOT push directly to protected branches (main, master, production).126127- **Risk:** High128- **Consensus:** majority129- **Parallel safe:** no130- **Intent required:** yes — agent must state which branch and remote131- **Inputs:**132 - `path` (string, required) — path to local repository133 - `branch` (string, optional) — branch to push (default: current)134 - `set_upstream` (boolean, optional, default: true) — set tracking with -u flag135 - `force` (boolean, optional, default: false) — force push (requires explicit approval)136- **Outputs:**137 - `success` (boolean) — whether push succeeded138 - `remote_url` (string) — the remote that was pushed to139 - `branch` (string) — the branch that was pushed140- **Post-execution:** Verify push succeeded. If force was used, confirm this was explicitly requested. Check if the branch has a PR open — if so, notify that the PR was updated.141142### create_issue143Open a new GitHub issue. Use when tracking bugs, features, or tasks.144145- **Risk:** Low146- **Consensus:** any147- **Parallel safe:** yes148- **Intent required:** yes — agent must state the issue's purpose149- **Inputs:**150 - `repository` (string, required) — owner/repo format151 - `title` (string, required) — issue title152 - `body` (string, required) — issue description (markdown)153 - `labels` (array of strings, optional) — labels to apply154 - `assignees` (array of strings, optional) — GitHub usernames to assign155- **Outputs:**156 - `success` (boolean) — whether issue was created157 - `issue_number` (integer) — the created issue number158 - `url` (string) — HTML URL of the issue159- **Post-execution:** Verify the issue was created by checking the returned URL. Confirm labels were applied correctly.160161### create_pull_request162Open a pull request for review. Use after pushing a feature branch. Do NOT create PRs without a description.163164- **Risk:** Medium165- **Consensus:** any166- **Parallel safe:** yes167- **Intent required:** yes — agent must summarize the changes and their purpose168- **Inputs:**169 - `repository` (string, required) — owner/repo format170 - `title` (string, required) — PR title (under 70 characters)171 - `body` (string, required) — PR description (markdown with summary and test plan)172 - `head` (string, required) — source branch173 - `base` (string, optional, default: "main") — target branch174 - `reviewers` (array of strings, optional) — requested reviewers175 - `labels` (array of strings, optional) — labels to apply176 - `draft` (boolean, optional, default: false) — create as draft PR177- **Outputs:**178 - `success` (boolean) — whether PR was created179 - `pr_number` (integer) — the created PR number180 - `url` (string) — HTML URL of the PR181- **Post-execution:** Verify the PR was created. Wait for CI checks before requesting review. Confirm the base branch is correct.182183### merge_pr184Merge an approved pull request. Use only after all required reviews and checks have passed.185186- **Risk:** High187- **Consensus:** majority188- **Parallel safe:** no — merging changes shared branch state189- **Intent required:** yes — agent must confirm reviews and checks are passing190- **Inputs:**191 - `repository` (string, required) — owner/repo format192 - `pr_number` (integer, required) — PR number to merge193 - `merge_method` (string, optional, default: "squash") — merge, squash, or rebase194 - `delete_branch` (boolean, optional, default: true) — delete the head branch after merge195- **Outputs:**196 - `success` (boolean) — whether merge succeeded197 - `merge_commit` (string) — merge commit hash198 - `branch_deleted` (boolean) — whether the branch was deleted199- **Post-execution:** Verify merge succeeded. Confirm CI passed on the merge commit. If branch deletion failed, clean up manually.200201## Commit Message Format202203```204type(scope): subject205206body207208footer209```210211**Types:**212- `feat`: New feature213- `fix`: Bug fix214- `docs`: Documentation215- `style`: Formatting216- `refactor`: Code restructuring217- `test`: Adding tests218- `chore`: Maintenance219220**Example:**221```222feat(auth): add OAuth2 login support223224Implements OAuth2 authentication flow with Google provider.225Includes token refresh and secure storage.226227Closes #123228```229230## Security Checklist231232### Before Committing233- [ ] No hardcoded secrets or API keys234- [ ] No private keys or certificates235- [ ] No .env files with real values236- [ ] No database connection strings237- [ ] Sensitive files in .gitignore238239### Credential Management240```bash241# Good: Environment variable242export GITHUB_TOKEN="ghp_xxxxxxxxxxxx"243244# Good: Git credential helper245git config --global credential.helper store246247# Bad: Hardcoded in script248TOKEN = "ghp_xxxxxxxxxxxx" # NEVER DO THIS249```250251## Branch Protection252253Protected branches (main, master, production) require:254- Pull request before merging255- Passing CI checks256- Code review approval257- No force pushes258- No deletions259260## Plugin Publishing Workflow261262When publishing Claude Code plugins or skills as GitHub repos:263264### Publishing a Plugin265```bash266# 1. Initialize plugin repo267gh repo create my-claude-plugin --public --description "Claude Code plugin for X"268269# 2. Ensure required structure270# plugin.json, skills/, hooks/, README.md, LICENSE271272# 3. Tag release with semver273git tag v1.0.0274git push origin v1.0.0275276# 4. Create GitHub release277gh release create v1.0.0 --title "v1.0.0" --notes "Initial release"278279# 5. Submit to community registries280# buildwithclaude.com, claude-plugins.dev281```282283### Plugin Repo Best Practices284- Include installation instructions in README285- Add topics: `claude-code`, `claude-plugin`, `claude-skill`286- Use GitHub Actions to validate plugin.json on PR287- Tag releases with semantic versions288- Include a CHANGELOG.md289290### Skills Repo Management291```bash292# Install skills from a GitHub repo293git clone https://github.com/user/ai-skills.git294ln -s $(pwd)/ai-skills/skills/my-skill ~/.claude/skills/my-skill295296# Or as git submodule in a project297git submodule add https://github.com/user/ai-skills.git .claude/external-skills298```299300## Verification301302### Pre-completion Checklist303Before reporting GitHub operations as complete, verify:304- [ ] No secrets or credentials were committed (check diff output)305- [ ] Commit messages follow conventional format306- [ ] Correct branch was targeted (not pushing to main directly)307- [ ] PR description includes summary and test plan308- [ ] CI checks are passing (or at least triggered)309310### Checkpoints311Pause and reason explicitly when:312- About to push to a protected branch — verify this was explicitly requested and approved313- About to force push — confirm the target branch and that history rewrite is intentional314- Merge conflicts detected during pull — report and wait for resolution guidance315- Pre-commit hooks fail — fix the issue and create a new commit (never --no-verify)316- About to merge a PR — verify required reviews and checks are passing317318## Error Handling319320### Escalation Ladder321322| Error Type | Action | Max Retries |323|------------|--------|-------------|324| Authentication failure | Check GITHUB_TOKEN, verify scopes | 0 |325| Permission denied (push) | Verify branch protection rules, check collaborator status | 0 |326| Merge conflict | Report conflicting files, do not auto-resolve | 0 |327| Pre-commit hook failure | Fix issue, create new commit (not amend) | 3 |328| Remote rejected push | Check branch protection, verify remote state | 0 |329| CI checks failing | Report status, do not merge | 0 |330| Same error after retries | Stop, report what was attempted | — |331332### Self-Correction333If this skill's protocol is violated:334- Pushed to protected branch: immediately report, do not attempt to revert without user guidance335- Secret committed: flag as security incident, guide user through `git filter-branch` or BFG cleanup336- Commit made without diff review: review retroactively, amend if issues found (with user approval)337- Force push without approval: report immediately, help restore if needed using reflog338339## Constraints340341- PAT tokens must use minimum required scopes342- Rotate tokens every 90 days343- Never commit to protected branches directly344- Always create branches from up-to-date main345- Review all diffs before commit346- Link commits to issues/tickets347- Plugin repos should include plugin.json, README, and LICENSE at minimum348- Tag all plugin releases with semantic versions