Module 2 – Prompt Engineering as Specification Engineering
Learning outcomes
Write prompts that behave like testable software specifications and produce dependable structured results.
Professional prompt pattern
- Role and objective: define the job and the required outcome.
- Context: include only relevant repository, business, and user information.
- Constraints: state security, compatibility, style, performance, and scope limits.
- Acceptance tests: describe exactly how success will be checked.
- Output contract: require a schema, diff, checklist, or other machine-verifiable format.
Advanced techniques
Use decomposition for complex work, examples for format control, retrieval for external facts, and explicit uncertainty when evidence is missing. Separate trusted system instructions from untrusted data. Never paste secrets into prompts.
Lab 2
Create a prompt that asks an AI to implement input validation. Include repository context, non-goals, edge cases, test requirements, and a JSON result schema. Run it three times and measure schema validity and test pass rate.