Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Is that skill safe to install?
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
Are you the author of Github?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/nuphos-github)
---
name: github
description: "GitHub repos, issues, PRs and Actions. Use whenever the user names a repo or asks about code or PRs."
---
# github
## Choose the GitHub identity first
For a confirmed local runtime on the current participant's own device, prefer their
existing `gh` login when the session's credential policy permits it. Check
`gh auth status --hostname github.com` before running Nuphos credential setup.
If the user explicitly requests the Nuphos App identity, skip this local-login
path and use the selected installation's setup command instead.
- Run the check in the participant's actual host environment. An isolated session
`HOME` / `GH_CONFIG_DIR` may hide the host login; an empty session config does not
mean the device is logged out. Use `local_exec` on the explicitly selected,
confirmed participant-owned device when available. Do not infer ownership from
the runtime account, OS username, or a matching display name alone.
- When the host has a valid active login, report its GitHub login and keep subsequent
`gh`/Git operations on that same device and credential context. Do not mint an
App token, copy the host token into the session, unset isolation variables, or
run `gh auth login`, `switch`, `logout`, or global credential-helper setup.
- Honor the current session's allowed identities and repository scope. This skill
does not authorize an unselected identity. A repository permission error is not
permission to try another account. Do not automatically switch identities.
- If no usable local login exists, or local identity use is not permitted, explain
that result and use an already selected Nuphos App installation when allowed.
Managed/shared runtimes always use the selected App identity; never reuse their
runtime owner's `gh` login.
The setup and signed-commit instructions below apply to Nuphos-minted tokens: the team App and a member's Personal Credential.
For the existing local-login path, use that account for GitHub operations and the
participant's existing Git author/signing configuration. Check that signing is
available before committing; do not change global Git configuration or fall back
to an unsigned commit when the repository requires signatures. PR review and
merge requirements apply to both paths.
## Session isolation
Keep CLI credentials and settings inside the current session's `HOME` (`NUPHOS_SESSION_HOME`) and respect the supplied CLI config environment variables. Do not copy another session's or the runtime owner's credentials. Without `NUPHOS_SESSION_HOME`, CLI defaults may use shared runtime configuration; be aware of the affected scope.
Changing runtime-global settings is possible, but strongly discouraged unless the user understands the impact on other sessions and explicitly requests it. Explain the shared scope first; do not unset session isolation variables, write to the runtime owner's home, write to a shared OS credential store, or modify shared shell startup files as routine setup. This is configuration isolation, not an OS security boundary.
For Nuphos installation tokens, always use the setup script below. Do not run `gh auth login`, `gh auth switch`, or `gh auth logout`: those flows can change a shared system keychain even with `--insecure-storage`. The setup script writes the configured gh authentication file (session-scoped when supplied by the runtime) and preserves other hosts.
For the App path, Nuphos backend mints a short-lived installation access token (≤1 h) on demand. The local-login path leaves authentication with the device's existing gh configuration.
## Setup (Nuphos App identity)
The bound GitHub App installations are already listed for you under **GitHub App
installations:** in the credential section of the system prompt. Each line carries the
`installationId`, `accountLogin`, `accountType`, and a ready-to-run `setupCommand`. Pick the
line whose `accountLogin` matches the org/user the requested repo lives under (most teams
have exactly one) and run its `setupCommand` verbatim:
```bash
bash skills/github/scripts/setup-credentials.sh <teamId> <installationId>
```
Identity: when the turn's member connected a Personal Credential, `gh` acts as their own GitHub account. That member is the sender of a member's message, or the session owner for automated turns (triggers, agent threads, resource events). Otherwise it acts as the team's GitHub App (`nuphos[bot]`). Add `--team` to use the App identity on purpose, for example for bot-owned automation. The JSON response's `actor.kind` (`personal` or `team`) says which one you got.
Permissions: acting as a member and the member's own `personal` / `github` credential use the same token, issued by the Nuphos GitHub App on the member's behalf. It can do only what both the member and the App installation allow, so a member who owns an org still cannot do through Nuphos what the App was not granted there. The setup script prints each installation's permissions and its settings page. Read them before planning work beyond code, issues and pull requests (org Projects, for example, need `organization_projects`). For a 403 or `Resource not accessible by integration`, follow [Errors](#errors).
Without a team installation: when `list_credentials` lists a selected `personal` / `github` entry, the conversation owner chose their own GitHub account for this conversation. Load it with `bash skills/github/scripts/setup-credentials.sh <teamId> personal`; it reaches what that member can reach.
Several GitHub accounts: `list_credentials` shows each account with its `connectionId`. When more than one is connected and the request does not say which, ask the user; never pick one yourself. Pass the chosen id as `GITHUB_CONNECTION_ID=<id>` before `setup-credentials.sh <teamId> personal`. A 409 `personal_credential_account_required` lists the choices.
`gh` is pre-installed in the runtime; the script retains a fallback for outdated images.
After `setup-credentials.sh` runs, `gh` is logged in (auth lives in the session’s `$GH_CONFIG_DIR/hosts.yml`, with mode restricted to the current OS user and without using the shared system keychain, so every later `bash` tool call picks it up — no env-var dance). The token is good for ~1 hour; if any call returns 401, just re-run the setup script. For raw curl, get the current token with `gh auth token`.
If the credential section lists no GitHub App installations, tell the user a team admin needs to install the GitHub App first via the install URL (`GET /teams/$TEAM/github-installations/install-url`, admin-only) — you cannot install it for them.
If the user requested an org/repo that isn't covered by any listed installation, say so explicitly and offer to look at a different repo. **Don't try to bind a new installation yourself**; that's an admin-only flow.
### Fallback: discover installations yourself
Only if the credential section is missing or looks stale, query the backend directly. `$TEAM`
is exported in the runtime environment.
```bash
# Reuse the helper from the nuphos-api skill (loads it if needed):
ac() { curl -sS -H @<(printf 'Authorization: Bearer %s\n' "$NUPHOS_TOKEN") "${NUPHOS_BACKEND_URL:-https://api.nuphos.ai}$1" "${@:2}"; }
ac /teams/$TEAM/github-installations | python3 -m json.tool
# → { "installations": [
# { "id": "...", "installationId": 12345678,
# "accountLogin": "myorg", "accountType": "Organization",
# "targetType": "selected" | "all", "createdAt": "..." } ] }
```
## What you can actually do
The token's permissions are whatever the team admin granted when they installed the App. Common shapes:
- **Read-only on selected repos** (most common) — list/read code, search PRs/issues, read Actions runs.
- **Read + write contents** — push branches, open PRs.
- **Read + write issues / PRs** — comment, label, close, request review.
- **Actions: write** — dispatch workflows, cancel runs.
`setup-credentials.sh` prints what is actually granted (`App permissions on <account>: ...`). A permission that is not in that list is not available under any identity. See [Errors](#errors) for what to tell the user.
## Common operations (with `gh`)
`gh` is the easiest path; it auto-uses `GH_TOKEN`. Examples:
```bash
# --- Repos / code ---
gh repo view myorg/myrepo --json name,defaultBranchRef,description
gh api repos/myorg/myrepo/contents/path/to/file.ts --jq '.content' | base64 -d
gh search code 'TODO repo:myorg/myrepo'
# --- Pull requests ---
gh pr list --repo myorg/myrepo --state open --json number,title,author,headRefName
gh pr view 42 --repo myorg/myrepo --json title,body,files,reviews,comments
gh pr diff 42 --repo myorg/myrepo
gh pr comment 42 --repo myorg/myrepo --body "Looks good, deploying"
gh pr review 42 --repo myorg/myrepo --approve --body "LGTM"
# --- Issues ---
gh issue list --repo myorg/myrepo --label bug --json number,title,author
gh issue view 17 --repo myorg/myrepo --comments
gh issue create --repo myorg/myrepo --title "..." --body "..." --label bug
# --- Actions ---
gh run list --repo myorg/myrepo --limit 10 --json databaseId,status,conclusion,headBranch,event
gh run view <run-id> --repo myorg/myrepo --log-failed
gh workflow list --repo myorg/myrepo
gh workflow run deploy.yml --repo myorg/myrepo --ref main -f env=staging
# --- Releases / tags ---
gh release list --repo myorg/myrepo --limit 5
gh release view v1.2.3 --repo myorg/myrepo
```
The sandbox has `jq`. For a `gh` response, prefer the built-in
`gh ... --jq '...'` so filtering stays in one command; use standalone `jq` for
other JSON instead of adding a Python formatting call.
## Common operations (raw curl, when you need something `gh` doesn't expose)
`gh api` already covers anything the REST API can do, so prefer that over hand-rolled curl. If you really need raw curl (uncommon), pull the current token from `gh`:
```bash
gh_api() {
curl -sS \
-H @<(printf 'Authorization: Bearer %s\n' "$(gh auth token)") \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com$1" "${@:2}"
}
gh_api /repos/myorg/myrepo | python3 -m json.tool
gh_api /repos/myorg/myrepo/branches | python3 -m json.tool
gh_api -X POST /repos/myorg/myrepo/issues/42/comments \
-d '{"body":"deployed to staging"}' | python3 -m json.tool
```
## Pushing code / opening PRs with a Nuphos token
Use GitHub's `createCommitOnBranch` GraphQL mutation with the token from the setup script for new commits. GitHub supplies the author (the App, or the member's own account for a Personal Credential), uses its signing committer (`web-flow`), and signs the commit. A local `git commit` followed by `git push` does **not** gain a signature from the push credentials, even when its email links to the bot. Do not create commits with the REST Git Database API (`POST /repos/OWNER/REPO/git/commits`): with a Personal Credential those commits are unsigned. To bring a branch up to date with its base, use `POST /repos/OWNER/REPO/merges` (GitHub signs that merge commit) instead of building a merge commit yourself.
When a participant wants commits signed with their own key, or the change needs a local `git commit` / `git push` that must be Verified, use the `git-signing` skill instead.
1. Run the selected installation's setup command with `--for-commit` appended. It prints the current authenticated Nuphos participant's `Co-authored-by` trailer. Refresh this on every committing turn; never infer the participant from the runtime/provider account, installation owner, or durable conversation owner. If the participant identity is unavailable, stop before committing.
If the repository uses the Developer Certificate of Origin (a `DCO` file at its root, a contributing guide that asks for `Signed-off-by`, or a DCO check on its PRs), also run `bash skills/github/scripts/commit-signoff.sh OWNER/REPO` against the repository the commit goes to (the fork, for a fork PR). It prints `Signed-off-by: NAME <EMAIL>` for the author GitHub records for the current identity; a DCO check compares that line with the author exactly, and no read-only API reports the commit email, so do not build the line yourself. It briefly creates and deletes a `nuphos/signoff-probe-*` branch. Run it again whenever the setup identity changes.
2. Work from the target branch's current SHA. For a new PR, create a new branch at the base branch SHA using `gh api repos/OWNER/REPO/git/refs -f ref=refs/heads/BRANCH -f sha=BASE_SHA`.
3. Prepare a JSON payload file for the mutation below. Include the complete new contents of each changed file as base64 in `fileChanges.additions`; include removed paths in `fileChanges.deletions`. Omit unchanged files. Add the participant and runtime trailers to `message.body`, after a blank line, followed by the `Signed-off-by` line when the repository uses the DCO.
4. Submit with `gh api graphql --input /path/to/commit.json`. Use `expectedHeadOid` to prevent overwriting concurrent changes; on a mismatch, fetch and reconcile before retrying.
5. Verify the returned commit through `gh api repos/OWNER/REPO/commits/SHA`: require `.commit.verification.verified == true`, check the resolved author (it must match any `Signed-off-by` line), and inspect co-authors. If verification fails, stop and report it; never bypass branch protection.
6. Fetch the branch to align the local checkout before further edits, then open the PR ready for review.
Example payload structure (replace placeholders, omit empty additions/deletions, and drop the `Signed-off-by` line for repositories without the DCO):
```json
{
"query": "mutation($input: CreateCommitOnBranchInput!) { createCommitOnBranch(input: $input) { commit { oid url } } }",
"variables": {
"input": {
"branch": { "repositoryNameWithOwner": "OWNER/REPO", "branchName": "BRANCH" },
"expectedHeadOid": "CURRENT_BRANCH_SHA",
"message": {
"headline": "fix: describe the change",
"body": "Context.\n\nCo-authored-by: PARTICIPANT_NAME <PARTICIPANT_EMAIL>\nCo-authored-by: codex <codex@openai.com>\nSigned-off-by: AUTHOR_NAME <AUTHOR_EMAIL>"
},
"fileChanges": {
"additions": [{ "path": "path/to/file", "contents": "BASE64_COMPLETE_FILE" }]
}
}
}
}
```
This API does not expose file modes, symlinks, or submodules. If the change needs those, stop and choose a signing-capable workflow rather than silently converting them to regular files. For unsigned commits already published on a PR branch, appending a signed commit does not sign its ancestors; prepare a replacement branch from the base, or obtain explicit authorization for a signed history rewrite.
A few rules:
- Always work on a **new branch**, never push to `main` / `master` / `release/*`.
- **Open the PR ready for review — not a draft.** A PR you open is a request for a human to look at the change, so `gh pr create` with no `--draft` is the default. Reach for `--draft` in exactly two cases:
- The user asked for a draft ("open it as a draft", "don't ping the reviewers yet", "just park the branch").
- The branch does not yet do what was asked: something is stubbed or `TODO`, a check you ran is failing and you haven't fixed it, or you're stopping partway and intend to push more commits to that same branch before a human should read it.
- Uncertainty is **not** a reason to draft. "I'm not sure this is the right approach", "the repo has no tests so I couldn't verify", "the user may want it done differently" — open the PR ready for review and write the doubt into the PR body, where a reviewer can act on it. A draft with a finished branch inside just delays the review the user asked for.
- If you did open a draft and then finished the work in the same session, flip it with `gh pr ready <number> --repo myorg/myrepo` and say so.
- Let GitHub set the author and its signing committer. Do not hardcode a bot slug/email, supply custom author/committer fields, or substitute local unsigned commits. This works with self-hosted installations' own Apps without identity configuration.
- Add the participant trailer printed by setup and exactly one runtime trailer, separated from the body by a blank line. Select by the runtime executing this turn, not the model name or installed CLI binaries:
- Claude Code: `Co-authored-by: claude <noreply@anthropic.com>`
- Codex: `Co-authored-by: codex <codex@openai.com>`
- Avoid duplicate trailers and preserve legitimate existing co-authors when carrying work forward. A participant email links to a GitHub profile only if registered there; report an unlinked co-author without substituting a different email.
- A `Signed-off-by` line certifies the DCO for the commit's author, and a new commit gets only the author's line, copied verbatim from `commit-signoff.sh` (a DCO check compares it exactly, so a login in place of the author's name fails). When a member's Personal Credential makes the commit, the author is that member and the line is theirs: they asked for the commit under their own account, so add it without asking. Never add a line for a co-author, the runtime account or anyone else; when carrying other people's commits forward, keep their existing `Signed-off-by` lines and add the author's below them. Merge commits from `POST /repos/OWNER/REPO/merges` need no sign-off.
- If the repo has CODEOWNERS or required reviews, mention that the PR will need a human reviewer — `gh` will not bypass branch protection.
## Safety
- **Read-only by default.** `gh repo view`, `gh pr view`, `gh issue view`, `gh run list/view`, `gh search` are all safe.
- **Confirm before mutating.** Before `gh pr create`, `gh pr merge`, `gh issue close/edit`, `gh release create/delete`, `gh workflow run`, or any push, summarize the exact change (which repo, which branch, which file, which workflow + inputs) and ask the user.
- **Never force-push.** No `git push --force` / `--force-with-lease`, no rewriting published history, no `gh pr merge --rebase` on a PR with review history unless the user explicitly asked.
- **Never merge to a default branch on the user's behalf** unless they explicitly said "merge it" naming the PR — getting that wrong is hard to undo.
- **Don't leak the installation token.** `gh auth token` will print the current value; never `echo` it, never paste it into a PR body, comment, or commit, never embed it in a workflow file or repo secret. If the user asks "what's the token", say it's a short-lived installation token held inside `gh`'s auth store in the sandbox and will expire within the hour.
- **Workflows can be destructive.** `gh workflow run deploy.yml -f env=production` ships code to prod. Treat dispatching any workflow named `deploy*`, `release*`, `publish*` like a deploy: confirm the inputs (especially `env`/`environment`) before sending.
- **Branch protection / required checks.** If a PR can't be merged because checks are red or reviews are missing, surface that to the user with the exact failing check names — don't override.
## Errors
- `404 github_installation_not_found` from Nuphos backend — the installation was uninstalled or transferred. Re-list installations and tell the user.
- `401 Bad credentials` from api.github.com (or `gh: HTTP 401`) — token expired (1 h max). Re-run `setup-credentials.sh`.
- `403 Resource not accessible by integration` (GraphQL: `FORBIDDEN` with the same message) — the App installation lacks a permission. The member's own access is not the problem, and GitHub does not say which permission. Don't retry. Switching to `personal` or `--team` will not help, and neither will another GitHub credential, because all of them go through the same App. Do this instead, in the same turn:
1. Name the permission. On REST, `gh api -i <path>` returns an `X-Accepted-GitHub-Permissions` header such as `organization_projects=read`. For GraphQL, call the REST endpoint of the same resource, or compare the call with the permissions the setup script printed.
2. Find who can grant it. `gh api /apps/<slug> --jq .permissions` lists what the App requests (`<slug>` is `app_slug` in `gh api /user/installations`). If the permission is there but not in the installation, an owner of that account approves it on the `Installation settings` page the setup script printed. If the App does not request it at all, nobody can grant it from that page: only whoever owns the App can add it, which is the Nuphos team on Nuphos Cloud and the instance operator when self-hosted.
3. Tell the user the permission, the account, which of the two cases it is, and the settings link. Then offer a way to finish now: give them the github.com page for the blocked step and the exact values to enter, so they can do that one step in the browser as themselves while you carry on with the rest.
- `404 Not Found` on a repo path — either the repo doesn't exist or it's outside the App's `selected` repository scope. Confirm with the user which repo they meant.
- `429` / secondary rate limits — slow down (don't retry tightly). Installation tokens get their own rate limit pool, but heavy fan-out can still hit it.
## Link work to the current conversation
After creating or adopting a PR or issue for the current task, use
`bind_session_resource` when that native tool is available. This registers a
verified resource link in the session sidebar. For GitHub pass `provider: github`,
the selected `installationId`, `repository` (`owner/repo`) and PR `number`.
For Linear pass `provider: linear`, the selected binding's `workspaceId` and
`issueId` (UUID or identifier). This is separate from Linear's Nuphos session
attachment; retain that attachment too. Do not bind unrelated search results.
Bound GitHub PR events durably wake this conversation with its existing permissions.
A receipt means the binding exists, not that an event was delivered or that checks
passed. Never promise a sandbox watcher will survive the turn. Use
`unlink_session_resource` when asked to stop following a resource; it does not
modify the external PR or issue. An event restores an archived session.