Skip to content

Conversation

@mafredri
Copy link
Member

@mafredri mafredri commented Nov 26, 2025

Summary

This PR documents critical frontend pattern migrations based on systematic analysis of 200+ git commits that modified site/ files. These patterns have been causing repeated feedback in PR reviews and need to be clearly documented for AI and human developers.

Analysis Method

Used git log to identify actual pattern migrations:

  • Analyzed 200+ commits touching site/ directory
  • Examined actual code diffs for migration patterns
  • Reviewed PR discussions via GitHub API
  • Identified systematic pattern changes across multiple PRs

Patterns Documented

1. Emotion → Tailwind CSS

2. MUI Components → Custom/Radix/shadcn

3. MUI Icons → lucide-react (NEW)

4. Radix Component Prop Naming (NEW)

5. Testing: spyOn → queries parameter

6. State Storage: localStorage → user_configs

7. Chromatic Testing Best Practices

8. cn() Utility for Conditional Classes (NEW)

  • Standard pattern for conditional className merging
  • Combines clsx and tailwind-merge
  • Used throughout shadcn components

Changes Made

  • Updated site/CLAUDE.md with comprehensive pattern documentation
  • Added prominent "Critical Pattern Migrations" section (now 5 critical patterns)
  • Included code examples for each pattern
  • Added new sections for icon migration and Radix conventions
  • Emphasized "leave the campsite better than you found it" philosophy

Git Statistics

  • Commits analyzed: 200+ touching site/ directory
  • Refactor/migration PRs found: 15+
  • Pattern-related PRs: 10+
  • Consistent migration effort: October-November 2025

Key PRs Referenced

#20948, #20946, #20938, #20933, #20905, #20900, #20869, #20849, #20808, #20530, #20479, #20318, #20261, #20204, #20201, #20200, #20193


🤖 This change was written by Claude Sonnet 4.5 Thinking using mux and reviewed by a human 🏂

Add comprehensive documentation for active frontend pattern migrations
discovered through analysis of 200+ git commits touching site/ files:

Core Migrations:
- Emotion → Tailwind CSS (strict 'no new emotion' policy)
- MUI Components → Custom/Radix/shadcn (Tooltips, Tables, Buttons)
- MUI Icons → lucide-react with specific icon mappings
- spyOn → queries parameter for GET endpoint mocks in Storybook
- localStorage → user_configs table for user preferences

New Documentation:
- Icon migration mappings (BusinessIcon→Building2Icon, etc.)
- Radix component prop naming conventions (placement→side)
- cn() utility usage for conditional className merging
- Chromatic testing best practices (prefer snapshots over assertions)

Includes concrete before/after examples and migration patterns to guide
developers away from deprecated approaches toward current best practices.

Analysis based on PRs: #20948, #20946, #20938, #20905, #20900, #20869,
#20849, #20808, #20530, #20479, #20261, #20201, #20200, #20193, #20318

---

🤖 This change was written by Claude Sonnet 4.5 Thinking using mux and reviewed by a human 🏂
@mafredri mafredri force-pushed the review-pattern-docs-update branch from 2af4fa8 to 1f0280e Compare November 26, 2025 13:44
Fix markdown linting errors MD032 and MD031:
- Add blank lines around lists (MD032)
- Add blank lines around fenced code blocks (MD031)

Ensures site/CLAUDE.md passes markdownlint-cli2 checks.
@mafredri mafredri requested review from aslilac and jaaydenh November 26, 2025 13:49
@mafredri mafredri marked this pull request as ready for review November 26, 2025 13:49
@mafredri mafredri changed the title docs(site): document critical frontend pattern migrations docs: document critical frontend pattern migrations in CLAUDE.md Nov 26, 2025
Copy link
Member

@aslilac aslilac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems to mostly make sense

one small worry: having the "don't"s in here puts them in the context window, and I worry that might some models might pick up on that and just ignore the "don't". I wonder if it might be better to only put the new equivalent? totally guessing tho

@jaaydenh has more experience with this kind of tuning so I'd love to here from him

Remove code examples showing deprecated patterns (OLD/DO NOT USE blocks)
that could mislead AI agents into copying the wrong patterns.

Changes:
- Icon section: Only show lucide-react imports, not MUI icons
- Radix section: Only show correct Radix pattern, not MUI pattern
- Emotion section: Only show Tailwind classes, not emotion imports
- Testing section: Only show queries parameter, not spyOn pattern

This prevents AI agents from pattern-matching and copying deprecated
code while maintaining clear guidance on what to replace and how.
Condense verbose sections to be more scannable and direct:
- Icon section: Single-line import, inline replacement mappings
- Radix section: Consolidated prop changes into one sentence
- Emotion section: Reduced from 5 to 4 bullets, combined redundant points
- Chromatic section: Reduced from 5 to 3 bullets
- localStorage section: Reduced from 8 to 4 lines

Overall ~30% reduction in text while maintaining clarity. AI agents
scan for patterns and use code examples - keeping prose minimal and
directive improves efficiency.
Remove redundant sections and repeated information:

- Remove entire "Migration" section (lines 192-207) that duplicated
  Components, Styling, and Tailwind sections
- Remove duplicate "leave campsite better" mention (already in line 13)
- Remove duplicate "Never import from @emotion/react" (already stated)

Reduces documentation from 250 to 232 lines while maintaining all
unique information. Each concept is now documented once in its most
appropriate section.
@mafredri
Copy link
Member Author

@aslilac personally I don't think the don't examples would be mistaken, but at the same time, they add length, wordiness and context size. So I opted to have the doc simplified, both in their removal and reduced wording.

There I guess the only tradeoff is how easily the old patterns are detected, but that's also not "free".

Remove 🚨 emoji from "Critical Pattern Migrations" section header to
maintain consistency with the original document style which uses no
emojis, only text emphasis and formatting.

All other style elements match the original:
- Section headers with ## and ###
- Bold emphasis for important terms
- Simple bullet lists with -
- Direct, imperative tone
- "(MUST FOLLOW)" matches original "(USE FIRST)" pattern
@mafredri mafredri force-pushed the review-pattern-docs-update branch from 21f5f0e to 453a8ac Compare November 27, 2025 19:30

### Icon Migration: MUI Icons → lucide-react

Never import from `@mui/icons-material`. Use `lucide-react` instead.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mui/icons-material is no longer used in the codebase, I think its highly unlikely the AI will suggest using a MUI icon anymore without any usages in the codebase.

When migrating from MUI to Radix components, use Radix naming conventions:

```tsx
<Tooltip side="top">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooltip migration will be completed soon, so this may not be the best example long-term, but could be fine for now.

Copy link
Contributor

@jaaydenh jaaydenh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the only change needed is removing the section about MUI Icons

@github-actions github-actions bot added the stale This issue is like stale bread. label Dec 9, 2025
@github-actions github-actions bot closed this Dec 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale This issue is like stale bread.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants