/github-setup:gh-create-appfrom github-setup
Create (from scratch) an org- or enterprise-scoped GitHub App for workflow authentication — walk the UI-gated registration with starter PR-automation permissions, install it on the target repo(s), set App ID + private key as secrets, verify a minted installation token, and save a checked-in metadata doc. Idempotent: detects an already-configured App and offers to verify instead of re-creating.
Ships in github-setup. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
You are running the /gh-create-app skill. Your job is to provision a
new GitHub App for workflow authentication, scoped at the org or
enterprise level, and wire it up for the current repo:
gh secret set.This skill is the create-from-scratch path of
skills/lib/gh-app.md. The find/verify path (detecting and validating
an existing App) already lives in that library; this skill is what
the library's "no suitable candidates" branch points users at. When an
App already exists, this skill detects it and offers to verify
rather than re-create (see "Idempotency").
There is no such thing as a per-repo GitHub App. Apps are owned by
an organization or an enterprise and installed onto repos. The
--scope flag (or the prompt in its absence) chooses org vs.
enterprise ownership.
The skill does not commit the metadata doc it writes (global rule
§0: never commit without approval). Remote changes it does apply
directly — setting secrets via gh secret set — are reported, and
re-running converges (a secret that is already set is overwritten with
the same value, reported as such).
All optional; the skill prompts for anything it needs and cannot infer.
--scope=org|enterprise (no default): ownership scope of the App.
In its absence the skill prompts (org vs. enterprise) before
the registration walkthrough.--app-name=<slug>: the intended App name/slug. Used for the
idempotency check (does an App by this slug already exist and
resolve via skills/lib/gh-app.md?) and recorded in the metadata
doc. If omitted, the skill asks for it before registration.--owner=<org-or-enterprise-slug>: the org or enterprise login that
will own the App. Defaults to the current repo's owner
(gh repo view --json owner -q .owner.login) for --scope=org;
prompted for --scope=enterprise.--target-repo=<owner/repo>: the repo to install the App on and set
secrets on. Defaults to the current repo
(gh repo view --json nameWithOwner -q .nameWithOwner).--secret-scope=repository|organization (default repository):
where the App ID and private-key secrets are stored. organization
sets them as org secrets (shared across repos); repository sets
them on --target-repo only.--app-id-secret=<NAME> (default WORKFLOW_APP_ID): name of the
secret that holds the App ID.--app-key-secret=<NAME> (default WORKFLOW_APP_PRIVATE_KEY): name
of the secret that holds the private key.--metadata-path=<path> (default docs/github-app.md, repo-root
relative): where the checked-in metadata doc is written.--permissions=<starter|custom> (default starter): the permission
set requested at registration. starter is the PR-automation set
below; custom prompts the user for the scopes.If the user passed nothing, use the defaults above and prompt for the
non-defaulted required inputs (--scope, --app-name, and --owner
for enterprise scope).
The default --permissions=starter requests exactly:
| Permission | Access | Why |
|---|---|---|
| Pull requests | Read and write | open / approve / merge / label PRs |
| Contents | Read and write | push branches, create commits |
| Issues | Read and write | close the issues a merged PR's Closes #N lines link |
| Checks | Read-only | read a commit's check-run results before merging |
| Commit statuses | Read-only | read a commit's combined status before merging |
| Metadata | Read-only | mandatory; GitHub auto-selects it |
Issues: write is not optional decoration. Merging a PR whose body
carries a closing keyword has an issue-side side effect, and that
side effect runs under the merging token's authority — so an App
with contents: write + pull_requests: write and no issues scope
merges the PR successfully and silently leaves every linked issue
open. That is the exact half of the closing-keyword convention (PR
body only, the branch's own issue set only) that the automation exists
to deliver.
Checks: read and Commit statuses: read are what let the App see
whether CI passed. GET /repos/{owner}/{repo}/commits/{ref}/check-runs
needs the first and GET /repos/{owner}/{repo}/commits/{ref}/status
needs the second, and the statusCheckRollup GraphQL field the
PR-automation workflows gate on reads both. Those workflows read the
rollup and make neither REST call, so an App without the two scopes
fails in the GraphQL shape the first time a merge pass has an open PR
to evaluate: HTTP 200 carrying a FORBIDDEN body error —
Resource not accessible by integration — which exits gh api graphql non-zero. HTTP 403 is the REST shape, and it is what a caller
of either endpoint above gets instead. Both scopes are read-only on an
App that already holds write on Pull requests, Contents, and Issues,
so they widen nothing an operator has not already granted.
No webhook. This App mints installation tokens in CI; it does not receive event deliveries. Leave "Active" under Webhook unchecked during registration.
The corresponding required_permissions map (the shape
skills/lib/gh-app.md and consuming skills use) is:
{ pull_requests: write, contents: write, issues: write, checks: read,
statuses: read, metadata: read }
For --permissions=custom, ask the user which scopes and levels they
need, then carry that map through the walkthrough and the metadata doc
in place of the starter set.
The template payloads this skill renders ship with the plugin at
${CLAUDE_PLUGIN_ROOT}/payload/gh-create-app/. The placeholder/render
convention is documented in ${CLAUDE_PLUGIN_ROOT}/payload/README.md.
Confirm you are inside a git working tree and capture the root:
git rev-parse --show-toplevel
If it fails, abort with:
/gh-create-appmust be run from inside a git repository. The current directory is not a git working tree.
Confirm gh is authenticated:
gh auth status
If not authenticated, abort and tell the user to run gh auth login.
Setting org secrets requires admin:org; enterprise-scoped
App management requires enterprise-owner rights. Note these in the
abort message when the relevant scope is selected.
Resolve identifiers and inputs:
gh repo view --json nameWithOwner -q .nameWithOwner # default --target-repo
gh repo view --json owner -q .owner.login # default --owner (org scope)
gh repo view --json defaultBranchRef -q .defaultBranchRef.name
Resolve --scope (prompt if absent), --app-name (prompt if absent),
and --owner (default for org; prompt for enterprise). Echo the
resolved configuration back to the user before proceeding:
gh-create-app — planned configuration
Scope: <org|enterprise>
Owner: <owner>
App name: <app-name>
Target repo: <owner/repo>
Secret scope: <repository|organization>
App ID secret: <APP_ID_SECRET>
Private-key secret: <APP_KEY_SECRET>
Permissions: <starter|custom> → <required_permissions map>
Metadata doc: <metadata-path>
Before walking the UI, run the find/verify path of
skills/lib/gh-app.md (Steps 1–4) with
required_permissions = the resolved permission map and
target_repo = --target-repo. If an --app-name was supplied, use
the "User-supplied App name (skip discovery)" path from that library.
A suitable App is found and installed on the target repo — do not re-create. Report what was found and offer to verify instead:
GitHub App
<app_slug>(ID<app_id>) already exists, has sufficient permissions, and is installed on<owner/repo>. Re-creating would produce a duplicate App. Proceed to verify the secrets and refresh the metadata doc instead? (Steps 4–7.)
On confirmation, skip Steps 3 (registration) and go to Step 4 using
the existing App's app_id / app_slug. The skill still needs the
private key for the verify step if the secret is not already set —
ask the user to generate one in the App settings if so.
An App exists by the requested name but is missing permissions or
not installed on the repo — report the gap (the library's "missing
permissions" / "not configured for repo" message) and tell the user
to fix it in the App settings, then re-run. Do not create a
second App with the same intent. For a missing permission
specifically, relay both steps from skills/lib/gh-app.md →
"Granting a missing permission to an existing App": the UI-only
edit, and the approval each installing account must give before
the new scope goes live. An App that predates a change to the
starter set — one provisioned before checks: read and
statuses: read joined it, say — lands in exactly this branch.
No suitable App — proceed to Step 3 (registration).
This is the create branch's half of the idempotency contract; the
find/verify half is owned by skills/lib/gh-app.md.
GitHub gates App creation behind the web UI; there is no API to create an App from nothing (see "Out of scope"). The skill therefore guides the user and waits. Print the steps and halt for the user to complete them.
https://github.com/organizations/<owner>/settings/apps/newhttps://github.com/enterprises/<owner>/settings/apps/newTell the user to set:
<app-name> (must be globally unique; if taken,
pick a variant and tell the skill the final slug).https://github.com/<owner/repo>).Then Create GitHub App.
After creation, on the App's settings page:
.pem file. Halt and ask the user for:
.pem file.Do not ask the user to paste the private-key contents into the
conversation. Only the path is collected; the key material is piped
straight into gh secret set via stdin in Step 4 and never printed.
Direct the user to the App's Install App tab, install it on
<owner>, and under "Repository access" select Only select
repositories → <target-repo> (or "All repositories" if that is the
intent). Halt until the user confirms the install is done.
Then verify the installation programmatically via the user-token path
from skills/lib/gh-app.md Step 4:
gh api "/user/installations" --paginate --jq \
'.installations[] | select(.app_slug == "<app-slug>") | .id'
gh api "/user/installations/<installation_id>/repositories" \
--paginate --jq \
'.repositories[] | select(.full_name == "<owner/repo>") | .full_name'
If the repo is not listed, report the "installed on org but not configured for this repo" gap from the library and halt for the user to fix the App's repository access, then re-check.
Set both secrets with gh secret set. Pick the org-vs-repo target
from --secret-scope.
App ID (a value, safe to pass on the command line):
# repository scope (default)
gh secret set <APP_ID_SECRET> --repo <owner/repo> --body "<app-id>"
# organization scope
gh secret set <APP_ID_SECRET> --org <owner> --visibility selected \
--repos <repo> --body "<app-id>"
Private key (read from the .pem path via stdin — never expanded into
argv or the conversation):
# repository scope (default)
gh secret set <APP_KEY_SECRET> --repo <owner/repo> < "<pem-path>"
# organization scope
gh secret set <APP_KEY_SECRET> --org <owner> --visibility selected \
--repos <repo> < "<pem-path>"
The redirect target is quoted so paths with spaces work. gh secret set overwrites an existing secret of the same name, so re-running is
convergent. Report each secret as set (and, when it already existed,
overwritten).
Read the reference snippet from the payload:
${CLAUDE_PLUGIN_ROOT}/payload/gh-create-app/app-auth-snippet.yml
Strip its leading comment block, substitute __APP_NAME__,
__APP_ID_SECRET__, and __APP_PRIVATE_KEY_SECRET__, and show the
rendered snippet to the user. This skill does not write a workflow
file — consuming skills (e.g. /gh-repo-setup-pr-automation) own their
workflows. The snippet is the canonical pattern those workflows embed:
mint a short-lived installation token with
actions/create-github-app-token, expose it as GH_TOKEN (or pass
steps.app-token.outputs.token to a token input), and do the
privileged work as the App.
Never show the snippet with unresolved __...__ placeholders; if any
remain, abort per the ${CLAUDE_PLUGIN_ROOT}/payload/README.md
unresolved-placeholder rule.
Confirm the secrets actually mint a working installation token. The paths below are in preference order:
Preferred — local mint with the collected private key. If the
.pem path is still available this run, mint an installation token
locally and call a representative API as the App. Use the App JWT →
installation-token exchange:
# Mint a JWT (App auth), exchange for an installation token, call an API.
# gh supports App auth via `gh api` with a generated JWT; if the local
# tooling to sign a JWT is not available, fall back to the CI path below.
Because signing an App JWT locally requires a JWT tool that may not be
present, treat the local mint as best-effort. If it succeeds, report
the representative call's result (e.g. the repo full_name).
Fallback — CI verification. If a local mint is not feasible, tell
the user to run a one-off workflow (or the snippet from Step 5 in any
workflow) and confirm the Mint App installation token step succeeds
and the representative gh api call returns. Report the expected
success signal:
The
Mint App installation tokenstep prints a masked token and thegh apicall returns<owner/repo>. A failure here means the secrets are wrong or the App is not installed on the repo.
Do not block the skill on the CI run; surface it as the verification step the user performs.
Render the metadata doc from the payload and write it to
--metadata-path (default docs/github-app.md, repo-root relative).
Read ${CLAUDE_PLUGIN_ROOT}/payload/gh-create-app/app-metadata.md.
Strip its leading HTML comment block (the placeholder documentation).
Substitute every placeholder:
| Placeholder | Value |
|---|---|
__APP_NAME__ | resolved App slug |
__APP_ID__ | the App ID |
__APP_OWNER__ | <owner> |
__APP_SCOPE__ | organization or enterprise |
__APP_INSTALL_URL__ | the App settings URL from Step 3a (minus /new) |
__APP_PERMISSIONS__ | comma-separated granted permissions (see note) |
__APP_ID_SECRET__ | <APP_ID_SECRET> |
__APP_PRIVATE_KEY_SECRET__ | <APP_KEY_SECRET> |
__SECRET_SCOPE__ | repository or organization |
__CREATED_DATE__ | today's date (ISO YYYY-MM-DD) |
The __APP_PERMISSIONS__ value is an inline, comma-separated
string (e.g. Pull requests: write, Contents: write, Issues: write, Checks: read, Commit statuses: read, Metadata: read), not a
markdown list — the template renders it inside a sentence.
Converge like the other setup skills: if the target file is absent, write it; if present and semantically equal to the render, do nothing and report "metadata doc already converged"; if present and different, show the diff and halt before overwriting (the doc may carry hand-added notes the render would drop). Whole-file replace, never append.
Never write the doc with unresolved __...__ placeholders.
The doc is written uncommitted; the user reviews and commits.
gh-create-app — <app-name> (ID <app-id>), <scope> scope, owner <owner>
Created / configured on GitHub:
App: <app-name> (ID <app-id>) <created|reused existing>
Installed on: <owner/repo> <verified>
Secrets (<repository|organization>):
<APP_ID_SECRET> <set|overwritten>
<APP_KEY_SECRET> <set|overwritten>
Uncommitted in this repo (review and commit when ready):
<metadata-path> <written|unchanged>
Granted permissions: <list>
Next steps:
1. Review the metadata doc: git diff --stat <metadata-path>
2. Commit and push when ready (this skill does not commit).
3. Use the App in a workflow with the snippet from Step 5
(or run /gh-repo-setup-pr-automation, which wires it in).
4. Verify in CI: trigger a workflow using the snippet and confirm
the token mints and the representative API call succeeds.
5. Re-run /gh-create-app any time — it detects the existing App and
converges (verify + refresh metadata) instead of re-creating.
When the App was reused rather than created, append the check-state upgrade note to the report:
6. Checks: read and Commit statuses: read joined the starter set
after some Apps were registered. If this App predates that, add
both in the App's settings AND accept the change on every
installation — granting alone leaves it pending and the minted
token unchanged.
Both scopes are read-only, so an operator who reads that note is being asked for the two reads and nothing else.
Re-running this skill on an already-configured App must detect and converge, never duplicate:
skills/lib/gh-app.md. A suitable, installed App short-circuits
registration; the skill offers to verify and refresh the metadata
doc instead of creating a second App.gh secret set replaces a
secret of the same name, so re-running with the same key is a
convergent overwrite..pem path and pipe it into gh secret set via stdin. The
gh secret set <NAME> ... < "<pem-path>" form is required.skills/lib/gh-app.md
find/verify path first (Step 2); a suitable existing App
short-circuits registration.__...__ placeholders. Abort per the
${CLAUDE_PLUGIN_ROOT}/payload/README.md unresolved-placeholder rule.<repo-root>/<metadata-path>.
Templates are read from
${CLAUDE_PLUGIN_ROOT}/payload/gh-create-app/ (never written).
Scratch work, if any, goes under
<repo-root>/.claude/tmp/gh-create-app/, never /tmp/, never the
user's home directory, never a path outside the repo./gh-repo-setup-protection's / a
protection skill's concern; this skill only provisions the App
identity and secrets.What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub thevoskamps/claude-plugins-marketplace --plugin github-setup6 skills in this plugin
/gh-repo-scrub-historyRewrite a repo's entire git history to substitute one string with another across every commit via git-filter-repo --replace-text, then force-push. Purges leaked secrets/names/strings from history. Warns loudly (but does not refuse) on public repos. Prompts for the from/to strings when not passed, using any passed values as editable defaults./gh-repo-setup-pr-automationInstall PR-automation workflows (auto-merge, auto-rebase, scheduled rebase sweep, /rebase responder, plus unattended Dependabot rebase-and-merge) into the current repo, rendered from templates and backed by a GitHub App identity stored as repo or org secrets, committing + PR-ing its own rendered files on a single approval and skipping the secret set when both App-identity secrets already exist./gh-repo-setup-protectionIdempotently converge a repo's entire Security & Quality surface — GHAS toggles (incl. push-protection bypass lockdown, per-repo Code Security, malware alerts, grouped security updates), the merge-button / PR-hygiene settings (merge-commit-only, auto-merge, auto-delete head branch), a hardened templated Dependabot config (always covering GitHub Actions), an Advanced CodeQL workflow, a dependency-install-gate (npm/pip/pnpm/yarn drift guard), a dependency-pinned-gate (npm/pip/actions/docker/go exact-version guard), a no-back-merging-guard, and the protect-main ruleset — re-asserting on every run, and committing + PR-ing its own rendered files on a single approval./gh-repo-setup-publicPromote a PRIVATE repo to genuinely PUBLIC: run the converge setup skills, re-assert the public posture (CODEOWNERS, conversation-resolution, issues/PRs open to outside contributors, no unexpected collaborators), add public-facing docs/community files, gate on history scrubbing, propose a clean rename, then flip visibility private -> public. The mirror skill is never run./repo-public-mirror-setupBootstrap a filtered, read-only public mirror for the current private repo (paired public repo, deploy key, filter config, mailmap, workflow, read-only enforcement).