How to use Claude to make a C# module testable
Claude Code helped refactor a C# reporting DLL, add dependency injection and tests, and create a CLI; the developer repaired logic errors before final release testing.
Prompt to try
Editorial adaptation, not the source author’s exact prompt. Replace bracketed inputs and review tool permissions first.
Refactor [bounded C# reporting module] so its logic can be exercised independently of [parent application]. Add dependency injection, tests for [supported configurations], and a CLI. Preserve reporting behavior and flag uncertain business rules for my review.
Reach people exploring AI agents
See placements →What happened
The author estimated saving a couple of days and obtained a module with tests and a CLI, although cleanup and business-logic corrections remained necessary.
Reported by mwigdahl on Hacker NewsHow the agent did it
- Refactored the bounded C# reporting module with Claude Code.
- Added dependency injection and tests to the module.
- Added a CLI to exercise supported reporting configurations.
Where a person stepped in
The author inspected the result, debugged business-logic mistakes and fixed them; the project was in final testing before release.
A person set the goal and reviewed the result.
mwigdahl described a C# DLL that generated data-driven prescription monitoring reports. It first retrieved report configuration, then used that configuration to retrieve and assemble the required data. Formatting varied by state, whether data existed, and whether output was intended for transmission or user review.
The original implementation had no tests and could only be exercised through embedded links in the main application. That made bug fixes and validation painful: production release testing required all 50 states and different data conditions, driven through automation of the parent application.
The developer used Claude Code to refactor the bounded module, add dependency injection and tests, and introduce a CLI for exercising its supported configurations. They reported spending approximately $50 in tokens over a few hours, much of that time while attending other meetings.
The result needed human correction. Some tests were overly specific, restructuring left existing functions incompletely cleaned up, and a couple of business-logic paths required debugging and repair. The author estimated that the work saved a couple of days and said the project was undergoing final testing before release. Who it's for: developers isolating a bounded legacy module so it can be tested without driving its parent application.
Prompt
Suggested prompt (written by Agents In Use, not the author's)
Source: Hacker News · mwigdahl
Frequently asked questions
Why did the module need a CLI?
The original DLL could only be exercised through its links in the parent application. The new CLI allowed the supported configurations to be exercised directly.
What needed human correction?
The author reported overly specific tests, incomplete cleanup of existing functions and a couple of incorrect business-logic paths that they debugged and fixed.
More details
Remaining steps
- Debugged and fixed incorrect business-logic paths.
About this account
Claude Code performed the refactoring and testing additions over a few hours while the author spent much of that time in meetings.
Platform: Hacker News. Attribution: https://news.ycombinator.com/item?id=45583302. Prompt: Suggested (written by Agents In Use, not the author's). Sourced by the Agents In Use pipeline.
Credit: mwigdahl on Hacker News
Source published 14 Oct 2025
Source checked 14 Oct 2026
Tools and topics
Claude Code · C# · CLI
C# · Legacy code · Testing
Editorial completeness: 100/100. Measures documented fields, not agent performance or verified outcomes.