How We Built a Code-Aware Grammar Checker on DeepSeek (and Why It Matters for Devs)
Every developer has felt this: you paste a README paragraph into a grammar checker, and it "corrects" maxRetries into "maximum retries", or flags kubectl get pods as a fragmented sentence. The checker doesn't know code f
Every developer has felt this: you paste a README paragraph into a grammar checker, and it "corrects" maxRetries into "maximum retries", or flags kubectl get pods as a fragmented sentence. The checker doesn't know code from prose, so it edits the one thing you can't change.
The Core Problem: Code Is Not Prose
Grammar models are trained on books and articles. To them, a line like cache_size = config.limit ?? 512 is just a very weird sentence with weird words. They will "improve" it - and break your code. The fix is not a better model; it is a better pipeline.
Architecture: Parse First, Reason Second
| Stage | What happens |
|---|---|
| 1. Split | Markdown/HTML is split into prose spans and code spans (fenced blocks, inline code, identifiers). |
| 2. Protect | Code spans are marked untouchable. Identifiers, commands, flags are never rewritten. |
| 3. Reason | Only prose spans go to the language model for grammar/style suggestions. |
| 4. Merge | Suggestions re-injected next to original code, zero mutation of identifiers. |
The result: your cache_size comes back as cache_size, and your real English mistakes still get caught.
Why DeepSeek Powers the Reasoning Layer
For this job the model has to do one thing well: edit short prose while respecting "don't touch the code". We evaluated the usual suspects and landed on DeepSeek for three practical reasons:
- Cost: at our volume, a GPT-4-class endpoint would be ~10x the bill for no measurable quality gain on grammar/style edits.
- Latency: grammar checks are interactive - users expect sub-second feedback. DeepSeek's smaller variants hold up.
- Instruction following: the "leave code alone" constraint is a system-prompt discipline the model follows reliably.
Try It
The checker is live and free (10 checks/day, no signup): code-aware grammar checker. If you write docstrings or READMEs, also try the paraphraser - same code-aware protection, so your identifiers survive the rewrite.
We open-sourced the parsing approach; the lesson that matters most is that the model choice is secondary to the pipeline. Get the split-and-protect stage right, and almost any modern model will do.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.