You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ref(github-code): Add edit workflow, commit conventions, and on-behalf-of attribution
Extend the github-code skill from a pure GitHub CLI reference into a
compact repo-edit and PR workflow skill. Key additions:
- Investigate before editing, check branch/worktree state
- Read repo-local instructions (AGENTS.md) before edits
- Commit conventions (type(scope): Subject) with on-behalf-of
Co-authored-by trailers inline — not buried in reference files
- PR conventions: draft by default, reviewer-facing prose, session
link footer, Action taken on behalf of footer
- api-surface.md: add branch, status, log, diff, commit commands;
default PR creation to --draft
Co-authored-by: David Cramer <david@sentry.io>
- Resolve the target repo: explicit request wins, then `github.repo` config. Run `jr-rpc config get github.repo` standalone — never chain with `cd`, pipes, `gh`, or `git`.
21
+
- Keep `--repo owner/repo` explicit on all `gh` commands; use `git -C PATH` for local repos.
22
+
- Do not treat this skill's files or `/skills/...` as target repository source.
23
+
- Read repo-local instructions (`AGENTS.md`, `.github/AGENTS.md`, nested equivalents) before editing. Repo instructions override this skill's defaults.
24
+
- Do not overwrite or revert unrelated user changes.
25
+
- Stop on: missing repo access, ambiguous target, destructive op without confirmation, or unresolved auth failure.
17
26
18
27
## Workflow
19
28
20
-
### 1. Resolve operation and target
29
+
### 1. Resolve target and state
21
30
22
-
- Determine whether the task is `clone`, `source-code investigation`, a pull request inspection (`view`, `list`, `diff`, `checks`), or a pull request mutation (`create`, `update`, `close`, `merge`).
23
-
- Resolve repository from the requested action: explicit target wins; otherwise use `<configuration>``github.repo`. If absent, run standalone `jr-rpc config get github.repo`.
24
-
- Preserve non-target GitHub references when they materially support the work.
25
-
- Run `jr-rpc config get github.repo` as its own bash command. Do not combine it with `cd`, `&&`, pipes, or any `gh` or `git` command.
26
-
- After resolving a configured repo, pass it explicitly to the next `gh` command with `--repo owner/repo`; do not rely on implicit GitHub CLI repository discovery.
27
-
- Resolve the pull request number for operations targeting an existing PR.
28
-
- Keep `--repo owner/repo` explicit on `gh` commands so the command itself targets the intended repository, not a stale default.
31
+
Identify `owner/repo`, local checkout path, default branch, and current branch.
- repo-local instructions that override this skill
36
39
37
-
---
40
+
Prefer existing local checkouts over cloning. Default to shallow clones.
38
41
39
-
### Clone path
42
+
### 2. Investigate before editing
40
43
41
-
- Default to a shallow clone; deepen incrementally only when the task needs history.
42
-
- Use exact command forms from [references/api-surface.md](references/api-surface.md).
43
-
- After cloning, check for `AGENTS.md` in the repo root (and `.github/AGENTS.md`) before making edits. Treat discovered instructions as hard constraints.
44
-
- Report the local directory and whether the clone is shallow or full.
44
+
Before changing code, establish:
45
45
46
-
---
46
+
- where the behavior lives
47
+
- what the current vs. requested behavior is
48
+
- root cause or gap the change addresses
49
+
- what smallest check can prove the result
47
50
48
-
### Source-code investigation path
51
+
Prefer narrow evidence: file reads, grep, tests, existing issues/PRs, command output. If the task is investigation-only, answer from evidence without editing.
49
52
50
-
- Use for questions like "where is this implemented?", "how does this workflow work in code?", "is there already logic for X?", or "verify this from the repo."
51
-
- If the current workspace already contains the target repository, inspect local files directly before cloning.
52
-
- Do not treat this skill's `SKILL.md`, bundled references, or `/vercel/sandbox/skills/...` as target repository source code. If no checkout of the target repo is present, inspect the configured GitHub repository by cloning it shallowly or reading files through `gh` before answering.
53
-
- Prefer the narrowest deterministic evidence: local file search, exact file reads, targeted clone inspection, existing issues/PRs, tests.
54
-
- Cite repository evidence in the reply: file paths, symbols, issue/PR numbers, or commit references when known.
55
-
- If evidence is incomplete, say what is unknown instead of guessing.
53
+
### 3. Edit safely
56
54
57
-
---
55
+
- Smallest coherent change that satisfies the request.
56
+
- Follow repo-local style, patterns, and API boundaries.
57
+
- No drive-by refactors or speculative cleanup.
58
+
- After meaningful edits, run the smallest relevant repo-real check.
59
+
- On check failure, inspect root cause before patching again.
60
+
61
+
### 4. Commit
62
+
63
+
Default format when the repo does not specify otherwise:
64
+
65
+
```
66
+
<type>(<scope>): <Subject>
67
+
```
68
+
69
+
Types: `feat`, `fix`, `ref`, `docs`, `test`, `build`, `ci`, `chore`. Imperative present tense, no trailing period, no agent/tool branding.
70
+
71
+
Body only when it helps reviewers understand _why_.
72
+
73
+
#### On-behalf-of commits
74
+
75
+
If the commit is authored by a bot and a human requested the work, add a trailer:
58
76
59
-
### Pull request inspection path
77
+
```
78
+
Co-authored-by: Full Name <email>
79
+
```
60
80
61
-
- Use read-only `gh pr` commands from [references/api-surface.md](references/api-surface.md); skip branch resolution and push logic.
62
-
- When inspecting PR comments or feedback, query both conversation comments (`--json comments`) and review comments (`gh api .../pulls/{number}/comments` and `.../reviews`). Bot review feedback lives in the review comments API, not conversation comments.
63
-
- Return canonical PR URL, PR number when available, target repository, and the fields the user asked to inspect.
64
-
- If the PR cannot be resolved, report the exact not-found or auth failure and stop.
81
+
Resolve name and email from evidence — requester context, Slack profile (`slackUserLookup`), GitHub profile, or repo commit history. If email cannot be confirmed, use `Full Name <noreply>` and note the gap in the PR body.
65
82
83
+
### 5. Create or update PR
84
+
85
+
Before creating:
86
+
87
+
1. Changes committed on a non-default branch.
88
+
2. Push the branch explicitly: `git push -u origin BRANCH`.
- Draft PRs unless the user or repo says otherwise.
94
+
- Reuse an existing PR for the branch; only open a new one when explicitly asked or the work is materially distinct.
95
+
- After new commits, re-evaluate title and body against the current diff.
96
+
97
+
**Title:**`<type>(<scope>): <Subject>` — same rules as commits, no agent branding.
98
+
99
+
**Body:**
100
+
101
+
- Reviewer-facing prose, not diff narration.
102
+
- What changed and why; what was verified; what remains unverified.
103
+
- Issue references when relevant.
104
+
- No checkbox boilerplate, no PII or customer data in public repos.
105
+
106
+
**Footers** (in order):
107
+
108
+
1. Issue references (`Fixes #N`, `Refs SENTRY-N`), if any.
109
+
2.`Action taken on behalf of Full Name.` — when on-behalf-of.
110
+
3. Session link — when `gen_ai.conversation.id` is available:
111
+
112
+
```
66
113
---
114
+
[View Session in Sentry](https://sentry.sentry.io/traces/?project=4510944073809921&query=gen_ai.conversation.id%3A%22<url-encoded conversation id>%22)
115
+
```
116
+
117
+
### 6. Report result
67
118
68
-
### Pull request mutation path
119
+
Return: repo, branch, PR URL/number (when applicable), what was verified, what was not.
69
120
70
-
#### 3. Resolve mutation inputs
121
+
On failure, report the exact command and error. Do not claim success from partial state.
71
122
72
-
- For PR creation credential/order questions, explicitly answer that repository context comes first, then `git push` pushes the branch with GitHub remote write access, then `gh pr create` runs against the pushed branch with pull-request permissions.
73
-
- For PR creation, resolve the base branch (explicit user request wins; otherwise repository default).
74
-
- Resolve the head branch from the current checkout or user request.
75
-
- If the head branch may not exist on the remote yet, push it explicitly before PR creation.
123
+
## Operation-specific notes
76
124
77
-
#### 4. Execute
125
+
**Clone** — shallow by default; deepen only when history is needed. Read repo instructions after cloning, before editing.
78
126
79
-
- Run `git push` first so `gh pr create` does not trigger hidden push/fork behavior; then `gh pr create --repo owner/repo --head BRANCH ...`.
80
-
- If `git push` returns 401/403 or another auth/permission error, verify the command is targeting the right repository and retry once. If it still fails, report the exact command failure and the GitHub App installation/permission remediation.
81
-
- Treat `gh pr merge` as a contents mutation and keep repository context explicit.
127
+
**Source investigation** — use local files first, otherwise clone shallowly or use `gh`. Cite evidence: file paths, symbols, PRs, issues, command output.
82
128
83
-
#### 5. Report result
129
+
**PR inspection** — read-only `gh pr` and `gh api` commands. Query both conversation comments (`--json comments`) and review comments (`gh api .../pulls/{n}/comments` and `.../reviews`).
84
130
85
-
- Return canonical PR URL, PR number when available, target repository, and applied changes.
86
-
- If PR creation fails after explicit push + explicit repo scoping, report the exact auth or validation failure and stop.
131
+
**PR mutation** — push before create. Retry once on auth failure after verifying repo targeting. Treat merge, close-with-delete, and force-push as confirmation-required. No admin mutations.
87
132
88
133
## Guardrails
89
134
90
-
- Require explicit confirmation only for destructive merges or force operations.
91
-
- Answer source-code questions from repository evidence, not product framing or generic memory.
92
-
- Default to shallow clones; do not use a full clone unless the task requires repository history or the user asks for it.
93
-
- If repository or installation access is missing, stop and return a concrete remediation message.
94
-
- GitHub App auth is host-managed; do not ask the user to reconnect a GitHub account.
95
-
- Do not execute repository admin mutations.
135
+
- Default shallow clones; deepen only when needed.
136
+
- Confirm before destructive merges or force operations.
137
+
- Answer source questions from repo evidence, not product framing or memory.
138
+
- GitHub App auth is host-managed; do not ask users to reconnect accounts.
139
+
- Stop and return concrete remediation on missing access or permissions.
0 commit comments