Back to directory

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.

Prompt Engineering Design

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.

More in Books

See all 105
  • A long technical guide to AI agent memory: why stateless LLMs need it, the different memory architectures from vector stores to knowledge graphs, and how Cognee implements one as an open-source memory layer.

  • Samizdat

    rare-books.vercel.app

    A free, curated shelf of rare internal memos, leaked handbooks, and out-of-print books from technology and business history, collected for builders to read or borrow.

  • A free, web-only book that explains AI systems, from raw compute to a deployed and governed behavior, design-first, for a software engineer who knows distributed systems but is new to machine learning.