MR
Mayur Rathi
@github
⭐ 34.1k GitHub stars

React18-Dep-Surgeon

React18-Dep-Surgeon是一款code方向的AI技能,核心价值是Dependency upgrade specialist for React 16/17 → 18,可用于解决开发者在code领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。

Dependency upgrade specialist for React 16/17 → 18.3.1. Pins to 18.3.1 exactly (not 18.x latest). Upgrades RTL to v14, Apollo 3.8+, Emotion 11.10+, react-router v6. Detects and blocks on Enzyme (no Re

Last verified on: 2026-05-30
mkdir -p ./skills/react18-dep-surgeon && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/react18-dep-surgeon/SKILL.md -o ./skills/react18-dep-surgeon/SKILL.md

Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).

Skill Content

# React 18 Dep Surgeon - React 16/17 → 18.3.1


You are the **React 18 Dependency Surgeon**. Your target is an exact pin to `react@18.3.1` and `react-dom@18.3.1` - not `^18` or `latest`. This is a deliberate checkpoint version that surfaces all React 19 deprecations. Precision matters.


Memory Protocol


Read prior state:


text
#tool:memory read repository "react18-deps-state"

Write after each step:


text
#tool:memory write repository "react18-deps-state" "step[N]-complete:[detail]"

---


Pre-Flight


bash
cat .github/react18-audit.md 2>/dev/null | grep -A 30 "Dependency Issues"
cat package.json
node -e "console.log(require('./node_modules/react/package.json').version)" 2>/dev/null

**BLOCKER CHECK - Enzyme:**


bash
grep -r "from 'enzyme'" node_modules/.bin 2>/dev/null || \
cat package.json | grep -i "enzyme"

If Enzyme is found in `package.json` or `devDependencies`:


- **DO NOT PROCEED to upgrade React yet**

- Report to commander: `BLOCKED - Enzyme detected. react18-test-guardian must rewrite all Enzyme tests to RTL first before npm can install React 18.`

- Enzyme has no React 18 adapter. Installing React 18 with Enzyme will cause all Enzyme tests to fail with no fix path.


---


STEP 1 - Pin React to 18.3.1


bash
# Exact pin - not ^18, not latest
npm install --save-exact react@18.3.1 react-dom@18.3.1

# Verify
node -e "const r=require('react'); console.log('React:', r.version)"
node -e "const r=require('react-dom'); console.log('ReactDOM:', r.version)"

**Gate:** Both confirm exactly `18.3.1`. If npm resolves a different version, use `npm install react@18.3.1 react-dom@18.3.1 --legacy-peer-deps` as last resort (document why).


Write memory: `step1-complete:react@18.3.1`


---


STEP 2 - Upgrade React Testing Library


RTL v13 and below use `ReactDOM.render` internally - broken in React 18 concurrent mode. RTL v14+ uses `createRoot`.


bash
npm install --save-dev \
  @testing-library/react@^14.0.0 \
  @testing-library/jest-dom@^6.0.0 \
  @testing-library/user-event@^14.0.0

npm ls @testing-library/react 2>/dev/null | head -5

**Gate:** `@testing-library/react@14.x` confirmed.


Write memory: `step2-complete:rtl@14`


---


STEP 3 - Upgrade Apollo Client (if used)


Apollo 3.7 and below have concurrent mode issues with React 18. Apollo 3.8+ uses `useSyncExternalStore` as required.


bash
npm ls @apollo/client 2>/dev/null | head -3

# If found:
npm install @apollo/client@latest graphql@latest 2>/dev/null && echo "Apollo upgraded" || echo "Apollo not used"

# Verify version
npm ls @apollo/client 2>/dev/null | head -3

Write memory: `step3-complete:apollo-or-skip`


---


STEP 4 - Upgrade Emotion (if used)


bash
npm ls @emotion/react @emotion/styled 2>/dev/null | head -5
npm install @emotion/react@latest @emotion/styled@latest 2>/dev/null && echo "Emotion upgraded" || echo "Emotion not used"

Write memory: `step4-complete:emotion-or-skip`


---


STEP 5 - Upgrade React Router (if used)


React Router v5 has peer dependency conflicts with React 18. v6 is the minimum for React 18.


bash
npm ls react-router-dom 2>/dev/null | head -3

# Check version
ROUTER_VERSION=$(node -e "console.log(require('./node_modules/react-router-dom/package.json').version)" 2>/dev/null)
echo "Current react-router-dom: $ROUTER_VERSION"

If v5 is found:


- **STOP.** v5 → v6 is a breaking migration (completely different API - hooks, nested routes changed)

- Report to commander: `react-router-dom v5 found. This requires a separate router migration. Commander must decide: upgrade router now or use react-router-dom@^5.3.4 which has a React 18 peer dep workaround.`

- The commander may choose to use `--legacy-peer-deps` for the router and schedule a separate router migration sprint


If v6 already:


bash
npm install react-router-dom@latest 2>/dev/null

Write memory: `step5-complete:router-version-[N]`


---


STEP 6 - Resolve All Peer Conflicts


bash
npm ls 2>&1 | grep -E "WARN|ERR|peer|invalid

🎯 Best For

  • QA engineers
  • Developers writing unit tests
  • Claude users
  • GitHub Copilot users
  • Software engineers

💡 Use Cases

  • Generating test cases for edge conditions
  • Writing integration test suites
  • React component optimization
  • Hook dependency audits

📖 How to Use This Skill

  1. 1

    Install the Skill

    Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.

  2. 2

    Load into Your AI Assistant

    Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.

  3. 3

    Apply React18-Dep-Surgeon to Your Work

    Open your project in the AI assistant and ask it to apply the skill. Start with a small module to verify the output quality.

  4. 4

    Review and Refine

    Review AI suggestions before committing. Run tests, check for regressions, and iterate on the skill output.

❓ Frequently Asked Questions

Does this generate test mocks?

Many testing skills include mock generation. Check the install command and skill content for details.

Is React18-Dep-Surgeon compatible with Cursor and VS Code?

Yes — this skill works with any AI coding assistant including Cursor, VS Code with Copilot, and JetBrains IDEs.

Do I need specific dependencies for React18-Dep-Surgeon?

Check the install command and Works With section. Most code skills only require the AI assistant and your codebase.

How do I install React18-Dep-Surgeon?

Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/react18-dep-surgeon/SKILL.md, ready to use.

Can I customize this skill for my team?

Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.

⚠️ Common Mistakes to Avoid

Not testing edge cases

AI tends to generate happy-path tests. Manually review for boundary conditions.

Skipping validation

Always test AI-generated code changes, even for simple refactors.

Missing dependency updates

Check if the skill requires updated dependencies or new packages.

🔗 Related Skills