migrate-static-to-wrapper

Migrate static dependency call sites to injected wrappers within a bounded code scope.

1|Updated May 21, 2026
One-click install
npx skills add https://github.com/1k-off/umbraco-observability-playground --skill migrate-static-to-wrapper
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: migrate-static-to-wrapper
Source: https://github.com/1k-off/umbraco-observability-playground/tree/main/.agents/skills/migrate-static-to-wrapper
Command: npx skills add https://github.com/1k-off/umbraco-observability-playground --skill migrate-static-to-wrapper

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Replacing hard-coded static dependency calls (like DateTime or File APIs) is difficult to test and reason about, so this Skill converts them into injected wrappers or built-in abstractions.

Core Features & Use Cases

  • Time abstraction migration: Convert DateTime.Now / UtcNow / Today / DateTimeOffset.UtcNow into TimeProvider calls suitable for deterministic testing.
  • I/O abstraction migration: Convert File.* and Directory.* calls to IFileSystem equivalents for safer, mockable filesystem access.
  • DI + call-site refactor: Add constructor injection for the new dependency, update DI registration expectations, and mechanically replace call sites within a bounded scope.

Quick Start

Ask the AI to migrate DateTime.UtcNow to TimeProvider.GetUtcNow() across the src/MyProject/Services/ namespace using constructor injection and update all affected tests so the solution builds.

Frequently Asked Questions about migrate-static-to-wrapper

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

FAQPage Schema
How do I refactor static DateTime calls to TimeProvider for deterministic testing?

To refactor static DateTime calls to TimeProvider, mechanically replace call sites like DateTime.UtcNow with TimeProvider.GetUtcNow(), add constructor injection for the dependency, and update DI registration and tests to verify the solution builds.

What is the best way to replace File and Directory static calls with injectable abstractions?

Replacing File and Directory static calls involves converting them to IFileSystem equivalents for safer, mockable filesystem access. The process adds constructor injection, updates using directives, and verifies DI registration within a bounded code scope.

Can I migrate static dependencies incrementally across a single namespace?

Yes, you can migrate static dependencies incrementally across a single namespace. The refactoring applies mechanical codemod-style replacements to a bounded code scope, targeting one file, project, or namespace at a time to ensure safe transitions.

Why does migrating static dependency call sites improve code testability?

Migrating static dependency call sites improves code testability by replacing hard-coded static dependencies with injected wrappers or built-in abstractions, allowing you to mock filesystem access and control time during deterministic testing.

Do I need to update dependency injection registration when refactoring static calls?

Yes, you must update dependency injection registration when refactoring static calls. Adding constructor or ambient injection for new abstractions requires updating DI registration expectations to successfully resolve dependencies and verify the build.