Log inBook a Demo
BuildMidBackendAuto-graded

Build a prompt renderer that resists template injection

Supplied data must never turn into instructions, while missing values and optional sections still have to behave correctly.LLM prompts are assembled from a trusted template your team writes and variables that are frequently untrusted — user names, retrieved chunks, tool output, chat history. The template provides structure; the variables fill holes. Implement render(template, vars) with placeholder substitution, a conditional block and a loop — and make the substituted values inert data, so a variable containing template syntax cannot inject structure of its own.
35 min
python

You're done when

  • The conditional block includes or omits its contents based on the named key.
  • The loop block repeats its body across a list.
  • Substituted values are inert — template syntax appearing inside a variable is not interpreted.
  • A missing variable is handled predictably rather than raising or leaking the raw placeholder.

What it measures

Prompt engineeringSeparating the trusted structure of a prompt from the untrusted content that fills it.
Context engineeringAssembling prompts from parts with conditionals and loops, so the structure stays legible as it grows.
Injection awarenessRecognising that a template engine re-interpreting substituted values is itself an injection surface.

Your environment

Terminal + editorA full shell in the browser
Claude CodePre-authenticated, no key setup
Isolated microVMYours alone, wiped afterwards

Start this lab

35 min
Start labYou'll sign in to Anthropos to start. The lab opens in a private cloud workspace with Claude Code ready to use.
AI Labs is part of Anthropos Workforce. Not on your plan yet? Book a demo