Im losing my mind here. I have this tight deadline for a fintech app migration project we are running out of our London office and the unit testing coverage is just abysmal. Im trying to use Claude Code to speed this up because manually writing all these edge cases is killing my velocity and I have zero budget to hire extra QA help right now.
I spent all last night reading through some docs and GitHub discussions. Some people swear that using custom system prompts to force a specific TDD flow is the way to go but others say you should just feed it the entire codebase index and let it rip. I tried the latter and it just hallucinated half the dependencies so that was a disaster. My logic was that if I could feed it just the interface definitions it would be more precise but then it keeps missing the business logic nuances that make our tests actually useful.
So Im stuck. Is there a specific way to structure the prompts to get better coverage for legacy code? Like should I be breaking the files down into smaller chunks before passing them over or is there some secret set of instructions for the agent to follow to prevent it from ignoring the mocks? I need this to work by Friday or my lead is gonna be all over me about the sprint velocity. I guess what I really need to know is what specific skills or prompt engineering tricks are actually making a dent in your testing workflows because right now this tool is just making more work for me than it saves... has anyone actually gotten it to generate production-ready test suites without spending three hours fixing the imports?
Honestly, stop feeding it the whole codebase. In my experience, dumping the entire repo just confuses the context window and leads to those hallucinations you are seeing. Over the years, I've found that breaking things down is the only way to keep the agent focused. Try isolating the specific service or module you are testing and only provide the interface definitions plus the business logic file. For fintech stuff, you really need to be explicit about the mocks. I usually create a small schema doc that defines the expected data structures and feed that in as a reference. It prevents the agent from guessing imports that dont exist. Also, if you are working on a massive migration, make sure you are running the agent on a machine with enough memory, like a beefy rig running an AMD Ryzen 9 7950X 16-Core 4.5GHz or similar, otherwise the indexing process itself gets flaky. My workflow is to prompt for one test class at a time using a strict TDD loop. If I just say write tests, it gets lazy. Instead, I tell it: given this interface, write a test case for this specific edge case, verify it fails, then write the implementation. It stops it from spinning its wheels. It takes a bit more upfront time but you arent cleaning up imports for hours afterwards. Hang in there, Friday is tight but doable if you narrow the scope.
> Stop feeding it the world. I use JetBrains IntelliJ IDEA Ultimate to map dependencies first Totally agree with that. Mapping stuff out saved me so much time. If you wanna keep costs low since you dont have a budget, skip the expensive enterprise tools for now and just lean into the CLI flow. I usually grab my Logitech MX Master 3S Performance Wireless Mouse to fly through those dependency trees manually—the thumb scroll is a lifesaver when you're jumping between files. Basically, give it a local definition file and a small unit spec rather than dumping the whole mess. Im really satisfied with how it handles imports when you force it to write one test file at a time. It stops the hallucinations dead. Just be patient with the prompt, dont rush it, and you will hit that Friday deadline no problem.
Like someone mentioned, chunking is key. Stop feeding it the world. I use JetBrains IntelliJ IDEA Ultimate to map dependencies first, then only send the relevant interfaces to the agent.