github-repo-ops
Skill0 starsChanged 42 days agoMITView on GitHub
Inspect and operate a GitHub repository safely with the gh CLI, and recover from auth, scope, and permission failures. Use when running `gh` commands, creating a PR or issue, checking CI or workflow status, managing branches, tags or releases, setting repository metadata or branch protection, or publishing a repo; when a gh call returns 401, 403, 404 or "Resource not accessible"; or before an operation that depends on token scopes. Ships scripts/gh-preflight.mjs, which reports auth, scopes, visibility, default branch, branch protection, and which operations the current token can perform.
In this repository19 other files it gives its agents.
- api-doc-recallSkill
- assistant-runtime-architectureSkill
- code-disciplineSkill
- english-requestSkill
- git-safetySkill
- long-task-continuitySkill
- opencode-config-authoringSkill
- opencode-tool-outputSkill
- powershell-windowsSkill
- provider-reconnectSkill
- reference-booksSkill
- release-checklistSkill
- research-synthesisSkill
- self-improvementSkill
- skill-authoringSkill
- subagent-delegationSkill
- task-closureSkill
- test-first-fixSkill
- troubleshooting-treeSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 15
Before an operation that depends on token scopes or repository settings.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
GitHub repo operations
The gh CLI fails in a small number of ways, and they all look like each other
in the terminal. Most are answered by asking the API what is true before acting
rather than by retrying.
When to use this
- Running
gh pr,gh issue,gh release,gh run,gh api, orgh repo. - Before an operation that depends on token scopes or repository settings.
- A gh call returned 401, 403, 404, or "Resource not accessible by integration".
- Publishing a repository, or setting its metadata, description, or topics.
Rules
- Read the status codes as distinct meanings. 401 is an expired or absent token. 403 with "Resource not accessible by integration" is a scope problem on the token. 404 on a repository you believe exists is usually missing scope as well, because GitHub hides private repos from tokens that lack access. 404 that persists after a correct token is a wrong name.
- A 404 is not proof of absence. GitHub returns 404 rather than 403 to
avoid confirming that a private repository exists. Before concluding a repo
is gone, confirm the token has
repoand not onlypublic_repo. repois broad,public_repois not. Thereposcope already covers issues, pull requests, releases, and workflow dispatch on repositories you can see. A separateissuesscope is never additionally required. Choosing the narrow read-only scope when the operation needs to write produces a 403 that looks like a repository permissions problem.- Check branch protection before force-pushing or relying on a review.
An unprotected default branch accepts direct pushes and force-pushes, so the
guarantee you think you have is not there.
GET .../branches/<name>/protectionanswering 404 with "Branch not protected" is the answer, not an error to ignore. - Prefer
--jsonand--jqover parsing human output.ghprints a TTY-shaped table without them and an error with them. Both are contract; the prose is not.gh repo viewwithout--jsonalso needs a git repository in the working directory and fails outside one. - Script against
gh apiwhen you need an exact field. It is the same authentication, one request, and a stable JSON body, rather than the repository of CLI output formats. - Never paste a token.
gh auth statusprints a masked token; the flag that reveals it,--show-token, has no place in a command that gets logged or echoed into a conversation.
Preflight
node scripts/gh-preflight.mjs [owner/name] [--remote <name>] [--json]Reads the repository from origin when no name is given, then reports the
account and its scopes, visibility, default branch, whether that branch is
protected, and a per-operation capability table.
Exit codes: 0 ready, 1 something is missing, 2 gh is unusable here.
node scripts/gh-preflight.mjs # from inside a clone
node scripts/gh-preflight.mjs owner/name --json # anywhere
node scripts/gh-preflight.mjs --remote upstream # fork layoutIn a fork, origin is your fork and upstream is the original. Checking the
wrong one reports a repository you are not about to write to, so name the remote
you will actually push to.
Widen scopes only when a specific operation needs it:
gh auth refresh -s workflow. Adding a scope in advance is not free — it
broadens what a leaked token can do.
Common failures
| Symptom | Meaning | Action |
HTTP 404 on a repo you own | token lacks repo | gh auth refresh -s repo |
Resource not accessible by integration | missing scope for that API | gh auth refresh -s <scope> |
gh: Not Found (HTTP 404) on a call | wrong owner/name casing | gh repo view owner/name |
failed to run git from gh repo view | run outside a clone | pass the repo name, or use --json |
| Push rejected, non-fast-forward | remote moved | fetch, then --force-with-lease |
| CI "pending" forever | workflow never started | check gh run list and Actions enabled |
Before publishing
A repository created with gh repo create --public is world-readable the
moment it exists, including its git history. Confirm before creating that
there is no secret in the history — a --public flag is not reversible by
adding a README later.
Checklist
- Ran the preflight, or read auth and scopes, before relying on them
- Treated 404 as possibly-missing scope, not as proof of absence
- Used
--json/--jqinstead of parsing human output - Checked branch protection before assuming a review gate exists
- Confirmed no secret in history before making a repo public
- No token in the command line, the log, or the output
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

