---
name: explain-code-prompt
description: A prompt that explains a piece of code, a script, a config file or tool output in plain English - what it does, a walk through of how it flows step by step, what the settings mean, any risks it carries - and answers your specific question about it. Use when you are handed code you do not understand, inherit a project, or want a walkthrough of what something does.
license: MIT
metadata:
  category: coding-prompts
  tags: "docs,debugging,quality"
  author: johnny-bravo
  version: "1.0"
  updated: "2026-11-02"
  status: published
  aliases: "explain this code, what does this code do, code walkthrough"
  source_url: "https://github.com/danielmiessler/Fabric/blob/8ce0909d8622a61b6aaf539d467ba31bb7e0b6dd/data/patterns/explain_code/system.md"
  source_license: MIT
  copyright: "Copyright (c) 2012-2024 Scott Chacon and others"
  original_author: "Daniel Miessler and Fabric contributors (explain_code pattern)"
  modified: "Converted by TheSkillVault into a fill-in prompt: added a reader-level input, a step-by-step flow section, a risks section, steps, safety and done-when sections."
  imported_on: "2026-11-02"
---

# Explain code (prompt)

Paste code, a config file or a tool's output and get a plain-English explanation pitched at your level.

## When to use
- You found code online or in a project and do not know what it does.
- You inherited a codebase or a config file nobody documented.
- A security scanner or build tool printed output you cannot read.

## Steps
1. Copy the code, config or output. Keep it to one file or function if you can.
2. Fill in {{LEVEL}} (for example "new to coding" or "experienced, new to Rust") and an optional {{QUESTION}}.
3. Paste it into the prompt below.
4. Ask follow-ups on any part that is still unclear.

## Prompt
```text
Explain the content below for a reader who is {{LEVEL}}.

First, say what kind of content it is (code, configuration, or tool output) in one line.

- If it is code: give a one-sentence summary of what it does, then walk through how it works step by step, naming the key functions and data.
- If it is configuration: explain what each important setting does and what would change if it were different.
- If it is tool or security output: explain what it means and what, if anything, needs action.

Then add:
- Risks: bugs, security issues or surprising behaviour you notice, each in one line. Say "none spotted" if none.
- Answer: if I asked a question, answer it directly.

Keep it plain. Define any jargon the first time you use it. Do not rewrite the code unless I ask.

QUESTION (optional): {{QUESTION}}

CONTENT:
{{CODE, CONFIG OR OUTPUT}}
```

## How to adapt
- Teaching someone? Add "end with three questions to check understanding".
- Long file? Ask for "a map of the file first, then explain only the part I choose".

## Gotchas
- Remove API keys, passwords and private data before pasting code or config into an AI tool.
- An explanation can sound confident and still be wrong. Run the code or check the docs for anything important.

## Portability
Works with any language and any chat AI or coding agent. No tool lock-in.

## Done when
- You can say in one sentence what the code does.
- Your question is answered and any risks are listed.

## Example prompt
"Explain this bash script for someone new to coding, and tell me if it is safe to run."

---
Converted from the "explain_code" pattern in danielmiessler/Fabric (MIT, Copyright (c) 2012-2024 Scott Chacon and others). See LICENSE.txt.
