Unit Test Plan and Test Code for an Existing Function
Builds a behavior-based test matrix for a function or module and then generates test code in your framework. Covers edge cases, failures, and mocking boundaries, with coverage gaps stated honestly.
You get: Behavior summary, test matrix table and test code in one fenced block per file
The prompt
mkdir -p .agents/skills/unit-test-plan-and-test-code-for-an-existing-function && curl -sL "https://prompts-gpt.com/prompts/unit-test-plan-and-test-code-for-an-existing-function/raw" -o .agents/skills/unit-test-plan-and-test-code-for-an-existing-function/SKILL.mdExample output
Tips and common edits
Works best on one function or class at a time. Include one existing test so the output follows your conventions. Run the generated tests yourself and treat any failures as information about either the tests or a real defect.
Questions about this prompt
More like this
More in CodingCharacterization Tests Before a Refactor
Writes tests that lock in a module's current behavior, including edge cases and quirks, so you can refactor safely.
Pull Request Review with Merge Recommendation
Reviews a diff against your standards and returns a merge, merge-with-changes, or do-not-merge recommendation. Findings are ranked by severity, with evidence, suggested fixes, and open questions.
Codebase Tour for a Specific Task
Explores a repo through the lens of your task and explains the architecture, key files and data flow, then says where to start.
Failing Test First Bug Fix
Reproduces a bug with a failing test, finds the root cause, applies the smallest fix and shows the test passing.
Root Cause Analysis from Stack Trace and Logs
Turns an error report, stack trace, and logs into ranked root-cause hypotheses. Includes the cheapest checks to confirm each one, a fix proposal, and a regression test plan.
Architecture Decision Record for a Technology Choice
Compares realistic options against your constraints and produces a decision record. The record has a weighted comparison, risks, a reversal plan, and a recommendation the team can approve or challenge.
Edge-Case Test Suite for One Function in Your Existing Test Framework
Writes tests for a single function that cover normal inputs, boundaries, bad input and error paths, in the test framework your project already uses.
Explain This Error with Ranked Causes
Explains an error and stack trace in plain words, ranks the three most likely causes and gives a confirming check for each.
Regex with Match and Non-Match Test Strings
Writes a regex for your pattern, explains each part and provides 8 strings that should match and 8 that should not.
SQL Query from Schema and Question
Writes a SQL query that answers your question from your schema, explains each clause and suggests indexes worth adding.
Cursor .mdc Rules to Portable AGENTS.md Converter
Converts your pasted Cursor .mdc rules into a single AGENTS.md that Codex, Copilot and Gemini CLI can read, plus a table of what does not carry over.
20-Case Agent Eval Set with Pass/Fail Rubric for Normal, Edge and Unsafe Requests
Builds 20 test cases for your agent's task, with expected behavior, failure signals and a pass/fail rubric covering normal, edge and unsafe requests.