Boss Fight: Documentation Assistant
The Scenario
Section titled “The Scenario”You are building a Documentation Assistant — an AI system that analyses technical documentation and answers developer questions. The assistant must work reliably: source-based answers, consistent format, traceable reasoning process. No hallucinations.
This project combines all five building blocks from Level 5:
Requirements
Section titled “Requirements”- A
buildDocAssistantPromptfunction that unifies all 5 concepts - Documentation as
<background-data>with source citation (<url>and<content>) - At least 2 exemplars in the
<examples>section that demonstrate the desired answer format <thinking-instructions>that guide the LLM to structured reasoning for complex questions<rules>that prevent hallucinations: only use provided data, be honest about knowledge gapsstreamTextfor output to the terminal
Starter Code
Section titled “Starter Code”Create boss-fight-5.ts and run with: npx tsx boss-fight-5.ts
import { streamText } from 'ai';import { anthropic } from '@ai-sdk/anthropic';
// Simulierte Dokumentation — in Production: fs.readFileSync oder Vector DBconst documentation = `# Authentication API
## SetupInstall the auth package: \`npm install @example/auth\`
## ConfigurationCreate an auth.config.ts file in your project root:
\`\`\`typescriptimport { defineConfig } from '@example/auth';
export default defineConfig({ providers: ['github', 'google'], secret: process.env.AUTH_SECRET, database: process.env.DATABASE_URL,});\`\`\`
## MiddlewareAdd the auth middleware to your server:
\`\`\`typescriptimport { authMiddleware } from '@example/auth';
app.use(authMiddleware());\`\`\`
## Protected RoutesUse the \`requireAuth\` helper:
\`\`\`typescriptapp.get('/dashboard', requireAuth(), (req, res) => { res.json({ user: req.user });});\`\`\`
## Error HandlingThe middleware throws AuthError for invalid tokens.Catch it in your error handler.`;
const question = 'How do I protect a route that only admins can access?';
// Deine Aufgabe: Baue den vollstaendigen Documentation Assistant.// Nutze ALLE 5 Techniken aus Level 5.
// 1. buildDocAssistantPrompt() — wiederverwendbare Template-Funktion// 2. XML Tags — strukturierter Prompt// 3. Exemplars — mindestens 2 Beispiele fuer das Antwort-Format// 4. background-data — die Dokumentation als Kontext// 5. thinking-instructions — Denkprozess vor der Antwort// 6. streamText — Ausgabe ins Terminal
const result = await streamText({ model: anthropic('claude-sonnet-4-5-20250514'), prompt: '// Dein Prompt hier',});
for await (const chunk of result.textStream) { process.stdout.write(chunk);}Evaluation Criteria
Section titled “Evaluation Criteria”Your Boss Fight is passed when:
- The prompt is generated by a reusable
buildDocAssistantPromptfunction (Template, 5.1) - The prompt uses XML tags in the correct order:
<task-context>-><background-data>-><examples>-><rules>-><the-ask>-><thinking-instructions>-><output-format>(XML Structure, 5.2) - At least 2 exemplars demonstrate the desired answer format with a
<thinking>block and structured answer (Exemplars, 5.3) - The documentation sits in
<background-data>with<url>and<content>tags (RAG, 5.4) -
<thinking-instructions>define how the LLM should search the docs and analyse the question (CoT, 5.5) -
<rules>prevent hallucinations: only use doc content, use quotes, be honest about knowledge gaps -
<output-format>clearly defines the answer structure - The code runs with
streamTextand produces a meaningful answer
Hint 1: Structuring the function
Your buildDocAssistantPrompt function needs a config object with at least these fields: docUrl, docContent, question, exemplars. The function returns a string containing all XML tags in the correct order. Look at the buildSystemPrompt function from Challenge 5.1 — same idea, just with more tags.
Hint 2: Exemplars for the Documentation Assistant
Your exemplars should show the complete answer format: first a <thinking> block with the search process through the docs, then the structured answer with quotes. Show at least one case where the question is answerable and one case where the docs do not have an answer. This way the LLM learns both paths.
Hint 3: The anti-hallucination rule
The most important rule in <rules> is: “If the question cannot be answered from the provided documentation, say so honestly and suggest where the user might find the answer.” Without this rule the LLM will try to answer questions that are not covered in the docs — with made-up answers.