Files
2026-07-10 02:19:48 +00:00

185 lines
7.6 KiB
YAML

name: detect-static-dependencies
description: Evaluates the dotnet-test/detect-static-dependencies skill
type: capability
config:
timeout: 5m
stimuli:
- name: Identify static dependencies in a multi-class project
prompt: >
I have a .NET project at StaticHeavy/ that I suspect has a lot of
hard-to-test static calls. Can you scan it and tell me what's making it
hard to unit test?
environment:
files:
- src: ./fixtures/static-heavy-project
dest: StaticHeavy
graders:
- type: output-matches
config:
pattern: (DateTime\.UtcNow|DateTime\.Now)
- type: output-matches
config:
pattern: (File\.|file system|filesystem|IFileSystem)
- type: output-matches
config:
pattern: (Environment\.|environment variable)
- type: output-matches
config:
pattern: (Console\.|console)
- type: output-matches
config:
pattern: (HttpClient|http client)
- type: exit-success
- type: prompt
rubric:
- Identified DateTime.UtcNow and DateTime.Now as frequently used static dependencies
- Identified File.WriteAllText, File.ReadAllText, File.Exists, and File.AppendAllText as file system statics
- Identified Environment.GetEnvironmentVariable as environment static usage
- Identified Console.WriteLine as untestable console output
- Identified new HttpClient() as a hard-to-test network dependency
- Ranked or prioritized the static categories by frequency or migration ease
- Recommended a concrete next step such as wrapping the statics or adopting TimeProvider
- name: Detect time-related statics and recommend TimeProvider
prompt: >
My OrderProcessor.cs uses DateTime.UtcNow in several places and it's
impossible to write deterministic tests. Can you scan my entire project
for all time-related static dependencies, show me where each one is
with file locations and counts, and recommend how to make them testable?
environment:
files:
- src: ./fixtures/static-heavy-project
dest: StaticHeavy
graders:
- type: output-matches
config:
pattern: (DateTime\.UtcNow|DateTime\.Now)
- type: output-matches
config:
pattern: (TimeProvider|time provider|ISystemClock|abstraction)
- type: output-matches
config:
pattern: \.cs
- type: output-matches
config:
pattern: \d+.*(call|site|occurrence|instance|usage|found|time)|([Cc]ount|[Tt]otal).*\d+
- type: exit-success
- type: prompt
rubric:
- Found all DateTime.UtcNow and DateTime.Now call sites across the project
- Identified specific files and locations containing time-related static dependencies
- Provided a count or summary of time-related static call sites
- Recommended TimeProvider or a similar abstraction as the replacement for .NET 8+
- Provided a migration plan or prioritized steps for replacing the time statics
- name: Decline scan for non-C# project
prompt: >
I have a Python Django project at my_app/ that has lots of
datetime.now() calls. Can you scan it for untestable statics?
environment:
files:
- src: ./fixtures/decline-non-csharp/views.py
dest: my_app/views.py
graders:
- type: output-matches
config:
pattern: (Python|not.*(C#|\.NET)|different|unsupported)
- type: prompt
rubric:
- Recognized that the project is Python, not C#/.NET
- Did not attempt to scan for .NET static patterns
- Suggested an alternative approach or clarified it only supports .NET
- name: Verify structured report includes file count, categories, and top patterns
prompt: >
I need to present a testability audit to my team lead. Can you scan the
StaticHeavy/ project and give me a full report? I need to know exactly
how many files were scanned, which categories of statics exist with
their totals, which patterns appear most often, and which files are the
worst offenders.
environment:
files:
- src: ./fixtures/static-heavy-project
dest: StaticHeavy
graders:
- type: output-matches
config:
pattern: \d+.*([Ff]iles?|scanned)|([Ff]iles?|[Ss]canned).*\d+
- type: output-matches
config:
pattern: ([Cc]ategor(y|ies)|[Bb]reakdown|[Pp]er.category).*\d+|\d+.*(categor|breakdown)
- type: output-matches
config:
pattern: (DateTime\.UtcNow|DateTime\.Now)
- type: output-matches
config:
pattern: \.cs
- type: exit-success
- type: prompt
rubric:
- Report includes the number of .cs files that were scanned
- Report includes a per-category breakdown showing total call sites for each static category
- Report ranks or lists the most frequently occurring static dependency patterns
- Report identifies which source files have the most static dependencies
- Report is organized with clear sections that would be presentable to a team
- name: Exclude obj and bin directories from the scan
prompt: >
My ObjExclusion/ project seems to have a lot of statics but I want to
know what's in my actual source code, not build artifacts. Can you scan
the source files, skip obj/ and bin/ directories, and give me a report
of all static dependencies that need to be wrapped for testability?
environment:
files:
- src: ./fixtures/obj-exclusion-project
dest: ObjExclusion
graders:
- type: output-matches
config:
pattern: (DateTime|File\.|Environment)
- type: output-not-matches
config:
pattern: (GeneratedResourceAccessor|AssemblyMetadata|Process\.(GetCurrentProcess|GetProcessesByName))
- type: output-matches
config:
pattern: \.cs
- type: exit-success
- type: prompt
rubric:
- Only reported static dependencies found in production source code files
- Did not include statics from auto-generated code in obj/ or bin/ directories
- Correctly identified the static dependencies in DataService such as DateTime.UtcNow and File.WriteAllText
- Provided a structured summary or report of findings with categories or counts
- Recommended wrapping or abstracting the detected static dependencies
- name: Detect statics inside lambda expressions and LINQ queries
prompt: >
My ReportGenerator class in LambdaStatics/ uses a lot of LINQ and
lambdas. I'm worried there might be hidden static dependencies that
would make it impossible to unit test. Can you find all the statics
in that project?
environment:
files:
- src: ./fixtures/lambda-statics-project
dest: LambdaStatics
graders:
- type: output-matches
config:
pattern: (DateTime\.UtcNow|DateTime\.Now)
- type: output-matches
config:
pattern: (File\.(Exists|ReadAllText|WriteAllText))
- type: output-matches
config:
pattern: (Environment\.|Directory\.)
- type: output-matches
config:
pattern: \.cs
- type: exit-success
- type: prompt
rubric:
- Found all DateTime.UtcNow and DateTime.Now call sites including those embedded in expression chains
- Found File.Exists and File.ReadAllText call sites even when used within method chains
- Found static calls inside callback or delegate assignments, not just direct method body calls
- Total count of detected static call sites covers all occurrences across the project