Skip to content

Document replace vs replaceAll gotcha for stable-id construction in CLAUDE.md #3

Description

@mollyretter

PR #1's F2 question surfaced a String.prototype.replace call building a stable record id from a repo field (scripts/promote-to-dataset.ts:120) — replace only swaps the first occurrence, so a repo value with more than one slash would silently collide ids across different repos sharing the same owner prefix.

The fix in PR #1 was straightforward (use replaceAll), but any future stable-id construction in this repo will face the same trap.

CLAUDE.md should carry a one- or two-sentence reminder under a "Stable IDs / record keys" subsection: prefer replaceAll (or a regex with global flag), or validate the input shape before the replace. The inline comment now living at scripts/promote-to-dataset.ts:119-120 is the precedent worth pointing at.

Context: Origin in docs/build-logs/panel-review-pr-1.md (Retro #2).


🤖 Filed by Claude Code from the panel-review PR #1 retro.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions