AI & PromptingAdvanced 3 to 5 hours

Implement XML Tag Routing

Use XML tags to force an LLM to separate its "thinking" from its final output.

The Scenario

You are building an AI agent that writes code. If the AI just outputs the code immediately, it often makes logic errors. You want the AI to write out its "plan" first, but you don't want the plan to be sent to the user—you only want the final code. You must use XML tags to separate the output streams.

The Brief

Design an advanced prompt that forces the LLM to output its reasoning inside `<scratchpad>` tags, and its final answer inside `<final_code>` tags, so your backend system can parse them separately.

Deliverables

  • The System Prompt instructing the use of XML tags for structural separation
  • An explanation of why separating the reasoning step improves LLM logic (Chain of Thought)
  • A regex (Regular Expression) or simple pseudo-code snippet showing how your backend would extract just the text inside the `<final_code>` tags.

Submission Guidance

Using `<tags>` is a fundamental technique in advanced prompt engineering (especially for Claude/Anthropic models). It allows you to give the model space to "think" without polluting the final JSON or user-facing text.

Submit Your Work

Your submission is graded against the rubric on the right. If you pass, you get a public Badge URL you can share on LinkedIn. There is no draft save, so work offline first and paste your finished response here.

This appears on your public Badge.

0/20000 charactersMarkdown supported

One per line or comma separated. Up to 5 links.

By submitting, you agree your submission text, name, and evaluation will appear on a public Badge URL.