π§ Constraints
Constraints are rules and boundaries you set for the AI's response. They tell the AI what it must do, what it must not do, and the limits it should stay within. Think of constraints as guardrails β they keep the AI's response on track and prevent it from going off in unwanted directions.
Without constraints, AI responses tend to be too long, too broad, or off-topic. Constraints solve all three problems.
Why This Mattersβ
AI models are trained to be helpful, which often means they over-deliver. Ask for a paragraph and you might get an essay. Ask about one topic and you might get tangents about five related topics. Constraints prevent this by setting clear boundaries.
Constraints are especially important in professional settings where outputs need to meet specific requirements β word counts for blog posts, reading levels for public communications, format standards for documentation, or topic restrictions for compliance.
Types of Constraintsβ
1. Length Constraintsβ
Control how much the AI writes:
Max 100 words.
Keep each bullet point to one sentence.
Answer in exactly 3 paragraphs.
Summarize in 2-3 sentences.
One-word answer only.
2. Topic Constraintsβ
Keep the AI focused on what matters:
Focus only on solutions, not problems.
Only discuss features available in the free tier.
Limit your answer to Python β do not suggest other languages.
Only cover events from 2020 to 2025.
3. Tone and Style Constraintsβ
Control how the AI communicates:
Use a professional, formal tone.
Write at an 8th-grade reading level.
No jargon β explain any technical terms.
Use active voice only.
Be direct β no filler words or hedging language.
4. Format Constraintsβ
Restrict the structure:
Respond only in bullet points.
Use a table β no paragraphs.
Every response must include a code example.
No headers β just plain text.
5. "Do Not" Constraintsβ
Explicitly forbid things you don't want:
Do not include any code.
Do not mention competitors by name.
Do not use analogies or metaphors.
Do not give medical/legal/financial advice.
Do not include disclaimers or caveats.
6. Scope Constraintsβ
Limit what the AI covers:
Only cover the top 3 options.
Focus on beginner-level content only.
Address only the front-end, not the back-end.
Only discuss open-source tools.
Combining Constraintsβ
The real power comes from layering multiple constraints together:
Write about climate change.
Constraints:
- Max 200 words
- Reading level: 8th grade
- Focus only on actionable solutions individuals can take
- No political opinions or blame
- Use exactly 5 bullet points
- Each bullet must start with an action verb
- Include one surprising statistic
Prompt Exampleβ
Write a product description for a wireless noise-canceling headphone.
Constraints:
- Exactly 75-100 words
- Target audience: young professionals (25-35)
- Tone: modern, confident, not salesy
- Must mention: battery life, comfort, and noise cancellation
- Must NOT mention: price, competitors, or technical specs (Hz, dB, etc.)
- End with a one-sentence call to action
- No exclamation marks
β Bad Exampleβ
Write about climate change
This prompt has zero boundaries. The AI might write a 1000-word essay covering everything from polar ice caps to politics. It could use a tone that doesn't match your audience or go into details you don't need.
β Improved Exampleβ
Write about climate change.
Constraints:
- Maximum 200 words
- Reading level: 8th grade (simple vocabulary, short sentences)
- Focus ONLY on solutions that individuals can do at home
- No political opinions or blame
- No statistics older than 2022
- Structure: 5 bullet points, each starting with an action verb
- End with one encouraging sentence
Do not discuss causes or history β only practical solutions.
π§ͺ Try It Yourself
Edit the prompt and click Run to see the AI response.
Practice Challengeβ
Task: Write a prompt asking the AI to explain artificial intelligence. But add at least 6 different constraints from different categories:
- One length constraint
- One topic constraint
- One tone/style constraint
- One format constraint
- One "do not" constraint
- One scope constraint
Run the prompt and then remove all constraints and run it again. Compare the two responses β which one is actually useful for your purpose?
Bonus: Try making your constraints contradictory (e.g., "Be comprehensive" + "Max 50 words") and see how the AI handles it.
Real-World Scenarioβ
Scenario: You're a content manager and need AI to write blog posts that match your company's strict style guide.
Without constraints:
"Write a blog post about remote work productivity."
You'll get something that probably doesn't match your brand voice, word count requirements, or content guidelines.
With constraints:
"Write a blog post about remote work productivity.
Style Guide Constraints:
- Word count: 600-800 words
- Tone: conversational but authoritative (like a smart friend giving advice)
- Reading level: 10th grade
- Structure: Introduction (2 sentences), 5 sections with H2 headers, conclusion with CTA
- Each section: 100-120 words
- Must include at least 2 data points or statistics (cite with year)
- Use "you" language β speak directly to the reader
- No buzzwords: don't use "synergy," "leverage," "paradigm," or "disruptive"
- No AI-generated clichΓ©s: don't start with "In today's fast-paced world"
- End with a clear call-to-action related to our product (a project management tool)
- SEO: naturally include the keywords 'remote work tips' and 'work from home productivity'"
This produces a blog post that fits your exact requirements without editing.
Interview Questionβ
Q: What role do constraints play in prompt engineering, and what types of constraints can you use?
A: Constraints act as guardrails for AI output, preventing responses from being too long, too broad, or off-topic. There are six main types: (1) Length constraints β word limits, sentence counts, paragraph limits; (2) Topic constraints β restricting focus to specific subjects or time periods; (3) Tone/style constraints β reading level, formality, voice; (4) Format constraints β requiring specific structures like tables or bullet points; (5) "Do not" constraints β explicitly forbidding unwanted content; and (6) Scope constraints β limiting the breadth of coverage. Layering multiple constraint types together is the most effective approach, as it gives the AI clear boundaries in every dimension, resulting in output that meets specific professional or creative requirements.
Summaryβ
- Constraints are rules and boundaries that keep AI responses focused and useful
- Six types: length, topic, tone/style, format, "do not", and scope
- Without constraints, AI tends to over-deliver with long, unfocused responses
- Layer multiple constraints together for the best results
- "Do not" constraints explicitly prevent unwanted content
- Constraints are essential in professional settings where output must meet specific standards
- Write constraints as a clear, bulleted list for maximum clarity
- Always test if your constraints are contradictory β the AI will struggle with conflicting rules