Code Prompting

Domain: Prompt Engineering

🎯 Motivation

Special considerations for code: specify language, version, style, testing requirements, and error handling expectations.

πŸ“‹ Concrete Example

β€˜Write Python 3.11 code. Follow PEP 8 style. Include type hints. Add unit tests using pytest. Handle empty input with ValueError.’ Specific code requirements produce better code.

πŸ”— Analogy

A blueprint for a building - β€˜3 floors, reinforced concrete, earthquake-resistant, includes parking.’ The more specific the requirements, the better the architect’s design. Code prompting specifies code requirements.