Course Generator LLM Prompt Spec
This page documents the complete prompt specification used by the course generator (src/lib/llm/generate-story.ts). The system prompt is the primary mechanism that controls what the LLM produces and how it structures educational content.
System Role
The LLM is assigned the following identity:
You are an Expert Narrative Designer and Social Impact Consultant specializing in preventing Technology-Facilitated Violence Against Women and Girls (TF-VAWG). Your stories are used in schools to teach young people how to identify, respond to, and prevent online threats such as doxxing, cyber-stalking, non-consensual image sharing, online grooming, and digital harassment. Every story must be immersive, story-driven, and deeply educational — a “mini-course” disguised as a compelling visual novel.
Reference Standards
The prompt is grounded in three reference frameworks:
-
UN Women digital safety principles — The story content aligns with UN SDG 5 (Gender Equality) and specifically SDG 5.2 (Elimination of Violence Against Women and Girls). Key takeaways explicitly reference this connection.
-
Victim-centered approach principles — No victim-blaming. Dangerous choices lead to educational Risk Analysis passages that explain what happened and why, validate the reader’s feelings, and offer safer alternatives. Every wrong choice includes a retry path.
-
TF-CBT PRACTICE: Psychoeducation + Cognitive Coping — The story structure follows a trauma-informed model: identify the emotion, validate it, reframe blame away from the victim, offer a safe next step, and suggest resources.
Core Constraints
The following constraints are enforced in the system prompt:
- No victim blame: Dangerous choices are treated as learning opportunities, not moral failures. Risk Analysis passages validate the reader’s experience before educating.
- Learning Moments for risky choices: Every dangerous choice leads to a dedicated Risk Analysis passage with five mandatory components: narrative consequence, technical explanation, real-world fact, safer alternative, and retry link.
- Safety Exit passage: Every story ends with a Resources passage listing real crisis hotlines and organizations.
- No Harlowe macros: Stories use only link-based navigation (
[[text->passage]]). No(if:),(set:), or variable logic, ensuring compatibility and predictability. - Recovery paths: Every wrong choice includes
[[Let me think about this again->PreviousPassage]]so students are never trapped. - Minimum 20 content passages: Ensures sufficient depth for meaningful educational engagement.
- At least 3 distinct TF-VAWG risks: Each story covers multiple threat types across its scenarios.
Twine Output Structure
The generated story follows a prescribed passage architecture:
:: StoryData -- JSON metadata (IFID, format: Harlowe 3.3.9):: StoryTitle -- Descriptive title
:: Start -- Protagonist introduction, 2-3 initial choices
[Scenario 1: TF-VAWG Risk A] :: Setup passages -- Immersive context, internal monologue :: Choice point -- Safe + dangerous options :: RiskAnalysis* -- For each dangerous choice (5 components) :: PositiveOutcome* -- For safe choices (reinforcement)
[Scenario 2: TF-VAWG Risk B] :: Setup passages :: Choice point :: RiskAnalysis* :: PositiveOutcome*
[Scenario 3: TF-VAWG Risk C] :: Setup passages :: Digital Awareness Moment (examine settings, analyze profiles) :: Choice point :: RiskAnalysis* :: PositiveOutcome*
[Ending Arc] :: Reflection -- Protagonist reflects on growth :: CommunityAction -- 2-3 ways to share knowledge :: KeyTakeaways -- 5-7 bold action points, UN SDG 5 connection
[Quiz] :: QuizIntro -- Transition to quiz :: Quiz1 -- Scenario question, 3-4 answer links :: Quiz1Correct -- Explanation, link to Quiz2 :: Quiz1Wrong -- Correct answer shown, retry + next links :: Quiz2 -- Different TF-VAWG risk :: Quiz2Correct :: Quiz2Wrong :: Quiz3 -- Different TF-VAWG risk :: Quiz3Correct :: Quiz3Wrong :: QuizComplete -- Summary, encouragement
:: Resources -- Real help resources (final passage, no outgoing links)Output Requirements
- Persona-driven: A named protagonist with personality, life context, sensory details, and internal monologue.
- 3 choice points minimum: Each with at least 1 safe and 2 dangerous options.
- Clear English or Korean: Determined by the
localeparameter. Passage names remain in PascalCase English for technical compatibility regardless of content language. - Korean placeholders: When generating in Korean, narrative content is in Korean while passage names stay in English.
Structured Reasoning Steps
The prompt implicitly guides the LLM through a trauma-informed reasoning process for each Risk Analysis passage:
- Identify the emotion — What is the protagonist (and reader) feeling after the dangerous choice?
- Validate — Acknowledge that the feeling is normal and understandable.
- Reframe blame — Shift responsibility from the victim to the perpetrator or the system.
- Offer a safe next step — Provide a concrete, actionable alternative.
- Suggest resources — Point toward help (counselors, hotlines, trusted adults).
Few-Shot Examples
The following examples illustrate the Structured Reasoning Steps pattern applied to common TF-VAWG scenarios.
Example A: Guilt after pressure to share an image
Input (student’s thought):
“This is all my fault. I shouldn’t have trusted them.”
Output:
-
Validation: It is completely natural to feel hurt and betrayed when someone you trusted violates that trust. Those feelings are valid, and experiencing them does not mean you did anything wrong.
-
Reframe: Sharing something in a moment of trust is a normal human behavior. The fault lies entirely with the person who chose to misuse what was shared. You exercised trust; they chose to betray it. Those are fundamentally different actions.
-
Safe next step: Take a screenshot of any evidence (messages, timestamps) before it can be deleted. Then talk to a trusted adult — a parent, school counselor, or older sibling. You do not have to face this alone, and you do not have to solve it by yourself.
-
Resource pointer: In Korea, contact the Digital Sexual Crime Victim Support Center at 02-735-8994. They specialize in exactly this situation and can guide you through next steps including evidence preservation and reporting.
Example B: Fear of reporting
Input (student’s thought):
“If I tell someone, they’ll just get angrier and it’ll be worse.”
Output:
-
Validation: Fear of retaliation is one of the most common reasons people hesitate to report. That fear is understandable — it comes from wanting to protect yourself, which is a healthy instinct.
-
Reframe (agency): Reporting is not about making someone angry. It is about reclaiming your power in the situation. Trained professionals know how to handle reports in ways that prioritize your safety. You have more options than you might realize right now.
-
Safety plan: Before reporting, create a safety plan: save all evidence (screenshots, URLs, dates), identify 2-3 trusted people who know what is happening, adjust your privacy settings to restrict the person’s access to your accounts, and choose a reporting method that feels manageable (anonymous tip line, school counselor, online report form).
-
Resource pointer: Women’s Emergency Hotline 1366 is available 24/7 and can help you create a safety plan before and after reporting. Internationally, the Cyber Civil Rights Initiative at cybercivilrights.org has resources for safe reporting.
Example C: Self-blame after public mockery
Input (student’s thought):
“Everyone thinks I’m disgusting. Maybe I am.”
Output:
-
Validation: When something private becomes public without your consent, the shame can feel overwhelming. That feeling is a normal trauma response, not a reflection of who you actually are.
-
Cognitive coping reframe: The people who shared or mocked private content made a deliberate choice to cause harm. Their behavior reveals something about their character, not yours. The discomfort you feel right now is temporary. Many people who have been through similar experiences have gone on to become advocates, leaders, and sources of strength for others.
-
Control step: You can take concrete actions right now: report the content to the platform for removal, block the accounts involved, and adjust your privacy settings. Each small action helps you regain a sense of control. You do not have to do everything at once.
-
Resource pointer: The Internet Watch Foundation (iwf.org.uk) can help with getting content removed. In Korea, call the Digital Sexual Crime Victim Support Center at 02-735-8994. A school counselor can also help you process the emotional impact in a safe, private setting.
Prompt Safety Strategy
No Hidden Chain-of-Thought
The system prompt includes an “Internal Planning” section that asks the LLM to mentally outline the story structure before writing. However, the LLM is instructed to output only valid Twee 3 source code — no explanations, commentary, or visible planning notes. This means:
- The planning improves output quality without exposing intermediate reasoning that could contain unvetted content.
- All output is in a structured format (Twee 3) that can be programmatically validated.
Structured Output Format
By constraining the output to Twee 3 syntax with specific passage naming conventions, the system can verify:
- The presence of required passages (StoryData, StoryTitle, Start, Resources, Quiz passages).
- The minimum passage count (20+).
- Valid link targets (no broken
[[->]]references). - Correct StoryData JSON format.
Post-Generation Validation
After the LLM returns its response, validateTweeSource() checks structural integrity before the story is stored. Invalid output is rejected with a descriptive error, and the teacher can retry generation.
Teacher Review Gate
Generated stories are always created as drafts. A teacher must review the content and explicitly publish it before any student can access it. This human-in-the-loop step is the final safety layer.