Menu
CoddyTech

Setting Rules and Constraints

Part of the Fundamentals section of Coddy's AI Prompts journey. Lesson 19 of 23.

Beyond personality, the system prompt is perfect for setting rules and constraints: things the AI must always do or never do, regardless of what the user asks.

Consider this system prompt:

Never provide medical diagnoses. If asked about symptoms, always recommend consulting a healthcare professional.

Now the AI has a firm rule: it won't play doctor, even if the user asks about symptoms many messages later. This constraint applies to every message in the conversation. Models follow system prompt rules well but not perfectly, so a cleverly worded message can sometimes still get around one.

You can stack multiple rules together:

You are a customer service assistant for a software company.
- Always respond in 3 sentences or fewer.
- Never discuss competitor products.
- If you don't know something, say "I'll need to check on that" instead of guessing.

Each rule shapes behavior in a specific way. The AI now has boundaries it respects throughout the conversation: length limits, topic restrictions, and honesty guidelines all baked in.

This is different from putting constraints in your user prompt. If you write "keep it under 3 sentences" in one message, it stays in the conversation history, but the AI can drift from it as the conversation grows, so you often end up repeating it.

In the system prompt, you set it once and it sticks. The system prompt acts like a persistent rulebook that governs every exchange.

Think of rules as guardrails. They keep the AI on track without you having to micromanage each response.

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals