Overview
How might we design smart code blocks so people can trust and act on AI output?
When to use
- Essential for AI-powered development environments, code generation tools, and technical documentation platforms where code snippets need immediate execution or integration.
When to skip
- Non-code products where fenced blocks are rare.
- Secure environments that must forbid run-from-chat.
- Tiny mobile views where run controls would dominate the answer.
Rules
Code fences with no copy button.
Run that executes without sandbox or confirmation.
Apply-to-file that skips a diff review.
Wrong language labels that break highlighting and tooling.
Evidence
| Product | Implementation |
|---|---|
| Cursor | Apply and diff flows from chat code blocks into the repo. |
| ChatGPT | Copy, canvas, and code execution affordances on blocks. |
| Claude | Artifacts and copy actions for generated code. |
| Replit | Runnable snippets tied to the project environment. |
