liveBook · Manning

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

What you will learn in chapter 2 of Crack Any Codebase with AI

This chapter introduces a hands-on chat-based method for interrogating unfamiliar code with sharper follow-ups, bounded context, and prompts that produce useful explanations before scaling to workflows or agents.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This chapter introduces a hands-on chat-based method for interrogating unfamiliar code with sharper follow-ups, bounded context, and prompts that produce useful explanations before scaling to workflows or agents.

Key terms: sharper follow-ups, one-page overview, design insight, "What does this do?", generic text, effective follow-up question, chat, workflow, agent, context window

2.1 The first answer is always generic. That's the point.

This section shows that a generic first code explanation is a useful warm-up for finding specific follow-up questions, not the final understanding.

Key terms: generic summary, warm-up, vocabulary, sharper second question, vocab_size, 50,304, 50,257, multiple of 64, GPU efficiency, tensor cores

2.1.1 Which model should I pick?

This section gives a practical default for choosing an AI model and explains when privacy requirements justify running a local model instead.

Key terms: newest frontier model, reasoning, hallucinates, codebase too large to paste, design question, deliberation, open-source model, locally, cloud API, Llama

2.2 One file can't answer cross-file questions. 20 lines fix that.

This section shows how serializing the relevant repository into one pasteable text file lets chat answer cross-file questions, within context-window limits.

Key terms: single-file view, cross-file questions, whole-repo dump, end-to-end pipeline, serialize, crawl.py, pasteable file, EXTS, SKIP_DIRS, directory tree

2.2.1 What you cut matters as much as what you keep

This subsection explains how mechanically filtering repository noise gives an LLM a more accurate architectural view of a codebase.

Key terms: mechanically filter files, architecture, source of truth, SKIP_DIRS, EXTS, tests, dependencies, node_modules, build output, dist/

2.3 A concrete prompt beats a vague one, every time

This section shows that concrete prompt constraints produce useful codebase explanations by replacing vague requests with stories, numbers, and checkable examples.

Key terms: concrete prompt, story, category, numbers, adjectives, toy example, generic, abstract summary, constraints, concrete answer

2.3.1 Ask for a story, not a category

This section shows that asking AI for a concrete user story with a specific goal and frustration produces a more memorable understanding of a codebase than asking for audience or use-case categories.

Key terms: category questions, specific person, specific frustration, walk me through their experience, character, goal, obstacle, structure sticks, compresses information, nanoGPT

2.3.2 Constrain by numbers, not adjectives

This section shows that replacing vague descriptive requests with measurable numeric constraints produces clearer, more memorable AI output.

Key terms: output constraints, adjectives, numbers, concrete constraints, Mermaid flowchart, forward pass, nodes, arrow labels, implementation details, architecture

2.3.3 Ask for toy examples, not prose

This section shows that requesting a small numerical toy example makes an abstract code concept concrete enough to explain and verify.

Key terms: toy example, real numbers, abstract explanation, gradient_accumulation_steps, gradient accumulation, mini-batch, gradient, forward pass, backward pass, w

2.4 You'll forget two-thirds by tomorrow

This section explains why passive rereading quickly fades and introduces a repeatable AI-assisted learning-note cycle for retaining codebase understanding.

Key terms: forgetting curve, active retrieval, comprehension debt, learning note, Skeleton, Follow-up, Edit, Quiz, CODEBASE.md

2.4.1 Let AI write the first draft. It's disposable.

Use AI to generate a deliberately short, editable learning-note outline that prioritizes core concepts, important files, and their dependency chain.

Key terms: structured outline, polished draft, disposable scaffolding, learning note, simple markdown, aggressively short, Concepts I need to know, The important files, max 8 items, plain English

2.4.2 Follow up on the line you think you understand

This section shows how to turn a familiar-sounding jargon term into genuine understanding by asking a concrete follow-up that distinguishes it from a related concept.

Key terms: concepts table, jargon term, concrete example, self-attention, cross-attention, sequence, encoder-decoder, nanoGPT, decoder-only, next token

2.4.3 The step everyone skips is the only one that works

This section argues that rewriting an AI explanation in your own words exposes gaps in understanding and frees working memory for the next concept.

Key terms: rewording, working memory, self-attention, token, weighted average, attention weights, cross-attention

2.4.4 Re-reading feels like learning. It isn't.

This section replaces passive re-reading with difficult, code-specific self-quizzing and uses missed answers to drive the next learning cycle.

Key terms: illusion of competence, re-reading, test yourself, quiz questions, real file names, real variable names, multiple choice, missed questions, gaps in your knowledge, learning note

2.5 Chat can't scale past five files. That's not a bug.

This section explains why manual chat-based code exploration stops scaling and positions workflows and agents as progressively more autonomous alternatives.

Key terms: chat, codebase, follow-up questions, workflows, agents, repetitive tasks, explore the codebase independently, workflow, agent, drive every step

2.5.1 What's a workflow?

This section defines an LLM workflow as reusable code that calls a model across repository files, turning manual chat-based investigation into a controllable pipeline.

Key terms: programmatic API access, LLM API, chat window, script, workflow, for loop, pipeline, per-file approach, repository, what the model sees

2.5.2 What's an agent?

This section defines coding agents, shows how they autonomously inspect and act on a codebase, and explains their coverage-versus-concentration tradeoff with chat.

Key terms: agent, LLM, goal, autonomously, read, write, and run cycle, CODEBASE.md, get_batch(), np.memmap, concentration, coverage

2.5.3 Chained together, each tool covers the next one's weakness

This section explains how chat, workflows, and agents compensate for one another’s limits when chained into a codebase-understanding loop.

Key terms: chat, workflow, agent, chaining, structured output, exploration, open-ended question, conversational thread, repeatable process, consistent pipeline

2.6 Summary

This summary recaps a disciplined chat-based learning loop—careful context, precise prompts, follow-ups, and notes—and positions chat as preparation for scalable workflows and agents.

Where this is used later

Concepts explained in this chapter

← Chapter 1: The shift: Code is free now. Understanding isn't. Chapter 3: Workflow: Build your own codebase knowledge builder →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.