Lexical Upgrade Skill
This skill automates the incremental upgrade of Lexical dependencies while synchronizing copied playground code.
Workflow
Phase 1: Version Discovery
- Read the current Lexical version from
libraries/react-components/package.json
- Determine target version:
- If user provided version as argument, use that
- Otherwise, find next available version:
- Use
npm view lexical versions --json to get all versions
- Filter out pre-release versions (containing -next, -nightly, -alpha, -beta, -rc)
- Find next patch version (e.g., 0.14.3 → 0.14.4)
- If no more patches, suggest next minor (e.g., 0.14.x → 0.15.0)
- Display upgrade plan showing:
- Current version
- Target version
- All packages that will be updated
- Ask for confirmation to proceed
Phase 1.5: Breaking Change Scan
- Load breaking changes for target version from Lexical's changelog
- For each breaking change in target version:
- Display change type, description, and severity
- If change has a pattern to detect, scan codebase:
- Use Grep to search for matching patterns in affected files
- Report files that match the pattern
- If auto-fixable:
- Show the fix that will be applied
- Ask if user wants to auto-fix now or later
- If not auto-fixable:
- Show recommendation for manual fix
- Ask user to confirm they've reviewed or want to proceed
- Display summary:
- Breaking changes in target version
- Files potentially affected
- Actions user should take
- Offer to proceed with upgrade or abort
Phase 2: Playground Repository Health Check
- Check the Lexical mono repo (including playground) repo. Ask the user for the location if you don't know it:
- ✓ Verify repo exists
- ✓ Check
git status - warn if uncommitted changes
- ✓ Check
git branch --show-current - warn if not on main/master
- ✓ Check
git fetch --dry-run - suggest pull if behind
- ✓ Verify target version tag exists (try both
v{version} and {version})
- ✓ Check if playground files in mapping exist in target version
- If any checks fail:
- Show specific error and suggested fix command
- Example fix: "Run: cd /Users/jonas/dev/explore/lexical && git checkout main"
- Ask user to fix before proceeding or skip playground sync
Phase 2.5: File Discovery
- Load auto-discovery configuration from
.claude/skills/upgrade-lexical/file-mapping.json
- If auto-discovery is enabled:
- Use Glob to find files matching patterns (e.g.,
libraries/react-components/src/**/*.{ts,tsx})
- Use Grep to find files importing from
@lexical/ or lexical
- Combine with known-file-groups and custom-nodes from file-mapping.json
- Create comprehensive checklist:
- Main editor/display components
- Custom nodes (6 nodes)
- Plugins (7 plugins)
- Utilities
- Any other files with Lexical imports
- Display discovered files and ask user to confirm coverage
- Save discovered file list for verification in Phase 5
Phase 3: Playground Change Detection
Read the file mapping from .claude/skills/upgrade-lexical/file-mapping.json
For each file in the tracked-files mapping:
- Check if playground file exists in both current and target versions
- Run
git diff v{current}..v{target} -- {playground_path} to see changes
- If changes exist:
- Analyze diff and classify change type:
- 🐛 Bug fix (small logic changes)
- ✨ Feature (new functions/exports)
- ♻️ Refactor (structure changes)
- 💥 Breaking change (API signature changes)
- 🎨 Style (formatting only)
- Show change summary with impact assessment
- Display the diff to the user
- For "exact-copy" files: Ask if user wants to auto-apply the changes
- For "manual-review" files: Show changes for review only, don't auto-apply
- If no changes: Note that file is already in sync
Phase 4: Apply Playground Changes
- For approved "exact-copy" files:
- Read the file content from the target version:
cd $LEXICAL_REPO && git show v{target}:{playground_path}
- Write to the local file (preserving any copyright header if present)
- Note which files were updated
Phase 5: Update Dependencies
Update Lexical dependencies in libraries/react-components/package.json:
- lexical
- @lexical/code
- @lexical/link
- @lexical/list
- @lexical/react
- @lexical/rich-text
- @lexical/selection
- @lexical/utils
Update Lexical dependency in apps/blog/package.json:
Check pnpm-workspace.yaml for any version overrides that might conflict:
- If overrides exist for Lexical packages, warn the user
- Ask if they should be removed or updated
Run pnpm install to update the lockfile
Phase 6: Verification
Build the project:
- Run
pnpm -w build
- If errors occur:
- Load error-patterns.json
- Match error output against known patterns
- For each matched pattern:
- Show error description and cause
- Show suggested fix
- If auto-fixable, offer to apply fix automatically
- If not auto-fixable, show code example and recommendation
- If no patterns match, show generic troubleshooting steps
- Ask how to proceed:
- Apply suggested fixes and retry build
- Skip this version and try next
- Fix manually and continue
- Abort upgrade
Run tests:
- Run
pnpm -w test
- If failures occur:
- Check for snapshot update needs
- Match against test-related error patterns
- Show test failure summary
- Ask how to proceed:
- Update snapshots if cosmetic changes
- Fix manually if functional issues
- Skip this version
Run linter:
- Run
pnpm -w lint
- If errors occur, display them and ask how to proceed
Phase 7: Commit
Stage all changes:
libraries/react-components/package.json
apps/blog/package.json
pnpm-lock.yaml
- Any updated third-party playground files
Show git diff of staged changes for review
Create commit with message following repo conventions:
chore(lexical): Upgrade from {old} to {new}
- Updated lexical packages in react-components and blog
- Synced getSelectedNode.ts from playground ({changes|no changes})
- All tests passing
Commit the changes
Phase 8: Iteration
- Ask if user wants to continue upgrading to the next version
- If yes, repeat from Phase 1 with the newly upgraded version as current
Edge Cases
- Playground repo not on main: Show specific error and fix command (Phase 2)
- Playground repo behind: Suggest
git fetch && git pull with full command (Phase 2)
- Playground repo uncommitted changes: Warn and suggest stashing or committing (Phase 2)
- No target version found: Show available versions and ask user to specify one (Phase 1)
- Build/test failures: Match against error-patterns.json, show fixes, offer auto-fix (Phase 6)
- Override conflicts: Check pnpm-workspace.yaml for version overrides (Phase 5)
- Breaking changes detected: Show in Phase 1.5, offer auto-fix before upgrading
- Missing tags: Try both
v{version} and {version} formats (Phase 2)
- File not found in playground: Warn if mapped file doesn't exist in target version (Phase 3)
- Auto-discovery finds no files: Warn user, fall back to known-file-groups (Phase 2.5)
- Multiple error patterns match: Show all matching patterns and fixes (Phase 6)
Version Selection Logic
When auto-detecting the next version:
- Parse current version (e.g., "0.14.3")
- Get all available versions from npm
- Filter out pre-release versions
- Find next patch in same minor (0.14.4, 0.14.5, etc.)
- If no patches available, find next minor (0.15.0)
- If no minors available, show available versions and ask user
File Sync Types
Safety Checks
- Detect breaking changes before upgrading (Phase 1.5)
- Always verify playground repo is clean and up-to-date (Phase 2)
- Auto-discover all affected files (Phase 2.5)
- Show all diffs before applying with impact analysis (Phase 3)
- Run build/test/lint before committing (Phase 6)
- Pattern-match errors and offer fixes (Phase 6)
- Ask for confirmation at key decision points
- Commit each version upgrade separately for easy rollback
- Maintain version consistency across all Lexical packages
Example Usage
# Upgrade to next available version (auto-detect)
/upgrade-lexical
# Upgrade to specific version
/upgrade-lexical 0.15.0
# Upgrade through multiple versions (will prompt after each)
/upgrade-lexical 0.20.0
Data Files
file-mapping.json
Enhanced configuration file with:
- tracked-files: Playground files to sync (backwards compatible with old format)
- auto-discover: Patterns for finding all Lexical-related files
- custom-nodes: List of custom node classes with metadata
- known-file-groups: Main components, plugins, utilities
- validation: Required/optional methods for custom nodes
Notes
- All version changes are committed separately for easy rollback
- The skill asks for confirmation at key decision points
- Playground changes are shown as diffs before applying with impact analysis
- Manual review is required for adapted files
- The skill will not automatically push commits - user must do that manually
- Breaking changes are detected proactively before upgrading
- Error patterns provide specific fix suggestions
- File discovery ensures no Lexical imports are missed
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: upgrade-lexical3description: Incrementally upgrade Lexical dependencies and sync copied playground code Use when this capability is needed.4---56# Lexical Upgrade Skill78This skill automates the incremental upgrade of Lexical dependencies while synchronizing copied playground code.910## Workflow1112### Phase 1: Version Discovery13141. Read the current Lexical version from `libraries/react-components/package.json`152. Determine target version:16 - If user provided version as argument, use that17 - Otherwise, find next available version:18 - Use `npm view lexical versions --json` to get all versions19 - Filter out pre-release versions (containing -next, -nightly, -alpha, -beta, -rc)20 - Find next patch version (e.g., 0.14.3 → 0.14.4)21 - If no more patches, suggest next minor (e.g., 0.14.x → 0.15.0)223. Display upgrade plan showing:23 - Current version24 - Target version25 - All packages that will be updated264. Ask for confirmation to proceed2728### Phase 1.5: Breaking Change Scan29305. Load breaking changes for target version from Lexical's changelog316. For each breaking change in target version:32 - Display change type, description, and severity33 - If change has a pattern to detect, scan codebase:34 - Use Grep to search for matching patterns in affected files35 - Report files that match the pattern36 - If auto-fixable:37 - Show the fix that will be applied38 - Ask if user wants to auto-fix now or later39 - If not auto-fixable:40 - Show recommendation for manual fix41 - Ask user to confirm they've reviewed or want to proceed427. Display summary:43 - Breaking changes in target version44 - Files potentially affected45 - Actions user should take468. Offer to proceed with upgrade or abort4748### Phase 2: Playground Repository Health Check49509. Check the Lexical mono repo (including playground) repo. Ask the user for the location if you don't know it:51 - ✓ Verify repo exists52 - ✓ Check `git status` - warn if uncommitted changes53 - ✓ Check `git branch --show-current` - warn if not on main/master54 - ✓ Check `git fetch --dry-run` - suggest pull if behind55 - ✓ Verify target version tag exists (try both `v{version}` and `{version}`)56 - ✓ Check if playground files in mapping exist in target version5710. If any checks fail:58 - Show specific error and suggested fix command59 - Example fix: "Run: cd /Users/jonas/dev/explore/lexical && git checkout main"60 - Ask user to fix before proceeding or skip playground sync6162### Phase 2.5: File Discovery636411. Load auto-discovery configuration from `.claude/skills/upgrade-lexical/file-mapping.json`6512. If auto-discovery is enabled:66 - Use Glob to find files matching patterns (e.g., `libraries/react-components/src/**/*.{ts,tsx}`)67 - Use Grep to find files importing from `@lexical/` or `lexical`68 - Combine with known-file-groups and custom-nodes from file-mapping.json69 - Create comprehensive checklist:70 - Main editor/display components71 - Custom nodes (6 nodes)72 - Plugins (7 plugins)73 - Utilities74 - Any other files with Lexical imports7513. Display discovered files and ask user to confirm coverage7614. Save discovered file list for verification in Phase 57778### Phase 3: Playground Change Detection798015. Read the file mapping from `.claude/skills/upgrade-lexical/file-mapping.json`818216. For each file in the tracked-files mapping:83 - Check if playground file exists in both current and target versions84 - Run `git diff v{current}..v{target} -- {playground_path}` to see changes85 - If changes exist:86 - Analyze diff and classify change type:87 - 🐛 Bug fix (small logic changes)88 - ✨ Feature (new functions/exports)89 - ♻️ Refactor (structure changes)90 - 💥 Breaking change (API signature changes)91 - 🎨 Style (formatting only)92 - Show change summary with impact assessment93 - Display the diff to the user94 - For "exact-copy" files: Ask if user wants to auto-apply the changes95 - For "manual-review" files: Show changes for review only, don't auto-apply96 - If no changes: Note that file is already in sync9798### Phase 4: Apply Playground Changes9910017. For approved "exact-copy" files:101 - Read the file content from the target version: `cd $LEXICAL_REPO && git show v{target}:{playground_path}`102 - Write to the local file (preserving any copyright header if present)103 - Note which files were updated104105### Phase 5: Update Dependencies10610718. Update Lexical dependencies in `libraries/react-components/package.json`:108 - lexical109 - @lexical/code110 - @lexical/link111 - @lexical/list112 - @lexical/react113 - @lexical/rich-text114 - @lexical/selection115 - @lexical/utils11611719. Update Lexical dependency in `apps/blog/package.json`:118 - lexical11912020. Check `pnpm-workspace.yaml` for any version overrides that might conflict:121 - If overrides exist for Lexical packages, warn the user122 - Ask if they should be removed or updated12312421. Run `pnpm install` to update the lockfile125126### Phase 6: Verification12712822. Build the project:129 - Run `pnpm -w build`130 - If errors occur:131 - Load error-patterns.json132 - Match error output against known patterns133 - For each matched pattern:134 - Show error description and cause135 - Show suggested fix136 - If auto-fixable, offer to apply fix automatically137 - If not auto-fixable, show code example and recommendation138 - If no patterns match, show generic troubleshooting steps139 - Ask how to proceed:140 - Apply suggested fixes and retry build141 - Skip this version and try next142 - Fix manually and continue143 - Abort upgrade14414523. Run tests:146 - Run `pnpm -w test`147 - If failures occur:148 - Check for snapshot update needs149 - Match against test-related error patterns150 - Show test failure summary151 - Ask how to proceed:152 - Update snapshots if cosmetic changes153 - Fix manually if functional issues154 - Skip this version15515624. Run linter:157 - Run `pnpm -w lint`158 - If errors occur, display them and ask how to proceed159160### Phase 7: Commit16116225. Stage all changes:163 - `libraries/react-components/package.json`164 - `apps/blog/package.json`165 - `pnpm-lock.yaml`166 - Any updated third-party playground files16716826. Show git diff of staged changes for review16917027. Create commit with message following repo conventions:171172 ```173 chore(lexical): Upgrade from {old} to {new}174175 - Updated lexical packages in react-components and blog176 - Synced getSelectedNode.ts from playground ({changes|no changes})177 - All tests passing178 ```17918028. Commit the changes181182### Phase 8: Iteration18318432. Ask if user wants to continue upgrading to the next version18533. If yes, repeat from Phase 1 with the newly upgraded version as current186187## Edge Cases188189- **Playground repo not on main**: Show specific error and fix command (Phase 2)190- **Playground repo behind**: Suggest `git fetch && git pull` with full command (Phase 2)191- **Playground repo uncommitted changes**: Warn and suggest stashing or committing (Phase 2)192- **No target version found**: Show available versions and ask user to specify one (Phase 1)193- **Build/test failures**: Match against error-patterns.json, show fixes, offer auto-fix (Phase 6)194- **Override conflicts**: Check pnpm-workspace.yaml for version overrides (Phase 5)195- **Breaking changes detected**: Show in Phase 1.5, offer auto-fix before upgrading196- **Missing tags**: Try both `v{version}` and `{version}` formats (Phase 2)197- **File not found in playground**: Warn if mapped file doesn't exist in target version (Phase 3)198- **Auto-discovery finds no files**: Warn user, fall back to known-file-groups (Phase 2.5)199- **Multiple error patterns match**: Show all matching patterns and fixes (Phase 6)200201## Version Selection Logic202203When auto-detecting the next version:2042051. Parse current version (e.g., "0.14.3")2062. Get all available versions from npm2073. Filter out pre-release versions2084. Find next patch in same minor (0.14.4, 0.14.5, etc.)2095. If no patches available, find next minor (0.15.0)2106. If no minors available, show available versions and ask user211212## File Sync Types213214- **exact-copy**: File is copied directly from playground with no modifications215 - Can be auto-applied with user approval216 - Preserves copyright headers217218- **manual-review**: File is adapted from playground with custom changes219 - Show diff but never auto-apply220 - User must manually review and merge changes221222## Safety Checks223224- Detect breaking changes before upgrading (Phase 1.5)225- Always verify playground repo is clean and up-to-date (Phase 2)226- Auto-discover all affected files (Phase 2.5)227- Show all diffs before applying with impact analysis (Phase 3)228- Run build/test/lint before committing (Phase 6)229- Pattern-match errors and offer fixes (Phase 6)230- Ask for confirmation at key decision points231- Commit each version upgrade separately for easy rollback232- Maintain version consistency across all Lexical packages233234## Example Usage235236```bash237# Upgrade to next available version (auto-detect)238/upgrade-lexical239240# Upgrade to specific version241/upgrade-lexical 0.15.0242243# Upgrade through multiple versions (will prompt after each)244/upgrade-lexical 0.20.0245```246247## Data Files248249### file-mapping.json250251Enhanced configuration file with:252253- **tracked-files**: Playground files to sync (backwards compatible with old format)254- **auto-discover**: Patterns for finding all Lexical-related files255- **custom-nodes**: List of custom node classes with metadata256- **known-file-groups**: Main components, plugins, utilities257- **validation**: Required/optional methods for custom nodes258259## Notes260261- All version changes are committed separately for easy rollback262- The skill asks for confirmation at key decision points263- Playground changes are shown as diffs before applying with impact analysis264- Manual review is required for adapted files265- The skill will not automatically push commits - user must do that manually266- Breaking changes are detected proactively before upgrading267- Error patterns provide specific fix suggestions268- File discovery ensures no Lexical imports are missed269270---271> Converted and distributed by [TomeVault](https://tomevault.io/claim/dossierhq) — claim your Tome and manage your conversions.272<!-- tomevault:4.0:skill_md:2026-04-11 -->