📚 The Context Problem
You want the elite knowledge in these PDFs. But dropping a document from 46 pages whole in Claude Code exceeds the context limit—and worse: it fills the window with summaries, thank-yous, and buzzwords. You need the valuable, not from the volume.
✗ Upload the entire PDF
- ✗Exceeds the token limit
- ✗Wastes expensive context on junk
- ✗Dilutes the signal with noise
- ✗Generic, superficial response
✓ Distill before using
- ✓Fits comfortably in the context
- ✓Only frameworks, numbers, and insights
- ✓Pure signal, high density
- ✓Reusable in any project
Huge PDFs
of context
value vs. volume
what matters
✂️ Chunking into blocks of ~10k tokens
The core idea behind lazy RAG: instead of processing everything at once, you slice. Extracts the text from the PDF, counts the tokens, and splits it into chunks of ~10,000 tokens. Each chunk fits comfortably in an API call.
// the concept of chunking — splitting by tokens
CHUNK_SIZE = 10_000 # tokens por bloco
texto = extrair_texto_do_pdf("bcg-guide.pdf") # via PyMuPDF
tokens = tokenizer.encode(texto) # cl100k_base
blocos = []
for i in range(0, len(tokens), CHUNK_SIZE):
pedaco = tokens[i : i + CHUNK_SIZE]
blocos.append(tokenizer.decode(pedaco))
# 1 PDF de 46 págs ≈ 3-4 blocos → cabem na API um a um
by block
extracts text
cl100k_base
not all at once
🧪 The synthesis prompt
This is where the quality of the cheat sheet comes from. The prompt instructs the model to extract only what's worthwhile — frameworks, statistics, insights, citations, terms — preserving numbers and cutting buzzwords. A block with no value gets the label [MINIMAL_CONTENT] and is discarded afterward.
// actual structure of the synthesis prompt (pdf_to_cheatsheet.py)
Você é um consultor criando um cheat sheet a partir deste documento. Extraia o conhecimento mais valioso: ## Conceitos & Frameworks → liste cada um em 1-2 frases ## Estatísticas críticas → preserve números e fontes ## Insights acionáveis → o que dá para implementar ## Citações notáveis → 2-3 frases de impacto ## Terminologia → defina termos e siglas Regras: seja conciso, NÃO generalize números, use bullets, negrito no termo na 1ª vez. Se o bloco for só sumário/ referências, responda: [MINIMAL_CONTENT: ...]
💡 The detail that makes a difference
The rule "DO NOT generalize numbers" is what separates a useful cheat sheet from an empty summary. “AI boosts productivity” is worthless; "40% productivity gain (Google Cloud, 2025)" is ammunition for your deliverable.
fixed extraction
doesn't generalize
only what's valuable
mark the gap
✨ Gemini 2.5 Flash: affordable and massive context window
The model that synthesizes. A deliberate choice: huge context, rock-bottom price. It makes it possible to distill an entire library of PDFs for pennies — with exponential retry and a delay between calls to respect the rate limit.
Huge context
Handles 10k-token blocks with room to spare — and responds without cutting off halfway.
Very low cost
The entire guide library costs pennies. It’s the same model that writes the deliverables in the Factory.
Resilient
Exponential retry (3 attempts) and ~5s delay between calls. A network error won’t bring down the process.
💡 Practical tip
This was a real error during development (in the video, Gemini's chunking failed on a file). Building in public means showing the mess: if an API error occurs, just ask Claude Code to run it again—the process resumes where it left off.
the model
huge
low cost
exponential
🧩 Build the cheat sheet
With the blocks synthesized, you rebuilds: combines them in the right order, discards those marked as empty, and generates a single Markdown file—with a header (source, date), numbered sections, and a "verify against the original" footer.
// reassembling the blocks into a final cheat sheet
cheat = cabecalho(fonte="bcg-guide.pdf", data=hoje)
for i, bloco in ordenar_por_indice(blocos_sintetizados):
if "[MINIMAL_CONTENT" in bloco and tamanho_util(bloco) < 500:
continue # descarta o vazio
cheat += f"## Seção {i+1}\n\n{bloco}\n"
cheat += rodape("verifique no documento original")
salvar("bcg-guide_TLDR.md", cheat) # 1 página, pronto
✓ Well-structured cheat sheet
- ✓Blocks in the original order
- ✓Empty entries discarded
- ✓Header with source and date
- ✓Footer requesting verification
✗ Poorly structured cheat sheet
- ✗Blocks out of order
- ✗Summary and acknowledgments in the middle
- ✗No source trail
- ✗Treated as absolute truth
by index
the empty ones
source + date
Final Markdown
🐍 pdf_to_cheatsheet.py in practice
You don’t write any of this by hand — the script already exists. It reads a folder of PDFs, saves progress to progress.json, skips blocks already completed, and accepts useful flags. Just ask Claude Code to run it.
// what you type to Claude Code
# dá uma olhada sem gastar API (só conta os blocos) python pdf_to_cheatsheet.py --dry-run # processa só um arquivo python pdf_to_cheatsheet.py --single-pdf "bcg-guide.pdf" # se o contexto encher ou a API falhar, rode de novo: # ele retoma pelos blocos que faltam (progress.json)
💡 Why resuming matters
O ProgressTracker saves each completed block. If the process fails at block 7 of 10, when you run it again, it skips the first 6 and continues. You doesn't pay twice through the same block — savings that add up in a large library.
without spending on API calls
a single file
resumes where you left off
saves what was done
✅ Module summary
🎯 Mission 2.2 — Your first cheat sheet
Get 1 consulting PDF (a free guide from McKinsey, BCG, KPMG, Google Cloud…) and turn it into a 1-page cheat sheet:
- Ask Claude Code to run the
pdf_to_cheatsheet.pyin it (or apply the block-by-block synthesis prompt). - Check: did frameworks, numbers, and insights remain—without buzzwords?
- Save as
fonte_TLDR.mdwith a header (source + date).
Success: 1 generated 1-page cheat sheet. What you gained: the first piece of your knowledge base—and the technique for distilling any PDF from now on.
Next module:
2.3 — Your consultant brain (organize multiple cheat sheets in a curated, injectable knowledge base)