Overview

2 Chat: "Explain this code" is the worst prompt in AI

When people first use AI to understand code, they often ask a vague question like “What does this do?” and get back a bland summary that feels useless. The chapter argues that the failure is usually the prompt, not the model, and shows that a single sharp follow-up can reveal more than many generic requests. Using nanoGPT as the example codebase, it demonstrates how a small, readable repository is ideal for learning how to interrogate code with chat, especially when you want to uncover a real design choice rather than a surface-level description.

The core method is to replace vague, abstract prompting with concrete constraints and targeted curiosity. Instead of asking for categories, ask for one specific person and story; instead of asking for adjectives like “simple,” ask for numeric limits; instead of asking for prose, ask for a toy example with actual values. The chapter also shows how to make a whole repository pasteable by serializing relevant source files into one text dump, while filtering out noise such as dependencies, tests, build outputs, and binaries. That lets you ask end-to-end questions about how files connect, how training works, and what the important dependency chain looks like.

Because memory fades quickly, the chapter adds a learning-note routine: let AI draft a short outline, refine it in your own words, follow up on anything unclear, and quiz yourself until gaps become obvious. This active process turns a one-time chat session into lasting understanding and helps prevent “comprehension debt.” It ends by placing chat in context: chat is best for exploring a few files deeply, workflows are better for repeating the same task across many files, and agents are better when you want the tool to decide its own next step. Each approach has limits, and the right one depends on whether you need depth, scale, or autonomous action.

Paste code, get a generic wall of text. Follow up on the one line that surprises you. Constrain the output with numbers instead of adjectives. Write a learning note to prevent forgetting.
Paste the files relevant to your question. A question about a single file's internals needs only that file. An end-to-end question needs the whole pipeline. A deployment question needs infrastructure files.
A vague question gets a vague answer. Ask "what are the features?" and the AI fills the board with fancy-sounding categories that leave you no wiser; ask it to trace one real story end-to-end, or to prove a claim with a toy example and actual numbers, and the same model finally makes it click.
Fifteen cluttered nodes, emojis, tensor shapes, and multi-line labels that overwhelm the reader.
"At most 10 nodes, 2-4 words each" produces 9 clean nodes that a beginner could memorize in 60 seconds.
From shallow to deep learning: passive reading (base), active questioning (climb), and building (summit). The learning note here is an example of the "climb" stage.
The learning note cycle: skeleton from AI, follow-up questions, rewrite in your own words, then self-quiz. Each round sharpens the note and deepens your understanding.
Chat explores deeply but only a few files at a time. A workflow asks the same question across every file and generates documentation. An agent takes that documentation as a map and decides which file to read next. Each tool's weakness is the next tool's strength.

Summary

  • Start with a single file, a single question, and a follow-up. Your first prompt will be simple. The initial answer is often generic, but a good follow-up question can reveal design choices you wouldn't discover by just reading the code.
  • Choose your files carefully. While a short script can serialize a repo into a single pasteable file, including irrelevant code not only dilutes the answer but can also actively mislead the model.
  • Frame your questions precisely. How you ask matters more than the model you use. Ask for specific formats: "stories" (sequences of events) instead of "categories," "numbers" instead of "adjectives," and "toy examples" instead of abstract prose.
  • Document what you learn immediately. You'll forget two-thirds of new information within 24 hours. Counter this "forgetting curve" by creating a learning note, iterating through cycles of outlining, asking follow-up questions, rewriting answers, and quizzing yourself.
  • Treat chat as your first step. Chat mode, where you manually paste files and guide the conversation, doesn't scale for large codebases. However, the manual effort forces you to think deeply, which builds understanding. This makes it ideal for your initial learning reps. Later, you'll move to Workflow mode, which automates repetitive tasks, and Agent mode, which explores independently, often using Workflow output as its guide.

FAQ

Why is “Explain this code” considered the worst prompt for AI?Because it is too vague. The model will usually produce a generic summary that could fit many codebases, instead of surfacing the specific design choices, surprises, or relationships that matter in your file.
What should I do instead of asking “What does this do?”Ask a sharper follow-up based on something specific you noticed in the code, such as an unusual variable value, an unfamiliar class, or a surprising dependency. Specific prompts lead to useful insights; vague prompts lead to generic text.
Why does the first answer from a chatbot usually feel generic?That is expected. The first answer is often a warm-up that gives you vocabulary and a high-level map of the code, which you can then use to ask better second-order questions.
What kind of detail should I look for before asking a follow-up?Look for something that does not match your expectation, such as an odd constant, an unfamiliar function, or a naming choice that seems deliberate. Those details are often the best entry point for a useful question.
How can I understand a whole repository if chat only handles a few files well?Serialize the repository into one pasteable text file. That lets you ask end-to-end questions across multiple files, instead of being limited to a single file’s local behavior.
What files should I keep when dumping a repo into chat?Keep source code, schemas, config, entry points, docs, and type/interface files. Cut noise like dependencies, build output, lock files, binaries, media, and tests unless you specifically need them.
Why is filtering files important when pasting a repo into an LLM?Because irrelevant code misleads the model. If you include too much noise, the AI spends attention on things that do not explain the architecture and gives you a worse answer.
How do numbers improve prompts compared with adjectives?Numbers constrain output precisely, while adjectives are vague. For example, “at most 10 nodes, 2–4 words each” gives the model a clear boundary, while “keep it simple” lets it improvise.
Why are toy examples useful when learning code with AI?Toy examples force the model to show the actual mechanics with real numbers. That makes abstract ideas like gradient accumulation concrete and easier to verify by hand.
Why does the chapter recommend writing a learning note?Because you forget quickly unless you actively retrieve and reprocess the information. A learning note, combined with rewriting and self-quizzing, helps convert short-term insight into lasting understanding.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Crack Any Codebase with AI ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • Crack Any Codebase with AI ebook for free