Skip to main content
subagent official · GitHub

react18-dep-surgeon — GitHub Copilot subagent: setup and overview

A subagent that upgrades dependencies from React 16/17 strictly to 18.3.1, bumps compatible libraries, and halts if Enzyme is detected.

Install into GitHub Copilot · Manually: put the files in place All methods and platforms ↓
.github/agents/react18-dep-surgeon.agent.md
Open on GitHub

What react18-dep-surgeon does

This subagent executes dependencies migration from React 16 or 17. Its target is an exact pin to [email protected] and [email protected] without caret ranges. Precision matters here. The 18.3.1 release serves as a checkpoint to surface upcoming React 19 deprecations.

The workflow systematically checks the package tree and bumps dependent tools. It upgrades React Testing Library to v14 for createRoot compatibility. It also installs compatible releases for Apollo Client and Emotion. When finding react-router-dom v5, execution pauses: upgrading to v6 brings breaking route changes and requires manual confirmation from the main agent.

Enzyme acts as a hard stop. Because Enzyme lacks React 18 support, finding it triggers an immediate NO-GO verdict to prevent unfixable test failures. The run completes with an npm run build smoke check and a final readiness report.

What it helps with

  • pin react and react-dom to version 18.3.1 without wildcards
  • detect incompatible Enzyme packages before test suites break
  • upgrade React Testing Library to v14 for createRoot support
  • catch peer dependency conflicts when migrating from React 16 or 17

Example prompts for the agent

  • Run the react18-dep-surgeon subagent to upgrade dependencies to React 18.3.1
  • Check package.json for Enzyme and peer conflicts using react18-dep-surgeon
  • Execute the dependency upgrade checklist with react18-dep-surgeon

How to install react18-dep-surgeon

Manually: put the files in place

.github/agents/react18-dep-surgeon.agent.md

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about react18-dep-surgeon

How to install react18-dep-surgeon in GitHub Copilot?

Create the subagent configuration file at .github/agents/react18-dep-surgeon.agent.md. GitHub Copilot will then be able to invoke this subagent during multi-agent workflows.

Why does it pin React strictly to 18.3.1 instead of latest?

Pinning to 18.3.1 provides a deliberate checkpoint that displays deprecation warnings ahead of React 19. It avoids using caret ranges like ^18 so dependencies do not shift unexpectedly.

What happens if Enzyme is detected in package.json?

The subagent issues a hard blocker and returns NO-GO because Enzyme lacks a React 18 adapter. Tests must be migrated to React Testing Library before continuing the dependency update.

Source text

react18-dep-surgeon.agent.md · MIT
---
name: react18-dep-surgeon
description: '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 React 18 support). Returns GO/NO-GO to commander.'
tools: ['vscode/memory', 'edit/editFiles', 'execute/getTerminalOutput', 'execute/runInTerminal', 'read/terminalLastCommand', 'read/terminalSelection', 'search', 'web/fetch']
user-invocable: false
---

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

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

## Memory Protocol

Read prior state:

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

Write after each step:

```
#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 [email protected] [email protected]

# 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 [email protected] [email protected] --legacy-peer-deps` as last resort (document why).

Write memory: `step1-complete:[email protected]`

---

## 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/[email protected]` 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|unmet"
```

For each conflict:

1. Identify the conflicting package
2. Check if it has React 18 support: `npm info <package> peerDependencies`
3. Try: `npm install <package>@latest`
4. Re-check

**Rules:**

- Never `--force`
- `--legacy-peer-deps` allowed only if the package has no React 18 release yet - must document it

---

## STEP 7 - React 18 Concurrent Mode Compatibility Check

Some packages need `useSyncExternalStore` for React 18 concurrent mode. Check Redux if used:

```bash
npm ls react-redux 2>/dev/null | head -3
# react-redux@8+ supports React 18 concurrent mode via useSyncExternalStore
# react-redux@7 works with React 18 legacy root but not concurrent mode
```

---

## STEP 8 - Clean Install + Verification

```bash
rm -rf node_modules package-lock.json
npm install
npm ls 2>&1 | grep -E "WARN|ERR|peer" | wc -l
```

**Gate:** 0 errors.

---

## STEP 9 - Smoke Check

```bash
# Quick build - will fail if class migration needed, that's OK
# But catch dep-level failures here not in the class surgeon
npm run build 2>&1 | grep -E "Cannot find module|Module not found|SyntaxError" | head -10
```

Only dep-resolution errors are relevant here. Broken React API usage errors are expected - the class surgeon handles those.

---

## GO / NO-GO

**GO if:**

- `[email protected]` ✅ (exact)
- `[email protected]` ✅ (exact)
- `@testing-library/[email protected]` ✅
- `npm ls` → 0 peer errors ✅
- Enzyme NOT present (or already rewritten) ✅

**NO-GO if:**

- Enzyme still installed (hard block)
- React version != 18.3.1
- Peer errors remain unresolved
- react-router v5 present with unresolved conflict (flag, await commander decision)

Report GO/NO-GO to commander with exact installed versions.

© github · MIT · github/awesome-copilot

Similar subagents

All subagents for Frontend and UI →
remotion-upgrade remotion-dev Upgrades Remotion and related dependencies to the latest stable release. It keeps package versions synchronized and updates project skills automatically. CX Codex +1 191,900installs dependency-checker davila7 A PostToolUse hook that runs a package audit after you touch a dependency file, so outdated or vulnerable packages surface right away. 2,314installs frontend-developer VoltAgent Community Subagent for building complete frontend applications with React 18+, Vue 3+, and Angular 15+. Handles component architecture, state management, testing, and accessibility. 40,905installs ui-ux-designer Seth Hobson This subagent creates interfaces, wireframes, and design systems. Use it for user flows, accessibility work, and consistent UI patterns. CX Codex 27,069installs fullstack-developer VoltAgent Community This subagent carries a feature across the database, API, and frontend layers. Use it when one change needs a consistent end-to-end implementation. 18,117installs javascript-pro Seth Hobson A subagent for modern JavaScript, async code, and Node.js APIs. Use it to debug event-loop issues, review complex patterns, and plan TypeScript migrations. CX Codex 4,974installs ui-designer VoltAgent Community Designs visual interfaces, builds component libraries, and creates handoff documentation. Ideal when code needs structured UI states and design tokens. 1,979installs ui-designer Seth Hobson Designs interfaces, components, and responsive layouts with implementation in mind. Use it when building screens, forms, tables, or a design system. CX Codex 1,979installs

From the same set949

The whole set →
react19-dep-surgeon Walks a project's dependencies up to React 19 step by step: core, testing-library, Apollo and Emotion, then peer conflicts, ending in a GO/NO-GO verdict. ★ 40,451repo stars react19-commander Orchestrates full React 18 to React 19 migrations. It triggers dedicated subagents sequentially, enforces stage gates, and persists progress in memory. ★ 40,451repo stars react19-auditor Scans a codebase for React 19 migration issues and writes a prioritized report. Use it to review the work ahead before upgrading. ★ 40,451repo stars react18-test-guardian A subagent that fixes failing tests after the move to React 18.3.1 and keeps looping until nothing fails. ★ 40,451repo stars react18-commander A GitHub Copilot subagent that coordinates a React 16/17 to 18.3.1 upgrade, from code audit and dependency changes to class component fixes and test checks. ★ 40,451repo stars react18-class-surgeon A GitHub Copilot subagent that moves class components from React 16/17 to React 18.3.1, replacing unsafe lifecycle methods and legacy APIs. ★ 40,451repo stars react18-batching-fixer Finds and repairs React 18 automatic batching regressions in class components. It spots stale this.state reads after await and inserts flushSync when intermediate UI updates are required. ★ 40,451repo stars react18-auditor Scans React 16 and 17 class components for deprecations before moving to React 18.3.1. It reads code without editing files and outputs results to .github/react18-audit.md. ★ 40,451repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor