Code rendered as plain text mashes variable names, file paths, and commands into prose where users cannot distinguish them from English — copy-paste breaks, indentation collapses, and shell commands get executed with the wrong quoting. This violates the inference-contract taxon: your UI renders markdown, but the model was never told to emit it. Developers paste broken snippets, support tickets escalate, and the product looks amateur next to competitors whose code blocks render with syntax highlighting.
High because every technical response degrades simultaneously, affecting trust and usability across the entire product surface.
Add explicit formatting directives to the system prompt telling the model to wrap code in fenced blocks with language specifiers, use inline code for paths and variables, and structure steps as numbered lists. Pair this with a syntax-highlighting renderer such as react-syntax-highlighter in lib/ai/prompts.ts.
const systemPrompt = `Use fenced code blocks with language specifiers for all code. Use inline code for file paths, variable names, and shell commands.`
ID: ai-response-quality.response-formatting.code-block-usage
Severity: high
What to look for: Enumerate all relevant files and Check the system prompt and any response formatting instructions for directives that instruct the AI to use fenced code blocks (triple backticks) for code, commands, file paths, and technical output. Check whether the markdown renderer is configured to apply syntax highlighting (react-syntax-highlighter, prism, highlight.js) to code blocks in AI responses. Look for any instructions that might suppress or discourage code formatting.
Pass criteria: No more than 0 violations are acceptable. The system prompt or formatting instructions explicitly instruct the AI to wrap code examples in fenced code blocks with a language specifier. The markdown renderer applies visible formatting (monospace font, background, or syntax highlighting) to code blocks. Report the count of conforming instances found even on pass.
Fail criteria: No formatting instructions exist for code output, or the system prompt actively discourages markdown formatting in a context where the UI renders markdown. A partial or incomplete implementation does not count as pass.
Skip (N/A) when: Application is a pure Q&A or conversational tool where code responses are not expected (detectable by system prompt containing no programming or technical domain scope).
Cross-reference: For UX quality of AI chat interfaces beyond response content, the AI UX Patterns audit covers conversation flow and error recovery.
Detail on fail: "System prompt in lib/ai/prompts.ts does not instruct code formatting — AI code samples will render without syntax highlighting" (max 500 chars)
Remediation: Add explicit formatting instructions to your system prompt:
const systemPrompt = `
You are a helpful assistant. Follow these formatting rules:
- Use fenced code blocks with language specifiers for all code examples.
- Use inline code for file paths, variable names, and commands.
- Use numbered lists for step-by-step instructions.
`
Pair this with a syntax-highlighting markdown renderer. For a deeper look at how AI responses are presented in the UI, the AI Chat Visibility Audit covers rendering configuration in detail.