Some pieces of code are obscure, complex, or simply poorly documented. This prompt helps you make them readable, understandable and educational. Ideal for onboarding a new developer, reviewing legacy code or simply learning by dissecting.
During audit or refactoring phase
To understand an external library or snippet
When onboarding a junior developer
To create quick documentation
A line-by-line or block-by-block explanation
Human and clear comments
Simplification with analogies if needed
A synthetic summary of the code function
This is the base template with placeholders. Replace the placeholders with your specific information:
You are an expert developer and educator. Analyze and clearly explain this code: {{code_block}}. Language used: {{language}}. The target audience is: {{audience_level}}. Provide an explanation line by line or by logical block, with clear comments, analogies if useful, and a final summary of what this code does. {{additional_context_block}}{{code_block}}Code to explain - ex: function processData(input) { ... }{{language}}Programming language - ex: JavaScript, Python, Go, Rust{{audience_level}}Target reader level{{additional_context}}Context or constraint (optional) - ex: the code is part of a REST API, integrates into a React app, or needs to be made accessible for onboardingHere's an example with filled-in values:
You are an expert developer and educator. Analyze and clearly explain this code:
function processData(input) {
const lines = input.split('\n');
const result = lines.map(line => line.trim()).filter(Boolean);
return result;
}
Language used: JavaScript. The target audience is: beginner. Provide an explanation line by line or by logical block, with clear comments, analogies if useful, and a final summary of what this code does.Help others discover this useful prompt by sharing it on social media