Monorepo for skill-driven, agentic React performance profiling and optimization.
This is the primary workflow for this repository, including everything the agent should do from app startup through verified optimization.
git clone https://github.com/avoc-ado/react-profiler-optimize.git
cd react-profiler-optimize
git submodule update --init --recursiveInstall dependencies for the app you want to profile and the profiler MCP tool:
cd apps/next-react-profiler-lab && yarn install
cd ../../tools/react-profiler-mcp && yarn installNext lab:
cd apps/next-react-profiler-lab
yarn devExpo web lab:
cd apps/expo-react-profiler-lab
npm install
npm run webWhen running the app, the agent should:
- Wait for the dev server to become reachable.
- Open the target route in Chrome Devtools MCP.
- Confirm page readiness (selector/text/URL) before recording.
Run React profiling MCP (record/analyze/compare):
In another terminal:
cd tools/react-profiler-mcp
node packages/mcp-server/index.jsOptional but recommended for browser-level trace scouting:
- Start
chrome-devtools-mcpin your agent client to enable navigation, interaction replay, and Chrome Performance traces.
Canonical skill lives in:
skills/react-profiler-optimize/SKILL.mdskills/react-profiler-optimize/references/*skills/react-profiler-optimize/scripts/*
Use this prompt pattern in your agent:
Use $react-profiler-optimize to profile apps/next-react-profiler-lab.
Capture baseline, analyze hotspots, apply a targeted fix, re-profile,
and produce before/after deltas.
- Navigate and interact deterministically.
- Run a baseline Chrome trace (if
chrome-devtools-mcpis connected) to prove a real perf issue and cadence. - Run a baseline React DevTools export capture with
record_react_devtools_profile. - Analyze the baseline export (
analyze_profile) and rank hotspots. - Narrow to concrete files/components using commit-level evidence and render reasons.
- Apply a minimal fix to one class of issue at a time.
- Re-run the exact same interaction sequence.
- Capture optimized profile and compare (
compare_profile_reportsorcompare_profiles_end_to_end). - Report measurable deltas and any residual risks.
- Start from
commits[*].flamegraph.nodes[*]andwhyRendered. - Cross-check recurring components in
reactTracks.topComponentCountsand cadence. - Map to source files in
apps/*(usually provider, memo boundary, or expensive child component). - Patch only the minimal lines required for the targeted footgun.
profiles/baseline-<flow>.jsonreports/baseline-<flow>.report.jsonprofiles/optimized-<flow>.jsonreports/optimized-<flow>.report.jsonreports/<flow>.diff.json
cd tools/react-profiler-mcp
node packages/cli/bin/react-profiler-cli.js record-react-devtools \
--url http://localhost:3000 \
--out /tmp/baseline.json
node packages/cli/bin/react-profiler-cli.js analyze \
--input /tmp/baseline.json \
--out /tmp/baseline-report.json \
--source-root ../../apps/next-react-profiler-lab
node packages/cli/bin/react-profiler-cli.js compare-profiles \
--before-profile /tmp/baseline.json \
--after-profile /tmp/optimized.json \
--out /tmp/compare.json \
--source-root ../../apps/next-react-profiler-lab.
├── apps/
│ ├── next-react-profiler-lab/
│ └── expo-react-profiler-lab/
├── tools/
│ └── react-profiler-mcp/
├── skills/
│ └── react-profiler-optimize/
└── vendor/
└── react/ # git submodule -> facebook/react
apps/*: profiling targets with intentional perf footguns.tools/react-profiler-mcp: recorder + analysis MCP server and CLI.skills/react-profiler-optimize: canonical skill to package/version with this repo.vendor/react: optional upstream checkout for parity/resync maintenance.
react-profiler-mcp is configured to resolve skill roots in this order:
- In-repo
skills/react-profiler-optimize(preferred) .skill-edit/react-profiler-optimize(workspace fallback)~/.codex/skills/react-profiler-optimize(user fallback)
Optional local install for Codex:
mkdir -p "${CODEX_HOME:-$HOME/.codex}/skills"
cp -R skills/react-profiler-optimize "${CODEX_HOME:-$HOME/.codex}/skills/react-profiler-optimize"Initialize:
git submodule update --init --recursiveUpdate:
git submodule update --remote vendor/reactMaintainer intent:
- Keep vendored hook parsing logic in
tools/react-profiler-mcp/packages/core/src/vendor/react-devtools-shared/. - Use
vendor/reactfor upstream diffing/resync workflows when needed.
- Node.js 20+
yarnand/ornpm- Git 2.40+
- GitHub CLI (
gh) authenticated - Chrome/Chromium available for automated profiling capture (Puppeteer)
- Generated traces/profiles/reports and local workspace artifacts are ignored at repo root.
- This repo is designed for reproducible optimization workflows, not long-term storage of raw trace dumps.