When 50 Documents Meet 20 Pages: A Context Management Problem
Twenty pages. That was the limit my professor set for our ME4231 Motion Control finalâbring anything you want, as long as it fits on ten double-sided sheets. I stared at fifty-plus documents of control theory, from Bode plots to PID tuning to state-space representations, and wondered how any of this would compress down to something I could actually use.
I decided to use Claude Code to help organize this mountain of material. What I learned had less to do with control systems and more to do with how AI tools handle large amounts of contextâand how that constraint shapes everything.
The Scope of the Problem
Motion Control covers the mathematics of how systems respond to inputs over time: transfer functions, frequency response, stability analysis. The material is dense with equations, block diagrams, and interconnected concepts where understanding one topic requires referencing three others.
The course materials included:
- 11 lecture PDFs (some 40+ pages of dense derivations)
- 11 lab assignments with MATLAB implementations
- Board notes, annotated versions, and review materials
- Reference documents totaling over 50 individual files
My plan was straightforward: have Claude Code read through everything and generate a dense HTML file I could print using Chromeâs headless mode. HTML gave me precise control over layout, column formatting, and font sizing that Word or LaTeX would have fought me on.
The execution was anything but straightforward.
What Happens When You Feed an AI Too Much
My first attempt was simple: ask Claude to read a lecture PDF and summarize the key formulas. For a 40-page document on frequency response methods, this failed immediately. The tool returned errors, and responses came back truncated mid-sentence.
The problem is fundamental to how these systems work. Large language models have context windowsâlimits on how much text they can process at once. Exceed that limit, and things break in unpredictable ways.
Iâd ask Claude to extract all transfer function examples from a lecture and get back:
The lecture covers several transfer function forms:
1. First-order: G(s) = K/(Ďs + 1)
2. Second-order: G(s) = KĎ_n²/(s² + 2ÎśĎ_n¡s + Ď_n²)
3. [Response truncated]
Everything after the cutoffâincluding the most complex examples I actually neededâvanished.
The Chunking Solution
The fix came from thinking about how humans handle large documents. We donât read a 50-page technical document in one sitting. We break it into pieces.
I started giving Claude explicit instructions:
Read lecture_07_frequency_response.pdf in chunks. For a 40-page document,
process pages 1-15 first, then pages 12-25, then pages 22-40. Summarize
each chunk separately, then I'll ask you to combine them.
That overlapâgoing back 3-4 pages when starting a new chunkâturned out to be crucial. Page 14 of one lecture ended with: âThe phase margin can be found byâŚâ
Page 15 continued: ââŚlocating where the magnitude plot crosses 0 dB and reading the phase at that frequency.â
Without overlapping chunks, the first section would end mid-sentence, and the second would start without context. The overlap kept complete concepts intact.
For my 50+ documents, I settled on roughly 20% overlapâenough to capture any concept spanning a page break without redundantly processing too much content.
The Technical Implementation
The actual workflow looked like this:
- List all PDFs in the course materials directory
- For each PDF, determine page count and calculate chunk boundaries
- Process each chunk, extracting formulas, definitions, and key concepts
- Combine chunks into a single document per lecture
- Generate HTML with a two-column layout optimized for dense information
- Use
chrome --headless --print-to-pdfto render the final output
Chromeâs headless mode was essential because it renders CSS exactly as a browser would, giving me precise control over margins, column breaks, and font scaling.
What Iâd Do Differently
The â20% overlapâ rule worked for lecture notes, but it wasnât universal. Lab assignments with long code blocks needed more overlap because a MATLAB function spanning two pages would get split awkwardly. Reference tables needed less because each row was self-contained.
Context management isnât a formula you can apply mechanically. You need to understand the structure of your source material and adjust accordingly. Dense mathematical derivations require different handling than bullet-pointed summaries.
The Real Takeaway
Tomorrow Iâll print this HTML file and discover whether my digital formatting survives contact with physical paper. Twenty pages of control theory, condensed from material that would stack an inch thick if printed directly.
Whether I pass the final depends on how well I actually learned the material. But the process of building this cheat sheet taught me something the course itself didnât cover: systems of all kindsâwhether control loops or language modelsâneed their inputs structured appropriately to produce useful outputs.
The phase margin formula wonât help me remember that lesson. But the three failed attempts before I figured out chunking certainly will.