Guide · Agent skill
How to use the React Modernization agent skill
Updated · written with AI from the project's own documentation and checked against our catalogue data
The react-modernization skill is a set of instructions that teaches an AI agent how to upgrade React applications, convert class components to hooks, and adopt React 18 features such as createRoot, transitions and Suspense. It is written for developers maintaining older React code who want the agent to follow consistent before-and-after patterns. By the end of this guide you will know how to install the skill, how to ask for help in a way that triggers it, and what to check before you accept its changes.
Quick start
- 1Download the ZIP. Download the react-modernization skill ZIP from this page.
- 2Unzip into the skills folder. Unzip it into ~/.claude/skills/ for all projects, or into your project's .claude/skills/ folder for one project.
- 3Or upload in the Claude apps. In the Claude apps, open Settings, go to Capabilities, and upload the skill under Skills.
- 4Make a branch and run tests. Create a version control branch and confirm your existing tests pass before any changes.
- 5Ask for a specific conversion. Name the file or component and the change you want, such as converting a class to hooks.
- 6Review and test. Read each change, run your tests, and check effects that fetch data or subscribe to events.
What the skill makes the agent do
Agent skills are folders of instructions that an AI agent loads when a task matches the skill's description. This one covers React version upgrades (16 to 17 to 18), migrating class components to function components, and using concurrent features. The main file, SKILL.md, lists breaking changes for React 17 and 18 and gives before-and-after code for state, lifecycle methods, context, higher-order components and root rendering.
When you ask for help modernizing a React codebase, the agent applies these patterns to your code instead of relying only on general knowledge.
- Class state becomes useState calls.
- componentDidMount, componentDidUpdate and componentWillUnmount become useEffect with a cleanup function.
- Context consumers and HOCs become useContext and custom hooks.
- ReactDOM.render becomes createRoot(...).render(...).
- Transitions with useTransition and Suspense boundaries for data loading.
Install the react-modernization skill
The skill is distributed as a ZIP file from this page. Download it, then unzip it into one of two locations depending on how you want to use it:
For all your projects, unzip it into ~/.claude/skills/ so the skill folder sits there as react-modernization.
For a single project, unzip it into the project's .claude/skills/ folder.
If you use the Claude apps instead, open Settings, go to Capabilities, and upload the skill under Skills.
Trigger the skill with natural requests
You do not need a special command. The skill's description tells the agent when to use it, so plain requests work. Good triggers mention modernizing React code, migrating to hooks, or upgrading React versions.
Name the files or components you want changed. The more specific the request, the more useful the output.
- Modernize the class components in src/components/ to function components with hooks.
- Upgrade this React 16 app to React 18 and switch to createRoot.
- Convert DataFetcher.jsx so the request is cancelled when the id prop changes and the component unmounts.
- Replace the HOC in withUser.js with a custom hook.
What the skill covers in practice
The skill's examples are hand-written conversions. Each one shows a class version and a hooks version side by side. The data-fetching example, for instance, uses a cancelled flag inside useEffect so a late response does not update an unmounted component.
For automation, references/details.md lists jscodeshift commands that run React codemods. These include renaming unsafe lifecycle methods, updating React imports, and adding error boundaries. A dry-run flag previews changes before anything is written.
npx jscodeshift -t https://raw.githubusercontent.com/reactjs/react-codemod/master/transforms/rename-unsafe-lifecycles.js --dry --print src/Safety notes: scripts, network and behavior changes
The skill itself runs no scripts and uses no network access. However, the codemod commands in references/details.md fetch transforms from a URL and run npx, so they do use the network when you run them yourself. Review the command and the transform before you run it, and use the dry-run flag first.
Refactors can change behavior even when they compile. The source flags Strict Mode double invocation and effect cleanup timing as areas to check. Run your tests before and after the migration, and review each changed component.
- Use a version control branch so you can revert easily.
- Run the test suite after each conversion step.
- Check effects that fetch data or subscribe to events, since cleanup timing matters.
- Expect Strict Mode to run effects twice in development.
Tips for better results
Migrate one component or folder at a time rather than the whole app in one request. Smaller changes are easier to test and review.
Ask the agent to explain each conversion. Its explanations make it easier to catch mistakes in lifecycle logic.
- Give the agent the file path and the React version you are moving from and to.
- Ask for a dry run of codemods before a real run.
- Ask for tests around a component before converting it.
What people use it for
- Converting a class component with state and lifecycle methods into a function component using useState and useEffect.
- Moving a React 17 app's root render call to createRoot for React 18.
- Replacing a higher-order component that fetches data with a custom hook.
- Previewing jscodeshift codemod changes on a src/ folder with a dry run before applying them.
- Adding Suspense boundaries and useTransition to a search screen so typing stays responsive.
Frequently asked questions
How do I install the react-modernization skill?
Download the ZIP from this page and unzip it into ~/.claude/skills/ for all projects, or into a project's .claude/skills/ folder for one project. In the Claude apps, you can instead upload it under Settings, then Capabilities, then Skills.
Does the react-modernization skill require any software?
The skill itself requires no software. You need a React codebase to modify. The codemod commands in its reference file use npx, which comes with Node.js.
Is the react-modernization skill free?
The source lists the licence as MIT. Check the repository's licence file for the full terms before you reuse or redistribute it.
Does it work with Vue or Angular?
No. The patterns target React, so they do not apply to Vue or Angular projects.
Are the automated codemods safe to run on production code?
Codemods and hand-written refactors can change behavior, for example around Strict Mode double invocation or effect cleanup timing. Run them on a branch, use the dry-run flag first, and rely on your tests before merging.
How does it compare with running React codemods myself?
The skill gives the agent hand-written before-and-after patterns and applies them to your code, and it lists codemod commands for automated work. Running codemods directly gives you the transform without the agent's explanations, so the two approaches suit different needs.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Use this skill if you maintain an older React app built with class components or plan a move from React 16 or 17 to React 18, and you want consistent conversion patterns. Skip it if your project is already on current React and only needs bug fixes, or if you are migrating without tests, since refactors can change behavior.
Download the skill