Skip to content

Commit 2ee86e4

Browse files
authored
docs: add REST API and branch protection guidance (#494)
1 parent fe76231 commit 2ee86e4

File tree

1 file changed

+28
-4
lines changed

1 file changed

+28
-4
lines changed

CLAUDE.md

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,14 @@ return { data: [], ...(condition && { metrics: { ... } }) };
125125
### Branch protection — `main` is fully protected
126126

127127
DO NOT run `git push origin main` directly. Branch protection requires all changes to
128-
arrive via a PR with passing CI checks. Always push to a feature branch and open a PR:
128+
arrive via a PR with passing CI checks. Always push to a feature branch and open a PR.
129+
This applies to **all** changes — even in a solo/personal repo, branch protection rules
130+
reject direct pushes. Always create a feature branch before committing:
129131

130132
```bash
131-
git checkout -b chore/release-<version>
132-
git push -u origin chore/release-<version>
133-
gh pr create --title "chore: release <version>" ...
133+
git checkout -b <type>/<slug>-<issue-number>
134+
git push -u origin <type>/<slug>-<issue-number>
135+
gh pr create --title "<type>(<scope>): description" ...
134136
```
135137

136138
### Version bumping — avoid `pnpm version` / `npm version` in nvm environments
@@ -179,6 +181,28 @@ a stale global link exists. Remove it with `pnpm remove --global <package-name>`
179181
- **Pre-existing infrastructure noise**: `Release to npm` OIDC failures when publishing
180182
was already completed manually.
181183

184+
### GitHub API — prefer REST over GraphQL
185+
186+
Prefer `gh api` (REST) over `gh pr create`, `gh pr merge`, and other high-level `gh`
187+
subcommands for PR and issue operations. The GraphQL API used by `gh pr` has stricter
188+
rate limits; REST endpoints have separate, more generous limits.
189+
190+
```bash
191+
# Create PR via REST (instead of gh pr create)
192+
gh api repos/:owner/:repo/pulls \
193+
-f title="feat: description" -f body="..." -f head="branch" -f base="main"
194+
195+
# Merge PR via REST (instead of gh pr merge)
196+
gh api -X PUT repos/:owner/:repo/pulls/<number>/merge -f merge_method="squash"
197+
198+
# Update PR branch (rebase onto base)
199+
gh api -X PUT repos/:owner/:repo/pulls/<number>/update-branch
200+
201+
# Check CI via REST
202+
gh api "repos/:owner/:repo/commits/<sha>/check-runs" \
203+
--jq '.check_runs[] | "\(.status)/\(.conclusion) \(.name)"'
204+
```
205+
182206
### Session start — prior incomplete tasks
183207

184208
**DO** recreate prior-session incomplete tasks with `TaskCreate` at the start of each new

0 commit comments

Comments
 (0)