TL;DR: Split the file on semantic boundaries (functions, classes, diff hunks) instead of cutting at an arbitrary token offset, add overlap between chunks, and verify every changed line was covered. Cutting every N tokens slices through functions and leaves each chunk with dangling references, so the model either hallucinates the missing half or misses bugs that only make sense across the cut.

```text
LLM context window too small for full-file review: chunking strategy that fails
```

1. Split the file on semantic boundaries: functions, classes, or diff hunks. Never cut mid-function.
   Expected: no chunk starts or ends in the middle of a function.
2. Give each chunk overlap: include the trailing lines of the previous chunk at the start of the next one.
   Expected: boundary code appears in two adjacent chunks.
3. Attach a rolling summary to each chunk: what the file does, plus the key types and globals defined so far.
   Expected: later chunks reference earlier definitions correctly.
4. Review each chunk and record which changed lines it covered.
   Expected: a coverage map from changed lines to chunks.
5. Verify the coverage map: every changed line must appear in at least one chunk. If any do not, re-chunk.
   Expected: zero uncovered changed lines.
6. Merge findings and dedupe anything reported in the overlap region twice.
   Expected: one finding per issue, citing its true location.

## Use this when
- a single file is too large for one review call
- naive fixed-size chunking misses bugs or invents context
- the file's changed lines span the whole file

## Not for this skill when
- the file fits in context (chunking adds nothing)
- the problem is total diff size across many files (batch by file instead)
- the model already handles long context well (measure before chunking)

## Variant phrasings
### chunked file review missed a bug at the chunk boundary
### splitting a large file for review lost cross-function context
### naive token chunking broke the code review

## Why it happens
Fixed-size token chunking is content-blind: it cuts wherever the counter lands, which is usually mid-function. Each chunk then has unresolved references to code it cannot see. The model fills the gap by guessing (hallucination) or stays silent about anything needing the other half (missed bugs). Semantic boundaries plus overlap keep each chunk self-contained enough to review honestly.

## Edge cases
- Extremely long single functions still exceed a chunk; split those at logical sub-blocks and note the split.
- The rolling summary can drift from the code; regenerate it from the actual chunks, not from the model's memory.
- Overlap too small misses boundary bugs; overlap too large wastes budget. A screenful of lines is a good default.
- Dedupe on location plus rule, not on text similarity.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_9T33Ns6TiH32UXPJxUxFwQ
