| --- |
| name: github-repo-ops |
| description: > |
| This skill should be used for any direct read or write operation against a GitHub |
| repository β when the user asks to "commit this", "push this file", "create a branch", |
| "open a PR", "read the repo", "what's in this repo", "update the README", "delete this |
| file", "merge that PR", "create a repo", "add a collaborator", "check CI status", |
| "list branches", "tag a release", or names a repository and asks for a change to it. |
| Also triggers on "github-ops", "repo ops", "full repo access", and any request that |
| would modify files, branches, issues, or pull requests on GitHub. |
| metadata: |
| version: "0.1.0" |
| --- |
| |
| # GitHub Repo Ops |
|
|
| Perform read and write operations against GitHub through the `github-ops` MCP server, which is authenticated with a Personal Access Token and therefore has write access β unlike the read-only OAuth GitHub connector. |
|
|
| ## Before the first operation in a session |
|
|
| Confirm which server is answering. Call `get_me` on the `github-ops` server. If it fails with a 401, the `GITHUB_OPS_PAT` environment variable is missing or expired β stop and point the user at `SETUP-PAT.md` rather than silently falling back to the read-only connector. |
|
|
| If both the read-only GitHub connector and this plugin's server are active, **always prefer the `github-ops` tools for writes.** The read-only connector returns `403 Resource not accessible by integration` on any mutation. |
|
|
| ## Resolve the target before acting |
|
|
| Never guess an owner/repo pair. Resolve it in this order: |
|
|
| 1. An explicit `owner/repo` in the user's message. |
| 2. A repo named in the current session's earlier turns. |
| 3. `search_repositories` with `user:<login>` or `org:<org>` β note that a bare `MADHAT` style keyword search returns nothing useful; owner-qualified queries do. |
| 4. Ask, once, if still ambiguous. Do not fan out writes across candidate repos. |
|
|
| Confirm the default branch (`default_branch` from the repo object) before any commit. Do not assume `main` β several repos use `master`. |
|
|
| ## Write operations: the safe sequence |
|
|
| Writes are irreversible from this session's perspective (there is no branch-delete or force-push tool). Follow this order every time: |
|
|
| 1. **Read before write.** `get_file_contents` on the target path. A blind `create_or_update_file` on an existing path without its current SHA fails; with a stale SHA it clobbers. |
| 2. **Branch, never commit to default.** `create_branch` from the default branch. Name it `<type>/<short-slug>` β `feat/`, `fix/`, `chore/`, `docs/`, `refactor/`. |
| 3. **Commit.** Use `push_files` for multi-file changes in one commit β it is atomic and produces a clean history. Use `create_or_update_file` only for genuine single-file edits. |
| 4. **Open a PR** with `create_pull_request`. Search the repo for `.github/pull_request_template.md` or `.github/PULL_REQUEST_TEMPLATE/` first and fill that structure if present. |
| 5. **Report the URL.** Always hand back the PR or commit URL. The user cannot see the API response. |
|
|
| Never `merge_pull_request` without explicit instruction in the current turn. "Open a PR" is not permission to merge it. |
|
|
| ## Commit message format |
|
|
| ``` |
| <type>(<scope>): <imperative summary under 72 chars> |
| |
| <why the change was needed β not what the diff shows> |
| |
| Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
| ``` |
|
|
| Types: `feat`, `fix`, `chore`, `docs`, `refactor`, `test`, `perf`, `build`, `ci`. Scope is the package or contract name. |
|
|
| ## Reading efficiently |
|
|
| Repo reads burn context fast. Discipline: |
|
|
| - `get_file_contents` with `path: "/"` to map structure before pulling files. |
| - `search_code` with `repo:owner/name` to locate a symbol instead of reading directories. |
| - `list_commits` with `perPage: 10` β never the default page size on an active repo. |
| - Set `minimal_output: true` on searches unless a specific field is needed. |
| - For a broad sweep across many files, stage the repo into the session workspace with `git clone` over HTTPS and grep locally. One clone beats fifty API reads. |
|
|
| ## Workflow files are a separate permission |
|
|
| Any commit touching `.github/workflows/*` requires the `workflow` scope on a classic PAT (or Workflows: write on a fine-grained PAT). `repo`/Contents alone returns 403 with a message about workflow permissions. If that error appears, say so plainly β it is a token scope problem, not a code problem. |
|
|
| ## Repository creation and settings |
|
|
| `create_repository` defaults matter. Set `private: true` unless the user says public. Initialize with a README only when there is no local content to push. For a first push into an empty repo, `push_files` against the auto-created default branch works; `create_branch` does not, because there is no ref to branch from yet. |
|
|
| Collaborator and settings changes (`Administration` permission) are not in this token's default scope. If `list_repository_collaborators` returns `403 Resource not accessible by integration`, the PAT lacks admin read β report it rather than retrying. |
|
|
| ## Project conventions |
|
|
| For MAD Gambit repositories, load the `mad-gambit-context` skill before writing anything user-facing. Canonical values that must never be altered in committed content: platform fee 1.88%, community profit share 28.8%, creator revenue share 40%, seed raise $1β2M at $12M pre-money. The platform is "MAD Gambit"; the card game is "MADHAT's Gambit". Never write "MADHATs Gambit" as a platform name. |
|
|
| Solidity work: pair with the `solidity-foundry` skill. Never commit contract changes without `forge build` and `forge test` passing locally in the session workspace first β CI catching it after the PR is open wastes a round trip. |
|
|
| ## Verification step |
|
|
| After any write, verify rather than assume: |
|
|
| - Commit: `get_commit` on the returned SHA, confirm the file list matches intent. |
| - PR: `pull_request_read` to confirm it targets the right base branch. |
| - CI: `list_workflow_runs` or the Actions toolset to confirm the run started. |
|
|
| Report what was verified, not what was attempted. |
|
|