본문으로 건너뛰기
Skillpedia
테스트5.8k · #14627

detect-static-dependencies

하는 일

이 스킬은 현재 시각, 파일 접근, 콘솔처럼 테스트하기 어려운 시스템 기능 호출을 C# 코드에서 찾습니다. 단위 테스트를 위해 코드를 준비하는 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓단위 테스트를 추가하기 전에 C# 프로젝트의 테스트 가능성을 감사하고 싶을 때.
  • ✓코드가 현재 시각, 파일, 환경 설정, HTTP 호출을 직접 쓰는 곳을 찾아야 할 때.
  • ✓어떤 정적 호출을 먼저 감쌀지, 가장 자주 나오는 것부터 정하고 싶을 때.

스킬 링크

https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/detect-static-dependencies/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/dotnet/skills/blob/main/plugins/dotnet-test/skills/detect-static-dependencies/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“제 C# 프로젝트에서 DateTime.Now, File, HttpClient 호출을 검사해서 어느 것이 가장 많이 나오는지 알려 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 C# 파일에서 이 정적 호출을 검색하고, 개수를 세고, 영향받는 파일을 나열하며, 이를 대체할 수 있는 기존 추상화를 제안합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

Detect Static Dependencies

Scan a C# codebase for calls to hard-to-test static APIs and produce a ranked report showing which statics appear most frequently, which files are most affected, and which abstractions already exist in the .NET ecosystem to replace them.

When to Use

  • Auditing a project's testability before adding unit tests
  • Understanding the scope of static coupling in a legacy codebase
  • Prioritizing which statics to wrap first (highest-frequency wins)
  • Creating a migration plan for incremental testability improvements

Response Guidelines

  • Scale the response to the user's request. A question about a specific category (e.g., "find time statics") should focus on that category with file locations and counts, not produce a full report across all categories.
  • When the user provides a specific file or directory path, scan only that scope — do not expand to the entire solution unless asked.
  • The full structured report format in Step 4 is for comprehensive audit requests. For focused questions, return only the relevant subset (e.g., category summary + affected files for the requested category).

Execution Contract

  • A relative path named in the prompt is enough to start. Discover it with the available file-listing tools and scan it immediately; do not ask the user to provide or re-upload files before both discovery and a content search fail.
  • Start with a recursive, line-numbered content search over eligible .cs files. Do not search only for the static keyword: ambient calls inside LINQ expressions, lambdas, callbacks, and interpolated strings usually have no static modifier.
  • If a file-reading tool fails on a path that listing or search proved exists, classify the failure before retrying. Fall back to another available mechanism such as rg -n, grep, or a shell file reader only for confirmed tool availability, transport, or path-normalization failures and only after verifying the canonical path remains inside the workspace. Stop on content-exclusion, permission/policy, workspace-boundary, or unknown failures. Search output can seed the occurrence ledger; open only the surrounding code needed to verify receiver provenance.
  • Never stop after loading this skill or announcing a scan plan. Return the completed audit in the same response. If every fallback genuinely fails, report the verified partial findings and the exact limitation; do not invent findings or replace the audit with a request to rerun.

When Not to Use

  • The user wants wrappers generated (hand off to generate-testability-wrappers)
  • The user wants mechanical migration done (hand off to migrate-static-to-wrapper)
  • The statics are already behind interfaces or TimeProvider
  • The code is not C# / .NET

Inputs

Input Required Description
Target path No A file, directory, project (.csproj), or solution (.sln) to scan. Defaults to the current workspace.
Exclusion patterns No Glob patterns to skip (e.g., **/obj/**, **/Migrations/**)
Category filter No Limit to specific categories: time, filesystem, environment, network, console, process

Workflow

Step 1: Determine scan scope

Resolve the target to a set of .cs files:

  • Treat a prompt-named workspace-relative path as the target; locate it rather than asking the user for an absolute path.
  • If omitted, scan every eligible .cs file under the current workspace; do not pick one project and silently omit its siblings.
  • If a .cs file, scan that single file.
  • If a directory, scan all .cs files recursively (excluding obj/, bin/).
  • If a .csproj, find its directory and scan .cs files within.
  • If a .sln, parse it, find all project directories, and scan .cs files across all projects.

Always exclude obj/, bin/, and any user-specified exclusion patterns.

Step 2: Search for static dependency patterns

Scan each file for calls matching these categories:

Treat pattern matches as candidates, not findings. Before counting an instance call, trace how its receiver enters the class. A collaborator supplied through a constructor, parameter, property, or dependency injection (DI) is already a test seam. In particular, an injected HttpClient is testable with a controlled HttpMessageHandler; do not count its calls or recommend replacing it merely because the injected type is concrete.

| Category | Patterns to search for | Recom

자주 묻는 질문

C#이 아닌 코드에도 되나요?

아니요. 이 스킬은 C#과 .NET 코드만 대상으로 합니다.

제 코드를 바꾸나요?

이 스킬은 찾고 보고하는 데 초점을 맞춥니다. 호출을 감싸는 작업은 별도의 스킬이 합니다.

폴더 하나만 검사할 수 있나요?

네. 파일이나 폴더 경로를 주면 그 부분의 코드만 검사합니다.

상세 정보

작성자의 원본 설명

ACTIVATION PREREQUISITE: the request or discovered target must explicitly identify C#, .NET, `.cs`, or `.csproj`; otherwise stay dormant without invoking this skill. USE FOR: locating System.DateTime.Now/UtcNow, System.IO.File/Directory, System.Environment, HttpClient, Console, or Process usage in C#; auditing C# code for hard-to-test framework dependencies; or verifying those C# calls are already abstracted. DO NOT USE FOR: any target lacking the activation prerequisite; generating wrappers (use generate-testability-wrappers); migrating code (use migrate-static-to-wrapper); or general code re

repo: dotnet/skills

인기도

GitHub 스타
5.8k
순위
#14627
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬