Skip to content

Add Vercel React best practices skill with 45 optimization rules#226

Open
cseagraves wants to merge 156 commits intovercel-labs:mainfrom
agenticassets:claude/review-codebase-quality-a7lOI
Open

Add Vercel React best practices skill with 45 optimization rules#226
cseagraves wants to merge 156 commits intovercel-labs:mainfrom
agenticassets:claude/review-codebase-quality-a7lOI

Conversation

@cseagraves
Copy link

Summary

This PR adds a comprehensive React and Next.js performance optimization skill to the agent system. The skill contains 45 rules organized across 8 priority categories, providing guidance for writing performant React/Next.js code.

Key Changes

  • Added SKILL.md: Main skill definition with overview of all 45 rules organized by priority (CRITICAL, HIGH, MEDIUM-HIGH, MEDIUM, LOW-MEDIUM, LOW)
  • Added 45 rule files across 8 categories:
    • Eliminating Waterfalls (5 rules): async-parallel, async-defer-await, async-dependencies, async-api-routes, async-suspense-boundaries
    • Bundle Size Optimization (5 rules): bundle-barrel-imports, bundle-dynamic-imports, bundle-defer-third-party, bundle-conditional, bundle-preload
    • Server-Side Performance (5 rules): server-cache-react, server-cache-lru, server-serialization, server-parallel-fetching, server-after-nonblocking
    • Client-Side Data Fetching (2 rules): client-swr-dedup, client-event-listeners
    • Re-render Optimization (7 rules): rerender-defer-reads, rerender-memo, rerender-dependencies, rerender-derived-state, rerender-functional-setstate, rerender-lazy-state-init, rerender-transitions
    • Rendering Performance (7 rules): rendering-animate-svg-wrapper, rendering-content-visibility, rendering-hoist-jsx, rendering-svg-precision, rendering-hydration-no-flicker, rendering-activity, rendering-conditional-render
    • JavaScript Performance (12 rules): js-batch-dom-css, js-index-maps, js-cache-property-access, js-cache-function-results, js-cache-storage, js-combine-iterations, js-length-check-first, js-early-exit, js-hoist-regexp, js-min-max-loop, js-set-map-lookups, js-tosorted-immutable
    • Advanced Patterns (2 rules): advanced-event-handler-refs, advanced-use-latest
  • Added AGENTS.md: Compiled document with all rules expanded (2249 lines)

Implementation Details

Each rule file includes:

  • Clear title and impact assessment
  • Incorrect code example with explanation
  • Correct code example with explanation
  • Additional context and references where applicable
  • Consistent frontmatter with metadata (impact level, tags)

Rules are prioritized by performance impact, with CRITICAL rules (waterfalls, bundle optimization) at the top to guide automated refactoring and code generation. The skill is designed to be used when writing, reviewing, or refactoring React/Next.js code.

https://claude.ai/code/session_014QKGykX1gzoA6EetgDrfKG

agenticassets and others added 30 commits November 17, 2025 19:11
This commit adds extensive Claude Code setup including commands, skills, reference documentation, and project-specific instructions to enhance AI-assisted development capabilities.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Expand GitHub OAuth affiliation to include collaborator and organization_member repos
- Hide GitHub stars button and Deploy Your Own button from UI
- Hide mobile footer with template branding

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Hide buttons in repo-layout.tsx
- Hide buttons in repo-page-client.tsx
- Hide buttons in task-page-client.tsx (2 instances)
- Hide buttons in tasks-list-client.tsx
- Hide buttons in task-page-header.tsx

All template branding now hidden site-wide while preserving code.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Analyzed GitHub authentication and identified root causes for two issues:
1. Private repositories not visible after OAuth login
2. Push operations failing with permission errors

Root causes identified:
- Organization OAuth app approval required
- SAML SSO authorization needed
- Repository-level write permissions
- OAuth scope verification during authorization

Created comprehensive documentation:
- GITHUB_AUTH_TROUBLESHOOTING.md: Complete diagnosis and solutions
- github-oauth-docs-2026.md: Latest GitHub OAuth documentation (2026)

Key findings:
- Codebase implementation is correct (no bugs found)
- Issues are GitHub configuration and permission-related
- OAuth scope 'repo' is correctly requested
- User must approve app for organizations and authorize SSO

Solutions provided for:
- End users (reconnect GitHub, approve org access, authorize SSO)
- Application administrators (permission validation, better error messages)
- Optional code improvements for better UX

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Changed tagline from "Multi-agent AI coding platform powered by Vercel Sandbox and AI Gateway" to "Multi-agent AI coding platform powered by Agentic Assets" with link to https://www.agenticassets.ai

Modified file:
- components/task-form.tsx (lines 393-403)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Added helpful text to explain how to add authentication headers (like Authorization with Bearer tokens) using environment variables in the MCP server configuration dialog.
- Created OrbisIcon component from SVG logo
- Added Orbis to PRESETS array with remote type
- Configured Authorization environment variable requirement
- Added icon detection for Orbis in all relevant UI sections
- Users can now easily add Orbis MCP with their Bearer token
- Updated page title in app/layout.tsx
- Updated main heading in task form
Displays the Agentic Assets SVG logo above the "AI Coding Agent" heading with responsive sizing (240px mobile, 320px tablet, 400px desktop) and priority loading for optimal performance.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Co-authored-by: admin <admin@agenticassets.ai>
- Add AI Gateway authentication method to Claude agent documentation
- Document alternative models available via AI Gateway (GLM-4.7, Gemini 3, GPT-5)
- Update API key sections to explain dual authentication support
- Add model selection logic and priority documentation
- Update AI_MODELS_AND_KEYS.md with comprehensive Claude section

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…-gateway

2026 1 15 cns claude code ai gateway
- Add dark:invert to logo for automatic color inversion in dark mode
- Reduce logo size by 20%: 192px mobile, 256px tablet, 320px desktop
- Update Next.js Image dimensions to match (320x37)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Remove standalone logo above heading
- Place logo inline after "powered by" text
- Replace "Agentic Assets" text with logo image
- Logo sized at 18px height to match text-lg font size (158px width for 8.79:1 aspect ratio)
- Maintain dark:invert for theme toggle
- Logo is now a clickable hyperlink to https://www.agenticassets.ai

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…uCooYvpq3t

There's there's an issue with the API keys window that pops up when i clik the user icon inthe top right corner and then click the API keys button. when i click it, i see htis ""API Keys
Configure your own API keys. System defaults will be used if not pro
agenticassets and others added 26 commits January 20, 2026 08:11
This commit merges approved optimizations from:
- cursor/AGENTIC-18-request-waterfalls-agent-c76b
- cursor/AGENTIC-19-editor-re-render-optimization-537c

Changes include:

**API Route Optimizations (Branch 18):**
- Use Promise.all for parallel fetching of user data in tasks/route.ts
- Use Promise.all for parallel fetching in continue/route.ts
- Extract getMcpServersForUser helper for cleaner code

**Page-Level Optimizations (Branch 18):**
- Parallel fetch session and GitHub stars in app/page.tsx
- Parallel fetch in app/[owner]/[repo]/page.tsx
- Parallel fetch in app/new/[owner]/[repo]/page.tsx
- Parallel fetch in app/tasks/page.tsx
- Parallel fetch in app/repos/[owner]/[repo]/layout.tsx

**React Component Optimizations (Branch 19):**
- Wrap FileDiffViewer with memo() for render optimization
- Hoist constants (DIFF_VIEW_MODE, IMAGE_MIME_TYPES) outside component
- Add memoized derived state (isFilesMode, isChangesMode, diffViewTheme)
- Memoize editor options, language, and theme in FileEditor
- Use static strings in console.error calls per security guidelines

Rejected patterns (per code review):
- NDJSON streaming (adds complexity without real benefit)
- startTransition (minimal benefit for sync state updates)
- Nested callback ref patterns (creates stale closure risk)
- Create docs/MCP_GUIDE.md (199 lines) with getting started guide
- Cover: authentication setup, tool overview, prompting tips, common workflows
- Include configuration for Claude Desktop, Cursor, and Windsurf
- Add best practices and troubleshooting sections
- Update README.md to cross-reference both MCP docs
…zations

## Security Hardening (8 Critical Fixes)
- Remove dynamic values from all log statements per CLAUDE.md security policy
- Fix logging in: migrate-production.ts, user.ts, claude.ts, github callback
- All console.log/error now use static strings only

## Database Performance
- Add migration 0025_add_rate_limit_indexes.sql with 4 new indexes:
  - idx_tasks_user_id_created_at (rate limit task counting)
  - idx_tasks_user_id_deleted_at (soft delete filtering)
  - idx_task_messages_task_id (join performance)
  - idx_task_messages_created_at (date filtering)

## React/Next.js Performance
- Add optimizePackageImports for lucide-react (bundle size reduction)
- Dynamic import Monaco editor (~2.5MB bundle reduction)
- Promise.all() for parallel data fetching in task creation (~30-50% latency reduction)

## Documentation
- Update CLAUDE.md with Recent Improvements section
- Update AGENTS.md with security enforcement emphasis

https://claude.ai/code/session_01FzPwR717TdRQmN6pAhCjB5
…nt-bFgxr

Comprehensive code review: security, performance, and database optimi…
…7okD

Add user-friendly MCP guide documentation
…-render-optimization-537c

Editor re-render optimization
Conflicts resolved in 3 files:
- app/api/tasks/route.ts: Keep Promise.all() with getMcpServersForUser helper
  for parallel data fetching (better performance and DRY principles)
- components/file-diff-viewer.tsx: Use React 19 startTransition for state
  updates, cachedDiffData memoization for proper deps, static logging
- components/file-editor.tsx: Add startTransition import, remove duplicate
  editorLanguage/editorTheme/editorOptions declarations

Merged features from main:
- MCP guide documentation
- Rate limit indexes migration
- Code review improvements
- Editor re-render optimizations

https://claude.ai/code/session_01LAxLpTMGTZrU4sqvwxRkK3
…cts-Mb97M

Claude/resolve merge conflicts mb97 m
- Add absolute maximum timeout (maxDuration + 15 min hard cap)
- Limit heartbeat extensions to 3 per task
- Add 10MB output size limit for Claude agent
- Explicit sandbox.stop() call for cost control
- Auto-cleanup keepAlive sandboxes after 30min idle
- Database migration for heartbeat extension tracking
- Enhanced warning logs for approaching limits

Addresses: infinite loop prevention, token exhaustion,
zombie sandbox cleanup, and cost attack mitigation.

https://claude.ai/code/session_01ENgSpXnDaFaK5wrZ2rycgt
…ce bundle size

Performance optimizations:
- Parallelize 3 independent user data fetches in start-sandbox route (~1200ms savings)
- Parallelize 5 sequential pkill commands in sandbox shutdown (~1000ms savings)
- Parallelize file existence checks and git config in sandbox creation (~600ms savings)
- Parallelize GitHub stars fetch with session in task page (~300ms savings)
- Run port detection in parallel with branch name polling in process-task (~400ms savings)
- Parallelize Claude CLI version/help diagnostic checks (~200ms)
- Parallelize sequential logger status/progress updates

Bundle size optimizations:
- Convert 10 client component value imports to `import type` for db/schema types,
  preventing potential leakage of drizzle-orm/pg-core into client bundle
- Dynamically import 5 heavy components in task-details.tsx (FileBrowser 1879 lines,
  TaskChat 1258 lines, FileDiffViewer 410 lines + @git-diff-view, CreatePRDialog,
  MergePRDialog) to reduce initial JS bundle
- Replace unused @radix-ui/react-icons with sonner and jotai in optimizePackageImports

https://claude.ai/code/session_01UHwJudy8YT9Ad258tFTkcv
CRITICAL - Waterfalls & Bundle:
- Parallelize 8 additional API route async operations (Promise.all)
- Defer Vercel Analytics/SpeedInsights after hydration (dynamic import)

HIGH - Server-Side Performance:
- Add React.cache() to 4 data fetching modules (user-token, client, user-keys, settings)
- Move sandbox cleanup and OAuth revocation to after() for non-blocking responses
- Add LRU cache for GitHub token validation (5min TTL, 100 entries)

MEDIUM-HIGH - Client-Side Data Fetching:
- Add passive flag to scroll event listeners (logs-pane, task-chat)
- Version localStorage keys with app:v1: prefix for migration support
- Centralize window resize listener into useWindowResize hook (5 components)

MEDIUM - Re-render Optimization:
- Remove useMemo for trivial ternary expression (file-editor theme)
- Fix useEffect dependency on repos array (task-form)
- Consolidate 4 duplicate effects into 1 (task-chat)
- Add startTransition for non-urgent auto-refresh updates
- Replace JSON.stringify dependency with ref-based array comparison

MEDIUM - Rendering Performance:
- Add content-visibility: auto for logs, task list, and file tree
- Wrap animated SVG icons in div wrappers (sub-agent-indicator)

LOW-MEDIUM - JavaScript Performance:
- Hoist 9 regex patterns to module level in logging utility

LOW - Advanced Patterns:
- Create useLatest hook for stable callback refs
- Stabilize keyboard and resize event handlers with useLatest

https://claude.ai/code/session_01UHwJudy8YT9Ad258tFTkcv
…-review-03b2

Deployment readiness review
…estration-9hnBH

Claude/optimize nextjs orchestration 9hn bh
- Add 14 @radix-ui packages to optimizePackageImports (bundle-barrel-imports)
- Defer Analytics/SpeedInsights via next/dynamic (bundle-defer-third-party)
- Wrap getGitHubStars in React.cache() for per-request dedup (server-cache-react)
- Hoist 4 default state objects to module constants in task-details (rerender-memo-with-default-value)
- Add { passive: true } to resize event listener (client-passive-event-listeners)
- Cache connectors filter with useMemo in task-form (js-combine-iterations)

https://claude.ai/code/session_015fSVBtppffeJSuTcWD3U3Z
HIGH priority:
- Install SWR and create shared fetcher utility (client-swr-dedup)
- Refactor useTask hook to SWR with smart polling (stops on terminal status)
- Create shared useCheckRuns hook eliminating duplicate check-runs requests
- Create useTaskMessages hook with SWR (auto-pause when tab hidden)
- Refactor session-provider to SWR (eliminates manual interval + focus listener)
- Refactor pr-check-status to shared useCheckRuns hook
- Refactor task-chat check-runs and message polling to SWR hooks
- Parallelize org-check in GitHub repos route (async-parallel)
- Wrap getMaxSandboxDuration in React.cache() (server-cache-react)

MEDIUM priority:
- Replace 7 manual loading states with useTransition in file-browser (rendering-usetransition-loading)
- Replace 3 manual loading states with useTransition in task-sidebar
- Convert Set dependency to primitive string in file-browser (rerender-dependencies)

https://claude.ai/code/session_015fSVBtppffeJSuTcWD3U3Z
…ges-KHYlU

Claude/review codebase changes kh yl u
Accessibility: aria-labels on icon-only buttons, aria-hidden on decorative
icons, skip link for main content, clickable div→button, overscroll-contain
on modals, focus-visible instead of focus on dialog close button, visible
focus ring on TabsContent.

Typography: "..." → proper ellipsis character (…) in all loading states,
placeholders, and truncated text. Added tabular-nums to duration displays.

Theming: color-scheme on :root/.dark, theme-color meta via Viewport export,
safe-area-inset padding on body, prefers-reduced-motion media query.

Animation: transition-all → explicit property lists in button, progress,
accordion, switch, and task-details components.

Forms: autocomplete/spellCheck on connector inputs, aria-labels on filter
inputs, Label with htmlFor in revert-commit-dialog.

Content: break-words/min-w-0/truncate on long text containers in logs-pane
and sub-agent-indicator.

https://claude.ai/code/session_014QKGykX1gzoA6EetgDrfKG
Copilot AI review requested due to automatic review settings February 1, 2026 00:37
@vercel
Copy link
Contributor

vercel bot commented Feb 1, 2026

@claude is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a comprehensive React and Next.js performance optimization skill containing 45 performance rules organized across 8 priority categories. The skill provides guidance for writing performant React/Next.js code with rules covering async operations, bundle optimization, server/client performance, and rendering patterns.

Changes:

  • Added main skill definition with metadata and categorized rule overview
  • Created 45 individual rule files with code examples across 8 performance categories
  • Added compiled AGENTS.md document with all rules expanded for quick reference

Reviewed changes

Copilot reviewed 109 out of 871 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
.agent/skills/vercel-react-best-practices/SKILL.md Main skill definition with overview of all 45 rules organized by priority
.agent/skills/vercel-react-best-practices/rules/*.md 45 individual rule files with incorrect/correct code examples
.claude/documents/guides-dec-2025/*.md Context engineering guide and Claude Code setup documentation
.claude/commands/**/*.md Various command definitions for project workflows
.claude/agents/*.md Agent definitions for specialized tasks
.agent/skills/web-design-guidelines/SKILL.md Web interface guidelines review skill

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +79 to +85
function DataDisplay({ dataPromise }: { dataPromise: Promise<Data> }) {
const data = use(dataPromise) // Unwraps the promise
return <div>{data.content}</div>
}

function DataSummary({ dataPromise }: { dataPromise: Promise<Data> }) {
const data = use(dataPromise) // Reuses the same promise
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The use() hook is experimental in React 19 and requires the experimental flag. Consider noting this requirement or providing a fallback pattern for production use.

Suggested change
function DataDisplay({ dataPromise }: { dataPromise: Promise<Data> }) {
const data = use(dataPromise) // Unwraps the promise
return <div>{data.content}</div>
}
function DataSummary({ dataPromise }: { dataPromise: Promise<Data> }) {
const data = use(dataPromise) // Reuses the same promise
async function DataDisplay({ dataPromise }: { dataPromise: Promise<Data> }) {
const data = await dataPromise // Unwraps the shared promise
return <div>{data.content}</div>
}
async function DataSummary({ dataPromise }: { dataPromise: Promise<Data> }) {
const data = await dataPromise // Reuses the same promise

Copilot uses AI. Check for mistakes.
**Correct (non-blocking):**

```tsx
import { after } from 'next/server'
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

Add a note about Next.js version requirement for the after() function, as this is a relatively new API that may not be available in all Next.js versions.

Copilot uses AI. Check for mistakes.
Comment on lines +44 to +48
module.exports = {
experimental: {
optimizePackageImports: ['lucide-react', '@mui/material']
}
}
Copy link

Copilot AI Feb 1, 2026

Choose a reason for hiding this comment

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

The optimizePackageImports configuration shown uses CommonJS (module.exports), but the comment states 'next.config.js' which could be either ESM or CJS. Consider showing both formats or noting the configuration file format.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

@vercel vercel bot left a comment

Choose a reason for hiding this comment

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

Additional Suggestion:

MCP continue-task handler updates database but never triggers actual task continuation, leaving tasks stuck in 'processing' status forever.

Fix on Vercel

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.

4 participants