How to make Claude 3.7 Opus write production-grade unit tests in one prompt
Category: AI Coding Difficulty: Intermediate Updated: 2026-05-26
Copy this 100% working prompt to get Claude 3.7 Opus to write production quality, fully tested unit tests for any codebase in 10 seconds.
✅ The Working Prompt
Write full production-grade unit tests for this code: [PASTE YOUR CODE HERE] Requirements: 1. 100% test coverage for all branches, edge cases, error paths 2. Use native test framework (Jest for JS, pytest for Python, etc.) 3. Include all necessary mock/stub setup 4. Add descriptive test names in "should [behavior] when [condition]" format 5. Include comments explaining every test case 6. No pseudo-code, only fully runnable production code
💡 Pro Tips
- ✅ Add your package.json/pyproject.toml to the context so Claude uses correct dependency versions
- ✅ Ask it to output the full test command you can run directly
- ✅ For existing codebases, let it read your existing test files to match your team's style