Prompt Engineering Design
A set of personal notes and first principles for designing prompts, arguing prompts should behave like a programming language and that Python can serve as the prompt itself.
This guide sets out first principles for prompt design: making prompt wording more like a programming language to reduce the loss from translating between representations, even using Python directly as the prompt itself; using absolute, must-style instructions instead of vague tone; and treating a system-role prompt as doing one small thing well, since smaller granularity is described as more stable.
Other principles cover automatic collaboration between multiple prompts instead of manually sorting their output by hand, retrieving enough accurate external context, applying lambda-calculus-style composition to combine prompts, and running multiple executions with retries and loops until a goal is met.
A specific technique uses Python code as both the input, as comments plus code, and the output, parsed with the ast module, for fill-in-the-blank generation tasks, then translates confirmed-correct Python into other languages. Complex questions are suggested to be tested first with simpler sub-questions, using the results to correct the prompt, and complex code issues are suggested to be solved by finding a minimal reproducible example first.