Skip to content

docs: add CLAUDE.md, and cover Storybook in CONTRIBUTING - #535

Merged
alukach merged 4 commits into
mainfrom
docs/claude-md
Aug 29, 2026
Merged

docs: add CLAUDE.md, and cover Storybook in CONTRIBUTING#535
alukach merged 4 commits into
mainfrom
docs/claude-md

Conversation

@alukach

@alukach alukach commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Why

Four things keep having to be restated across sessions, and none of them are
visible from the code:

  1. UI changes belong in Storybook, in the same PR — added, changed, or
    removed. A state you can only reach by clicking through the running app is a
    state nobody reviews.
  2. A UI PR should link its stories and screenshot anything visual. The
    screenshot shows the change in the review itself, and outlives the branch
    deployment, which goes away with the branch.
  3. A PR's title and description describe the branch as it stands — not as it
    stood when the PR was opened. A description is read later as the spec, so a
    stale one sends a reviewer looking for code that isn't there.
  4. Comments say why the code is the way it is, in the present tense. What it
    used to do and what a change fixed belong in the commit message and PR
    description, where someone actually goes looking for history — and where it
    stays accurate as the code moves on.

CLAUDE.md is loaded automatically into every Claude Code session in this repo,
so it is the mechanism that makes these stick without being re-explained.

Rule 3 earned its place during this session: #533 still described a fixed-width
Storybook wrapper, and testing "inside the 320px container", two commits after
both had been replaced by a pinned viewport. It called out the two parts that rot
first — a Testing section asserting checks that predate the current commits, and
a Conventional Commits title that no longer matches the work's shape.

Also in CLAUDE.md

The Storybook gotchas that otherwise cost an hour to rediscover:

  • async server components can't be storied (they read the session) — extract the
    presentational part, as ProductDoi does beside ProductSummaryCard;
  • a component importing a server action needs sb.mock() in preview.tsx, or
    its story dies on __filename is not defined;
  • responsive states want a pinned viewport, never a fixed-width wrapper. A box
    exactly as wide as the frame has none of the page padding the real layout has,
    so it invents overflow the page doesn't have. (Learned the hard way in fix(products): truncate a product's DOI instead of overflowing the row #533.)

CONTRIBUTING.md

Storybook has been published at ui.source.coop since #498 and was not mentioned
in CONTRIBUTING at all. Adds a Code Conventions section for it, plus two PR
steps: describing UI changes, and keeping the PR current. The gotchas stay in
CLAUDE.md — one copy of each rule, so the two files can't drift.

Notes

Rules 1–3 are not component-scoped, which is why this is a root CLAUDE.md
rather than a scoped src/components/CLAUDE.md.

Worth considering separately: much of rule 1 could be enforced rather than
documented — this repo already codifies conventions as no-restricted-syntax
rules with a teaching message. A test asserting every component has a sibling
.stories.tsx would need an allowlist for the current gaps, so it is left out
here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JoNCbzms6gPxEbKCgSPe9L

alukach and others added 2 commits August 29, 2026 15:35
Three rules that keep having to be restated:

- UI changes land in Storybook in the same PR -- added, changed or removed.
  A state only reachable by clicking through the app is one nobody reviews.
- A UI PR links the stories it affects on that branch's Storybook deploy, and
  screenshots anything visual, since the deploy is behind SSO.
- Comments say why the code is the way it is, present tense. History belongs in
  the commit message and PR description, where it stays accurate.

Plus the Storybook gotchas that cost time to rediscover: async server components
can't be storied, server actions need sb.mock(), and responsive states want a
pinned viewport rather than a fixed-width wrapper.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JoNCbzms6gPxEbKCgSPe9L
Storybook has been published at ui.source.coop since #498 and went unmentioned
here. Adds a Code Conventions section for it, and a PR step asking UI changes to
link their stories and screenshot anything visual.

The gotchas stay in CLAUDE.md; this is the part a human contributor needs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JoNCbzms6gPxEbKCgSPe9L
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
source-coop-ui Ready Ready Preview Aug 29, 2026 6:46am
source-cooperative Ready Ready Preview Aug 29, 2026 6:46am

Request Review

@claude

claude Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Claude finished @alukach's task in 1m 4s —— View job


✅ No blocking issues — safe to merge.

This is a docs-only change (CLAUDE.md new, CONTRIBUTING.md +9/-1); there's no executable code, so there's nothing to flag on correctness or security.

One non-blocking consistency note:

  • The PR description says the goal is "one copy of each rule, so the two files can't drift," but the "Storybook" and "Pull requests" guidance is stated in both files with near-duplicate wording:

    • CLAUDE.md:9-12 ("Every UI change lands in Storybook in the same PR...") vs. CONTRIBUTING.md:81 ("UI changes carry their stories with them...")
    • CLAUDE.md:30-33 (linking stories + screenshotting visuals) vs. CONTRIBUTING.md:16 ("Describe UI changes.")
    • CLAUDE.md:34-40 (keeping title/description current) vs. CONTRIBUTING.md:17 ("Keep the PR current.")

    Not a bug, but worth a look since it's the exact kind of drift risk the PR calls out — if one is edited later, the other may quietly go stale.

Simplify (ponytail)

  • CONTRIBUTING.md:16-17 / CLAUDE.md:30-40 — the "Describe UI changes" and "Keep the PR current" checklist bullets restate CLAUDE.md's "Pull requests" section almost verbatim; cut one copy (e.g. keep the detailed version in CLAUDE.md, reduce CONTRIBUTING.md's bullets to a one-line pointer) → single source of truth per the PR's own stated intent.

💰 Estimated review cost: $0.27 · 1m03s · 16 turns

A description written when the PR was opened is read later as the spec. This
session produced the example: #533 still described a fixed-width Storybook
wrapper and testing "inside the 320px container" two commits after both were
replaced by a pinned viewport.

Flags the two parts that rot first -- a Testing section asserting checks that
predate the current commits, and a Conventional Commits title that no longer
matches the work's shape.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JoNCbzms6gPxEbKCgSPe9L
…ded claim

The server-component note assumed the reader already knew the mechanism. Says it
outright now: stories render in a browser bundle, ProductSummaryCard awaits
getPageSession() for cookies and a DynamoDB lookup, so no prop makes it render --
hence the split into a data half and a presentational half.

Also replaces the reason for screenshotting UI changes. Branch deployments do
302 to Vercel SSO unauthenticated, but reviewers here are generally logged in,
outside contributions have their own approval flow, and anyone can run the
stories locally -- so "all a reviewer can see" was overstated. A screenshot earns
its place by showing the change in the review and outliving the deployment.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JoNCbzms6gPxEbKCgSPe9L
@alukach
alukach merged commit 05bfa59 into main Aug 29, 2026
7 of 8 checks passed
@alukach
alukach deleted the docs/claude-md branch August 29, 2026 06:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant