mk-react-patterns
React/Next.js authoring, review, and optimization: components, routes, bundle size, re-renders, performance. Auto-activates on .tsx/.jsx files alongside mk:typescript in React projects.
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 16
- Forks
- 3
01 前言 Front Matter
- name
- mk-react-patterns
- description
- React/Next.js authoring, review, and optimization: components, routes, bundle size, re-renders, performance. Auto-activates on .tsx/.jsx files alongside mk:typescript in React projects.
02 资源文件 5
- 参考文档references/async-patterns.md1.6 KB
- 参考文档references/bundle-optimization.md1.5 KB
- 参考文档references/rendering-patterns.md1.6 KB
- 参考文档references/rerender-optimization.md2.0 KB
- 参考文档references/server-patterns.md1.7 KB
03 SKILL.md 正文
React Patterns
React and Next.js performance optimization — curated rules across priority categories drawn from framework docs and production practice.
Complements mk:typescript (type safety) and mk:vue (Vue patterns). This skill covers React-specific performance patterns.
When to Use
- Writing or reviewing React/Next.js components
- Optimizing bundle size or render performance
- Fixing re-render issues
- Server vs client component decisions
- Data fetching patterns
Rule Categories (by priority)
Load the relevant reference when working in that area:
| Priority | Category | Reference | Key rules |
|---|---|---|---|
| CRITICAL | Eliminating waterfalls | references/async-patterns.md |
Defer await, parallel promises, Suspense boundaries |
| CRITICAL | Bundle size | references/bundle-optimization.md |
No barrel imports, dynamic imports, defer third-party |
| HIGH | Server performance | references/server-patterns.md |
React.cache(), LRU cache, parallel fetching, after() |
| MEDIUM | Re-render optimization | references/rerender-optimization.md |
Derived state, functional setState, memo, transitions |
| MEDIUM | Rendering perf | references/rendering-patterns.md |
content-visibility, hoist JSX, conditional render |
Process
- Identify the performance concern (waterfall? bundle? re-render? server?)
- Load the matching reference file
- Apply rules — each rule has: problem, solution, code example
- Verify improvement (Lighthouse, bundle analyzer, React DevTools)
Gotchas
- Premature optimization: optimizing re-renders before measuring → measure first with React DevTools Profiler
- Over-memoizing: wrapping everything in useMemo/React.memo → memo only when profiler shows expensive re-renders
- Barrel file trap: importing from index.ts pulls entire module → always import directly from source file
Workflow Integration
Auto-activates during Phase 3 (Build) when React/Next.js project detected. Loaded by developer agent alongside mk:typescript.
04 同仓库更多 Skills
mk-worktree
Manages git worktrees for parallel agent isolation: creates parallel/{name}-{timestamp} branches, merges with conflict detection. NOT for user feature branches (use git worktree directly).
mk-workflow-orchestrator
Auto-invoked 7-phase workflow for complex-feature intent; fasttrack mode for pre-approved specs. NOT for explicit single tasks (mk:cook), green-field builds (mk:autobuild), or simple fixes (mk:fix).
mk-web-to-markdown
Fetch a URL and return clean markdown, for arbitrary external pages (blog, RFC, GitHub issue, vendor doc) not covered by mk:docs-finder. Static-only by default; opt-in JS rendering available.
mk-vulnerability-scanner
Vulnerability analysis: OWASP Top 10, current threat landscape, supply chain security, attack surface mapping, risk prioritization. Use for security audits. NOT for STRIDE/CSO infra audits (mk:cso).
mk-vue
Vue 3 authoring/review: components, composables, reactivity, Pinia, Pinia Colada, file routing, forms. Composition API + script setup. Auto-activates on .vue files. Deep review: mk:vue-best-practices.
mk-vue-testing-best-practices
Vue 3 testing best-practices review: Vitest + Vue Test Utils for components, composables, Pinia, Router, async/Suspense, forms, a11y, plus Playwright E2E strategy. Advisory only.