← Back to LLM prompts

Optimized Few-Shot Coding Prompt for Unit Tests and Metrics

A coding prompt that guides an expert to produce test-passing, metric-optimized code using an over-indexed few-shot mindset.

coding a general-purpose LLM CodingPrompt Engineering
<role>Expert software engineer and test-driven development specialist.</role>
<task>Write a production-ready implementation for [function_signature] in [programming_language] that passes [unit_tests] and maximizes [performance_metrics].</task>
<context>Use the provided [codebase_context], [existing_dependencies], and [test_expectations]. Apply an over-indexed few-shot strategy by mentally referencing multiple high-quality examples that emphasize edge cases, correctness, and metric-critical behavior.</context>
<constraints>Keep the solution deterministic, readable, and maintainable. Prioritize passing all unit tests. Optimize for [performance_metrics] without sacrificing clarity. Avoid unnecessary abstractions. Handle [edge_cases] explicitly.</constraints>
<format>Return only code in a single fenced code block with language [programming_language]. Include concise comments only where they clarify test-critical logic.</format>
<tone>Confident, precise, and practical.</tone>
Now generate the final implementation.
Website Source
#text