Prompt engineering is the practice of designing and refining LLM inputs to guide output quality and character. A prompt works like a specification: it states the task, relevant constraints, and expectations rather than leaving the model to infer them. Design is iterative—test a draft, observe the response, and refine unclear directions or missing assumptions. section 1.1 section 6.1 section 6.2
Prompt engineering is part of context engineering. In an application, a context-management layer may combine the user’s prompt with instructions, external knowledge, tools, memory, and state. The prompt expresses immediate intent; the broader context determines what else the model sees. section 6.1 section 1.1
Four principles make prompt design more systematic:
- Give direction: state the desired outcome, then add audience, purpose, style, or other constraints where useful. section 6.2.1
- Specify format: define the structure, field names, units, ordering, and handling of missing values when downstream systems depend on the output. section 6.2.1
- Provide examples: show representative inputs and outputs to clarify the task and desired pattern. section 6.2.1
- Break down complex tasks: use smaller steps, including chained model calls when appropriate. section 6.2.1
From question to specification
Instead of asking “What is context engineering?”, request: “Define context engineering in 3–4 sentences for a software engineering audience. Focus on its practical benefits, clearly distinguish it from prompt engineering, and use technical but accessible language.” The revision specifies length, audience, emphasis, and tone. section 6.1
Patterns such as role prompting, few-shot prompting, chain-of-thought, ReAct, and chaining structure interactions but consume context-window space. For reasoning models, explicit procedural reasoning prompts can be largely redundant or overly constraining; focus instead on the task, grounding data, constraints, examples, and tool definitions. section 6.7 section 6.3.7
In production, treat user prompts as untrusted input and isolate them with delimiters against injection attacks. Version prompt templates and run regression tests. Frameworks such as COSTAR and CRISPE can standardize prompt construction; tools such as DSPy support optimization, evaluation, and deployment. section 6.7


















































