Skip to content

Commit 6e04952

Browse files
committed
ci: .github instructions for coderabbit
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
1 parent 95f0ad2 commit 6e04952

File tree

1 file changed

+178
-2
lines changed

1 file changed

+178
-2
lines changed

.coderabbit.yaml

Lines changed: 178 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ reviews:
114114
- Unit tests protect our future selves - be defensive and forward-looking.
115115
- Tests should be readable by SDK developers: clear names, brief docstrings, key inline comments.
116116
- When tests fail, we should immediately know what broke and why.
117-
117+
118118
# --- INTEGRATION TESTS REVIEW INSTRUCTIONS ---
119119
- path: "tests/integration/**/*"
120120
instructions: |
@@ -168,6 +168,182 @@ reviews:
168168
- When tests fail in CI, developers should immediately understand what broke.
169169
- Redundant setup code should be refactored, but clarity trumps abstraction.
170170
171+
# --- CUSTOM INSTRUCTIONS FOR .GITHUB DIRECTORY ---
172+
- path: ".github/workflows/**/*"
173+
instructions: |
174+
Review workflows as security-sensitive infrastructure.
175+
176+
A good workflow is small, focused, and boring.
177+
If a workflow is clever, generic, or overly flexible, it is a risk.
178+
179+
---------------------------------------------------------
180+
PRIORITY 0 — ABSOLUTE REQUIREMENTS
181+
---------------------------------------------------------
182+
- All third-party actions MUST be pinned to full commit SHAs, similar to other workflows.
183+
- `permissions:` MUST be explicitly declared and minimally scoped.
184+
- Workflows MUST behave safely when executed from forks.
185+
- YAML MUST orchestrate steps, not implement business logic.
186+
- Any workflow that mutates GitHub state MUST support dry-run mode.
187+
- Workflows MUST NOT modify repository source code outside `.github/`.
188+
189+
---------------------------------------------------------
190+
PRIORITY 1 — SCOPE, FOCUS & RESTRAINT
191+
---------------------------------------------------------
192+
- The title of each workflow must be relevant, match similar naming schemes, and match its script filename.
193+
- Each workflow MUST have a single, clearly defined objective and SHOULD document this in a top-level comment.
194+
- Flag workflows that:
195+
- Attempt to be generic “frameworks”
196+
- Include speculative or future-facing logic
197+
- Perform actions unrelated to the stated goal
198+
- Over-abstraction and excess flexibility are maintenance risks.
199+
200+
---------------------------------------------------------
201+
PRIORITY 2 — INPUT HARDENING
202+
---------------------------------------------------------
203+
- Treat ALL GitHub event data as potentially hostile input, including:
204+
- issue titles, bodies, and comments
205+
- labels, usernames, branch names
206+
- Free-form user input MUST NOT be passed directly into:
207+
- shell commands
208+
- gh CLI arguments
209+
- Node.js exec / spawn calls
210+
- Require strict allowlists or exact string matches.
211+
- Flag any use of:
212+
- eval or bash -c
213+
- backticks or $(...) with user-controlled input
214+
215+
---------------------------------------------------------
216+
PRIORITY 3 — DRY-RUN & SAFE OPERATION
217+
---------------------------------------------------------
218+
- Workflows that mutate state MUST expose:
219+
workflow_dispatch:
220+
inputs:
221+
dry_run:
222+
default: "true"
223+
- When dry_run=true, workflows MUST:
224+
- Log dry mode is active
225+
- Function on dry run: never post, comment, label, assign or edit
226+
- Be easy to expand in the future
227+
- Exit successfully
228+
- Dry-run behavior must be explicit and visible in logs.
229+
230+
---------------------------------------------------------
231+
PRIORITY 4 — SCRIPT EXTRACTION & CODE TRIM
232+
---------------------------------------------------------
233+
- YAML should orchestrate execution only.
234+
- All non-trivial logic MUST live in:
235+
- `.github/scripts/*.sh`
236+
- `.github/scripts/*.js`
237+
- Workflow filenames and their primary scripts SHOULD share a clear, matching name.
238+
- Scripts MUST remain:
239+
- Purpose-built
240+
- Trim and readable
241+
- Easy to maintain
242+
- Flag:
243+
- Large `run: |` blocks
244+
- Inline loops, conditionals, or API calls in YAML
245+
- Overly generic helper scripts for narrow tasks
246+
247+
---------------------------------------------------------
248+
PRIORITY 5 — API EFFICIENCY & DISCIPLINE
249+
---------------------------------------------------------
250+
- GitHub API usage must be intentional and minimal.
251+
- Prefer:
252+
- Aggregated queries over per-entity loops
253+
- Server-side filtering over client-side iteration
254+
- Reusing data already present in the event payload
255+
- Pagination MUST:
256+
- Be considered and justified
257+
- Enforce hard upper bounds
258+
- Flag:
259+
- Repeated API calls inside loops
260+
- Unbounded pagination
261+
- Fetching data already available in context
262+
263+
---------------------------------------------------------
264+
PRIORITY 6 — CONCURRENCY & IDEMPOTENCY
265+
---------------------------------------------------------
266+
- Workflows that mutate state MUST:
267+
- Define a deterministic concurrency group
268+
- Be safe under retries and parallel execution
269+
- Duplicate prevention is REQUIRED:
270+
- Marker-based comment detection
271+
- Check-before-create logic for labels and assignments
272+
- Assume workflows may:
273+
- Run multiple times
274+
- Be retried automatically
275+
- Execute concurrently with other automations
276+
- Workflows should avoid logic that duplicates or causes conflicts.
277+
278+
---------------------------------------------------------
279+
PRIORITY 7 — PERMISSION CORRECTNESS
280+
---------------------------------------------------------
281+
- Requested permissions MUST exactly match behavior.
282+
- Explicitly validate common cases:
283+
- issues: write → comments, labels, assignments
284+
- contents: read → repository checkout
285+
- pull-requests: write → PR mutations
286+
- Flag:
287+
- Over-permissioned workflows
288+
- Under-permissioned workflows that would fail at runtime
289+
- Reliance on default permissions
290+
291+
---------------------------------------------------------
292+
PRIORITY 8 — LOGGING & OPERABILITY
293+
---------------------------------------------------------
294+
- Logs should include, where applicable:
295+
- repository
296+
- workflow name
297+
- issue or PR number
298+
- triggering actor
299+
- dry-run status
300+
- decisions made (performed vs skipped)
301+
- Avoid:
302+
- Silent success or silent skips
303+
- Raw payload dumps
304+
- Any secret or token leakage
305+
306+
# ============================================================
307+
# SHELL SCRIPTS
308+
# ============================================================
309+
- path: ".github/scripts/**/*.sh"
310+
instructions: |
311+
Treat shell scripts as production-grade automation.
312+
313+
Scripts should be small, focused, and explicit.
314+
Avoid “do-everything” or overly generic scripts.
315+
316+
- MUST use: `set -euo pipefail`
317+
- MUST validate all required environment variables
318+
- MUST defensively quote variables
319+
- MUST validate all untrusted input
320+
- MUST have bounded loops and pagination
321+
- MUST support dry-run mode if state is mutated
322+
- MUST log key decisions and early exits
323+
324+
# ============================================================
325+
# JAVASCRIPT SCRIPTS
326+
# ============================================================
327+
- path: ".github/scripts/**/*.js"
328+
instructions: |
329+
Review JavaScript scripts as long-lived automation code.
330+
331+
Scripts must remain:
332+
- Focused
333+
- Readable
334+
- Purpose-built
335+
336+
- All `context.payload` fields MUST be validated
337+
- Free-form text MUST NOT be trusted
338+
- Dynamic code execution is prohibited
339+
- Avoid `child_process.exec`; prefer `execFile` if needed
340+
- All async operations MUST be wrapped in try/catch
341+
- Errors MUST include contextual metadata
342+
- Duplicate API calls MUST be avoided
343+
- Marker-based deduplication is required
344+
- Scripts MUST NOT assume write access
345+
- Permission failures MUST be handled gracefully
346+
171347
chat:
172348
art: false # Don't draw ASCII art (false)
173-
auto_reply: false # Don't allow bot to converse (spammy)
349+
auto_reply: false # Don't allow bot to converse (spammy)

0 commit comments

Comments
 (0)