🤖 The Modern AI Developer · Context Engineering: Feed the AI Exactly the Right Info

How to Write a Good System Prompt: Giving the AI a Role

Why a role / system prompt helps, and how to write a good one

一句话先懂 · TL;DR

Why giving an AI a role improves answers, how a system prompt differs from a normal message, and how to write role prompts that are specific and actionable.

A Role Tunes the AI to the Right Channel First

Ask the same question of "a rigorous pediatrician" and "a stand-up comedian" and the answers are worlds apart. Giving the AI a role means telling it first "who you are now, who you serve, and in what tone."

Be clear: a role mainly shapes tone, perspective, and boundaries; its boost to accuracy on objective/factual questions is not reliable, and it doesn't guarantee a more correct answer—it tunes "how it says things," not "whether it knows them."

🔆Like tuning a radio: without tuning there's only static. One line—"you are a patient elementary-school math teacher"—tunes it to the right channel, and the answers that follow naturally fit.

A Good Role: Specific and Actionable

"You are an assistant" is basically saying nothing. A good role spec is specific enough to act on: identity, who it serves, style, boundaries.

你是一位面向新手的理财顾问。
- 用大白话解释,少用术语,必要时举生活例子
- 每个建议都说明理由
- 涉及高风险操作必须先提示风险
- 不确定的事直说不确定,绝不编造数字
💡When writing a role, ask yourself: "If someone else followed this passage, would they perform consistently?" If yes, you've written it well.

System Prompt vs. an Ordinary Question

The role spec usually goes in the system prompt. It's different from each of your ordinary questions: the system prompt is the overall tone that runs through the whole conversation, while an ordinary question is what you want it to do for this one line.

💡Analogy: the system prompt is the actor's character script (who you are, how you play it); a user question is the director's call for this particular scene. The character is set once; the scenes come one by one.

Quick note: the AI doesn't actually "remember" the character—it persists across the conversation because the system prompt is automatically placed back into the context every round before being sent to it. This is the same as "it only sees the current desk" from before.

自测 · 学完检查一下

想真正动手做题、记进度、攒连胜?到互动课里练。

What's the main benefit of giving the AI a clear role?

答案:It sets its identity, tone, and boundaries up front, so answers fit better

A role spells out "who you are, who you serve, what tone" up front—like tuning to the right channel—so answers naturally fit the need better.

Judge: for the same question, giving the AI different roles often yields answers that differ in style and emphasis.

答案:True

The role determines the AI's perspective and tone—like how asking a doctor versus a comedian gives completely different answers.

Which role spec is written best (specific, actionable)?

答案:"You are a financial advisor for beginners: use plain language, give a reason for every suggestion, and say so if you're unsure"

A good role is specific enough to act on: identity, audience, style, boundaries. The others are too vague—basically saying nothing.

To test whether a role is well written, ask: if someone else followed this passage, could they perform ___?

答案:consistently

If different people can perform consistently following it, the role is specific and actionable enough; if not, it's written too vaguely.

About the system prompt and an ordinary user question, which statement is correct?

答案:The system prompt is the overall tone that runs through the whole conversation; the user question is this one specific task right now

The system prompt is like the actor's character script (set once, governs the whole show); the user question is like the director's call for this scene (one by one).

Judge: a role spec (system prompt) usually only needs to be set once to influence the tone of the whole conversation.

答案:True

True—it's the overall tone that runs through the whole show. Strictly speaking, though, it's not that the AI "remembers" it, but that the system prompt is put back into context every round, which is why it stays in effect.

想边练边学,而不只是读?

到互动课里答题、记进度、攒连胜——游客即可试学,无需注册。

进入互动课程 →

Learn something new — don't miss updates

New courses, features and learning tips. Occasional emails, unsubscribe anytime.