Skip to content

Commit 9ad4410

Browse files
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>
1 parent 5ed5a05 commit 9ad4410

2 files changed

Lines changed: 109 additions & 59 deletions

File tree

packages/junior-github/skills/github-code/SKILL.md

Lines changed: 102 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -6,90 +6,134 @@ allowed-tools: bash
66

77
# GitHub Code Operations
88

9-
Repository checkout, source-code investigation, and pull request operations via `gh` CLI.
9+
Use `gh` and `git` for repository checkout, source investigation, code changes, commits, and pull requests.
1010

11-
## Reference loading
11+
## References
1212

13-
| Operation | Load |
14-
| ------------- | -------------------------------------------------------------------------------------- |
15-
| Any operation | [references/api-surface.md](references/api-surface.md) |
16-
| On failure | [references/troubleshooting-workarounds.md](references/troubleshooting-workarounds.md) |
13+
| Need | Load |
14+
| ---- | ---- |
15+
| Command syntax, permissions, config | [references/api-surface.md](references/api-surface.md) |
16+
| Failed commands, auth errors | [references/troubleshooting-workarounds.md](references/troubleshooting-workarounds.md) |
17+
18+
## Core rules
19+
20+
- 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.
1726

1827
## Workflow
1928

20-
### 1. Resolve operation and target
29+
### 1. Resolve target and state
2130

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.
2932

30-
### 2. Execute by operation type
33+
For edit operations, also check:
3134

32-
**Clone** → shallow clone path below.
33-
**Source-code investigation** → source-code path below.
34-
**Pull request inspection** → inspection path below.
35-
**Pull request mutation** → mutation path below.
35+
- current branch and uncommitted changes
36+
- package manager, build tool, monorepo structure
37+
- relevant test/lint/typecheck commands
38+
- repo-local instructions that override this skill
3639

37-
---
40+
Prefer existing local checkouts over cloning. Default to shallow clones.
3841

39-
### Clone path
42+
### 2. Investigate before editing
4043

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:
4545

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
4750

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.
4952

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
5654

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:
5876

59-
### Pull request inspection path
77+
```
78+
Co-authored-by: Full Name <email>
79+
```
6080

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.
6582

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`.
89+
3. Create with explicit targeting: `gh pr create --repo owner/repo --head BRANCH ...`.
90+
91+
Defaults:
92+
93+
- 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+
```
66113
---
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
67118

68-
### Pull request mutation path
119+
Return: repo, branch, PR URL/number (when applicable), what was verified, what was not.
69120

70-
#### 3. Resolve mutation inputs
121+
On failure, report the exact command and error. Do not claim success from partial state.
71122

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
76124

77-
#### 4. Execute
125+
**Clone** — shallow by default; deepen only when history is needed. Read repo instructions after cloning, before editing.
78126

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.
82128

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`).
84130

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.
87132

88133
## Guardrails
89134

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.

packages/junior-github/skills/github-code/references/api-surface.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ Treat explicit repo flags as command-targeting safety rails, not as a credential
2626
| Clone repository (default shallow) | `gh repo clone owner/repo [DIRECTORY] -- --depth=1` |
2727
| Deepen shallow clone | `git -C DIRECTORY fetch --depth=N origin` |
2828
| Convert shallow clone to full | `git -C DIRECTORY fetch --unshallow` |
29+
| Check branch | `git -C DIRECTORY branch --show-current` |
30+
| Check worktree state | `git -C DIRECTORY status --short --branch` |
31+
| View commit log against base | `git -C DIRECTORY log BASE..HEAD --oneline` |
32+
| Diff against base | `git -C DIRECTORY diff BASE...HEAD` |
33+
| Create branch | `git -C DIRECTORY checkout -b BRANCH` |
34+
| Stage and commit | `git -C DIRECTORY add -A && git -C DIRECTORY commit -m "message"` |
2935
| Push branch before PR creation | `git -C DIRECTORY push -u origin BRANCH` |
30-
| Create pull request | `gh pr create --repo owner/repo --head BRANCH --base BASE --title "..." --body-file PATH` |
36+
| Create pull request (draft) | `gh pr create --draft --repo owner/repo --head BRANCH --base BASE --title "..." --body-file PATH` |
3137
| Update pull request | `gh pr edit NUMBER --repo owner/repo [--title "..."] [--body-file PATH]` |
3238
| Close pull request | `gh pr close NUMBER --repo owner/repo` |
3339
| Merge pull request | `gh pr merge NUMBER --repo owner/repo [--merge \| --squash \| --rebase]` |

0 commit comments

Comments
 (0)