Four-Part Prompt Structure

The framework for writing ChatGPT prompts that produce precise, targeted responses. Role sets the perspective, Context provides background, Task specifies the action, Constraints define scope and format.

Syntax

chatgpt
ROLE:
You are a [specific expertise] who [specific job].

CONTEXT:
[Background — stack, project, current state]

TASK:
[Action verb] [exact thing to do].
Format: [output format]

CONSTRAINTS:
- Do not [exclusion]
- Keep [scope limit]
- Output as [format]
- Maximum [length]

Example

chatgpt
ROLE:
You are a senior TypeScript engineer reviewing a PR
for type safety and correctness.

CONTEXT:
Multi-tenant React app, strict TypeScript, Supabase auth.
The PR adds a real-time notification system.

TASK:
Review the code below. Flag all type safety issues.
Format: [HIGH/MEDIUM/LOW] File:Line — Description

CONSTRAINTS:
- Flag only type issues — no style suggestions
- One line per issue
- "No type issues found" if clean

[paste code]