RefactorDependency

Refactor one dependency type into injectable abstractions across 1-2 modules.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/fnoritomi/tabulador-dados-abertos --skill refactordependency
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: RefactorDependency
Source: https://github.com/fnoritomi/tabulador-dados-abertos/tree/main/.agent/skills/refactor-dependency
Command: npx skills add https://github.com/fnoritomi/tabulador-dados-abertos --skill refactordependency

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps teams decouple code from concrete dependencies by introducing explicit dependency injections, improving testability and maintainability without altering public APIs.

Core Features & Use Cases

  • Isolate one dependency type per iteration to minimize risk.
  • Limit changes to 1-2 modules to preserve behavior and ease review.
  • Introduce adapters or DI contexts while keeping public API unchanged.
  • Use cases: refactoring fetch to a platform abstraction, swapping localStorage for an injected storage, facilitating testing by supplying mocks.

Quick Start

To begin, select a single dependency type (for example, fetch or localStorage), identify the files that use it, implement an adapter or constructor parameter injection, update imports and constructor calls minimally, then run tests and a build to verify no public API changes.

Frequently Asked Questions about RefactorDependency

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

FAQPage Schema
How do I refactor hard-coded dependencies like fetch or localStorage for unit testing?

To refactor hard-coded dependencies like fetch or localStorage for unit testing, replace them with injectable abstractions such as constructor parameters or adapters. This isolates one dependency type per iteration to minimize risk while keeping public APIs unchanged and tests green.

What is the safest way to introduce dependency injection in an existing TypeScript project?

The safest way to introduce dependency injection in a TypeScript project is limiting changes to one dependency type and at most two modules. By preferring constructor or function parameter injection, you ensure predictable refactoring with minimal call-site changes and preserved behavior.

Can I swap concrete dependencies with injected abstractions without altering public APIs?

Yes, you can swap concrete dependencies with injected abstractions without altering public APIs by using adapters or DI contexts. This approach decouples code from specific implementations while preserving the external interface and keeping existing tests green.

Does dependency injection refactoring limit changes to a specific number of modules?

Dependency injection refactoring limits changes to at most two modules per iteration. This narrow scope ensures predictable refactoring in real-world projects by minimizing risk, preserving behavior, and making code reviews easier while updating imports and constructor calls.

When should I not use constructor parameter injection for decoupling code?

You should not use constructor parameter injection when refactoring scope exceeds one dependency type or two modules. Broad changes risk breaking public APIs and test suites; this approach requires minimal call-site updates and isolated adapters to maintain predictable behavior.