modernize

Applies version-gated TypeScript syntax and API upgrades to legacy code patterns.

4|1|Updated Jul 31, 2025
One-click install
npx skills add https://github.com/alvis/.agents --skill modernize-alvis
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: modernize
Source: https://github.com/alvis/.agents/tree/main/plugins/coding/skills/modernize
Command: npx skills add https://github.com/alvis/.agents --skill modernize-alvis

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Codebases accumulate legacy TypeScript constructs that newer compiler versions already support replacing, but manually tracking which features apply to your project's exact TypeScript and Node.js versions is tedious and error-prone. ## Core Features & Use Cases - Version-gated feature detection: Reads the project's TypeScript version, Node.js engine, and tsconfig target/module/lib to determine exactly which modern features from the catalog (TS 5.0 through 6.0) are safe to apply. - Pattern-based transforms: Scans target files with grep-compatible detection patterns from versioned example files, applies before/after transforms, and respects documented edge cases where transforms must not run. - Verified application with dry-run: Supports --dry-run previews, then applies edits file-by-file and validates with npx tsc --noEmit and the project test suite, reverting any transform that fails verification. - Use Case: Point it at a legacy src/ directory on a TypeScript 5.5 project and it replaces manual reduce grouping with Object.groupBy, spread-then-sort with toSorted(), and explicit type predicates with inferred ones — all verified by the type checker. ## Quick Start Ask the agent to modernize the src directory with the modernize skill, optionally adding --dry-run to preview proposed changes first.

Frequently Asked Questions about modernize

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I upgrade legacy TypeScript code to modern syntax automatically?

Run the modernize skill on a file, directory, or glob. It detects your TypeScript and Node.js versions, selects applicable features from its catalog, scans for legacy patterns, applies transforms, and verifies with tsc --noEmit and your test suite.

How can I preview TypeScript modernization changes before applying them?

Pass the --dry-run flag with your target area. The skill reports each match's file, line, current pattern, proposed replacement, and motivating feature without editing anything, and skips the verification step.

Does the modernize skill upgrade TypeScript versions or dependencies?

No. Dependency upgrades, package.json changes, tsconfig modifications, and TypeScript version bumps are explicitly out of scope. It only rewrites source code to use features your already-installed versions support.

Can I preview features from a newer TypeScript version before upgrading?

Yes. Use --target-version=X.Y to override the detected TypeScript version, which lets you preview which transforms would apply after a future compiler upgrade without changing the project.

What happens if a modernization transform breaks the build?

The skill runs tsc --noEmit and the project tests after edits. If verification fails, it identifies the offending transform, reverts it, records it as skipped with the reason, and re-runs the checks until everything passes.

When should I not use automated TypeScript modernization?

Avoid it for architectural refactoring or business-logic changes (use a refactoring skill instead), and it rejects configuration files, binary files, gitignored or vendor files, and areas with no valid source files.