DEV Community

EvvyTools
EvvyTools

Posted on

How to Add a Readability Check to a Documentation CI Pipeline Without Blocking Every Pull Request

Docs teams that adopt readability tooling usually make the same early mistake: wiring the check up as a hard CI gate on day one. A new contributor pushes a perfectly reasonable API doc, the pipeline fails on a grade-level threshold nobody explained to them, and the whole team quietly starts ignoring the check within a month. Here is a sequence that avoids that.

Step 1: Run the check in report-only mode first

Before any pull request can fail because of it, add the readability check as a CI step that posts a comment with the score but does not block merging. This gives you real data on your existing docs corpus, what your typical grade level actually is today, before you pick a threshold that might be unrealistic for your content.

Most CI systems (GitHub Actions, GitLab CI, CircleCI) support posting a PR comment from a script's output. Point that script at a reading level analyzer or an equivalent formula library, and have it comment the Flesch-Kincaid grade level and word count on every changed markdown file.

Step 2: Collect two to three weeks of baseline data

Let the report-only check run across real pull requests for a few weeks. Look at the range of scores your existing, already-published docs are landing in. If your published API reference sits at grade 12 to 14 because of unavoidable technical vocabulary, a rule that requires grade 9 or below is going to fail on legitimate content constantly.

This step also surfaces which formula fits your content best. If Gunning Fog consistently reports two to three grades higher than Flesch-Kincaid on your docs because of technical terms tripping its complex-word counter, that is useful to know before you commit to enforcing either one.

Step 3: Set a threshold based on your own baseline, not a generic target

Once you have real numbers, set the CI threshold at something like "one grade level above your current median," not an arbitrary number pulled from a generic style guide that was never written with your docs in mind. This keeps the check meaningful: it catches genuine outliers, sentences or pages that got noticeably harder to read, without punishing normal technical writing.

Step 4: Make the failure message actionable

A failing check that just prints "readability score too high" teaches a contributor nothing. Have the script identify the specific sentences driving the score up, typically the longest ones or the ones with the most polysyllabic words, and print those in the CI output. Contributors who can see exactly which sentence to shorten will fix it in one commit instead of guessing.

Step 5: Exempt reference material explicitly, not implicitly

Decide upfront which doc types are exempt from the grade-level ceiling (API references, changelogs with version-specific terminology) versus which types should be held to it strictly (onboarding guides, tutorials, README introductions). Encode that as a path-based rule in the CI config rather than leaving it to reviewer judgment, which drifts over time and creates inconsistent enforcement.

Following this sequence, report-only first, baseline before threshold, actionable failures, explicit exemptions, gets you a check that catches real regressions instead of one that gets muted in the team's notification settings within a month.

For background on why different formulas can disagree by several grade levels on identical text, see the longer explainer on why readability scores disagree on the same paragraph.

Handling the edge cases that break naive implementations

A few situations trip up readability CI checks that work fine in testing. Code blocks and inline code spans inside markdown will confuse a formula that is not stripping them first, since a long variable name or a multi-line code sample will get counted as extremely long "words" and "sentences," wrecking the score for a page that is otherwise perfectly readable prose. Make sure your script strips fenced code blocks and inline code spans before running any formula against the remaining text.

Tables and bullet lists have a similar problem: formulas built around sentence structure do not know what to do with a table cell or a one-word bullet point, and will sometimes report wildly inflated or deflated scores on pages that are mostly structured data rather than prose. Consider running the check only against prose paragraphs, and skipping table cells, code blocks, and single-line list items entirely.

Auto-generated content, API reference pages built from OpenAPI specs or docstrings, should usually be excluded from the check altogether rather than exempted case by case. That content is typically generated from a template your team does not hand-edit line by line, so a readability score on it is not actionable in the way a score on hand-written prose is.

What good looks like after a few months

Teams that get this right end up with a CI check that fires rarely, catches real problems when it does, and gets fixed in a single commit each time. The failure comments reference specific sentences, the threshold reflects the team's actual writing rather than a generic target, and reference material with an unavoidably higher technical vocabulary floor is excluded rather than fought against. That is a very different experience than the blanket, ungraduated check most teams start with, and it is the difference between a tool the team trusts and one they quietly disable six months later.

Rolling this out to a team that has never had a readability gate before

If your team has zero existing tooling around prose quality, readability is a reasonable first check to introduce, precisely because it can start as report-only and never actually block anyone while you build trust in it. Announce it as an informational addition before it ships, not a new requirement. Nothing kills adoption of a quality gate faster than a team discovering a new blocking check in their pull request queue with no warning and no context for why the number matters.

Pair the rollout with a short internal doc, even three or four sentences, explaining which formula you picked, why, and what the current baseline looks like. This matters more than the tooling itself. A contributor who understands "we use Flesch-Kincaid, our docs currently average grade 10, and pages above grade 13 usually mean an unnecessarily long sentence, not necessarily bad writing" will engage with a failing check productively. A contributor who just sees a red X with an unfamiliar formula name attached will not.

Measuring whether the check is actually helping

After a quarter or two of running the check as a hard gate, look back at what it actually caught. Good outcomes look like: a handful of genuinely improved sentences, contributors who mention the check positively or reference it when writing new docs, and a stable or slowly improving baseline score over time. Bad outcomes look like: contributors routinely disabling or overriding the check, a growing list of path-based exemptions because the threshold keeps hitting content it should not, or the check firing so rarely that nobody remembers it exists. If you are seeing the bad outcomes, it is worth revisiting the threshold and the exemption list rather than assuming the check itself was a mistake, since most of these failure modes trace back to a threshold that was set before the baseline data step above was actually done.

Tooling references: GitHub Actions documentation covers how to post PR comments from a workflow script, the textstat project on PyPI ecosystem hosts several open-source readability formula libraries you can wire into a pipeline directly, and the Vale linter project is a popular open-source tool for enforcing broader prose style rules in CI alongside readability scoring.

Top comments (0)