Code Prompts
Code generation / fix prompt
Spec-first code task with constraints and verification.
The prompt
Task: {task}
Language: {lang}
Constraints: {constraints}
Tests to satisfy: {tests}
Return: complete code + short usage notes. Do not assume APIs; state versions. What to swap in
| Placeholder | What it means |
|---|---|
{task} | task |
{lang} | lang |
{constraints} | constraints |
{tests} | tests |
Keep the placeholders short and concrete. If a value is unknown, say so explicitly in the prompt rather than leaving the model to guess.
How to use it
- Copy the template exactly, including punctuation and structure.
-
Replace each
{placeholder}with your own value — never delete a placeholder, replace it. - Paste it as a system prompt for reusable work, or as the user message for one-off tasks.
- Check the output against the rubric below. If it fails a line, tighten the prompt rather than re-rolling the model.
Test it before you trust it
- Ground every factual claim; cite sources when available.
- Distinguish 'known', 'inferred', and 'assumed' — never blur them.
- Say 'insufficient context' instead of guessing.
- Keep instructions unambiguous: one action per sentence where possible.
- Prefer concrete, testable criteria over adjectives.
- Specify the audience and the desired response format explicitly.
- Add few-shot exemplars for any non-trivial output shape.
- Budget context: put the most important instructions first.
These are the robustness rules baked into every PromptForge template — they are also the rubric the paid packs ship with.
Related prompts
- Code explanation prompt — Structured explanation for learning.
- Code reviewer system prompt — Strict reviewer persona with severity rubric and evidence requirement.
More in this category: Code Prompts · all prompt templates