Prompting Techniques
Constraint Frame

The Constraint Frame

Tell AI what NOT to do. It's often more effective than saying what to do.

The Concept

AI loves to:

  • Add dependencies you don't need
  • Over-engineer solutions
  • Add features you didn't ask for
  • Use patterns it "thinks" are best

Constraints prevent this.

Examples

Limiting Dependencies

"Implement this WITHOUT using any external libraries. 
Use only native browser APIs."

Limiting Complexity

"Give me the simplest possible implementation. 
No abstractions. No classes. Just functions.
Keep it under 50 lines."

Limiting Scope

"ONLY modify the validateEmail function. 
Don't change anything else in the file."

Limiting Features

"Just the basic CRUD operations. 
No pagination, no filtering, no sorting yet."

Constraint Cheat Sheet

GoalConstraint Phrase
No dependencies"WITHOUT using any external libraries"
Keep it simple"Give me the minimal version"
Limit scope"ONLY modify..." or "Don't touch..."
Specific tech"Using only [X], not [Y]"
Size limit"Keep it under N lines"
No features"No [X], no [Y], just [Z]"

When Constraints Save You

⚠️

Without Constraints: AI suggests installing 3 npm packages for date formatting.

With Constraints: "No external dependencies" → AI uses toLocaleDateString().

// AI might suggest:
import { formatDate } from 'date-fns';
formatDate(date, 'PP');
 
// But you only needed:
const formatDate = (date) => date.toLocaleDateString();

Combining Constraints

Stack multiple constraints for precise output:

"Create a function that validates email addresses.

Constraints:
- No regex (use string methods only)
- No external libraries
- Return { valid: boolean, error?: string }
- Under 20 lines
- Handle: empty input, missing @, missing domain"