Skip to content

docs(claude): consolidate CLAUDE.md rules from stale branches#608

Merged
John-David Dalton (jdalton) merged 2 commits intomainfrom
chore/claude-consolidate-rules
Apr 21, 2026
Merged

docs(claude): consolidate CLAUDE.md rules from stale branches#608
John-David Dalton (jdalton) merged 2 commits intomainfrom
chore/claude-consolidate-rules

Conversation

@jdalton
Copy link
Copy Markdown
Contributor

@jdalton John-David Dalton (jdalton) commented Apr 21, 2026

Summary

Consolidates the genuinely valuable content scattered across four now-stale worktree branches into one coherent PR, and pulls two rules from the socket-repo-template gold standard that this repo was missing.

CLAUDE.md changes

  • New: null-prototype rule ({ __proto__: null, ...rest }). Already the idiom across src/socket-sdk-class.ts and src/file-upload.ts; codifying it keeps prototype-pollution surface small.
  • New: Linear-reference rule. Keeps code + PR history tool-agnostic. Forward-looking — no violations today.
  • Restructured: Promise.race bullet split into a dedicated ### Promise.race in loops subsection with Safe / Leaky / Fix framing (matches template). Also explicitly covers Promise.any and long-lived interrupt-signal arms.

src/socket-sdk-class.ts changes

Expands the 6-line comment landed in #600 with the fuller narrative that was sitting uncommitted on the fix/promise-race-leak worktree — concrete walkthrough of the handler-stacking trap, what each piece of the single-waiter machinery is responsible for, and why the snapshot-and-clear dance in deliverStep / deliverError matters. No behavioral change; comments only.

Deliberately NOT pulled from template

  • NEVER use dynamic imports (\await import()`)— the SDK usesawait import('node:fs')legitimately atsrc/socket-sdk-class.ts:1931and:3818` for lazy loading. A blanket ban would be wrong here.

Test plan

  • oxfmt --check passes for both files
  • Pre-push validation passes (lint, type-check, build, tests)
  • Reviewer sanity-checks that the new rules reflect actual SDK practice

Fold the genuinely valuable guidance scattered across several now-stale
worktree branches (fix/promise-race-leak, chore/parallel-claude-rule,
docs/claude-fix-warnings-rule) into a single coherent pass on CLAUDE.md,
and pull in two rules the socket-repo-template gold standard already
carries but this repo was missing.

- Restructure the Promise.race guidance into a dedicated "### Promise.race
  in loops" subsection with the template's Safe/Leaky/Fix triad — same
  content, but the three-state framing is easier to apply at review time
  than a single run-on bullet.
- Add null-prototype rule: `{ __proto__: null, ...rest }` is already the
  idiom used throughout src/socket-sdk-class.ts and src/file-upload.ts
  (config objects, internal state, return shapes); codify it so new
  contributions follow suit and prototype pollution surface stays small.
- Add Linear-reference rule: keep code and PR history tool-agnostic.
  Forward-looking — no violations currently in the repo.

Deliberately NOT pulled from template: the "NEVER use dynamic imports"
rule. SDK uses `await import('node:fs')` legitimately in two places
(socket-sdk-class.ts:1931, :3818) for lazy loading; a blanket ban would
be wrong here.
Replace the 6-line comment landed in #600 with the fuller narrative that
was sitting uncommitted on the fix/promise-race-leak worktree — concrete
walkthrough of the handler-stacking trap, what each piece of the
single-waiter machinery is responsible for, and why the snapshot-and-
clear dance in deliverStep/deliverError matters.

No behavioral change; comments only. The mechanical fix already shipped
in #600 (376a743); this captures the reasoning someone will want when
they look at this code six months from now.
@jdalton John-David Dalton (jdalton) merged commit a036acc into main Apr 21, 2026
11 checks passed
@jdalton John-David Dalton (jdalton) deleted the chore/claude-consolidate-rules branch April 21, 2026 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants