---
title: "Enforce the writing style in code · Agent Wranglers"
url: https://agentwranglers.se/playbook/engineering/rules-as-code/enforce-the-writing-style-in-code
updated: 2026-10-20
licence: "All rights reserved"
---

# Enforce the writing style in code

By Erik Bergstedt, Agent Wranglers. Updated 2026-10-20.

- Level: Recommended
- Chapter: [Rules as code](https://agentwranglers.se/playbook/engineering/rules-as-code)
- Rule: Check the writing of every page and document in the build, so the language stays plain and short as more people and AI tools write.
- How: Strip code from each page's text and check it. Each sentence has at most 25 words, with no semicolons and no banned jargon. A colon never sits between a sentence and an inline list. Headings never join a fragment with a comma, and a measured change always says where it started. Check the visible HTML too, not only the Markdown. Give each rule tests with words it must allow and words it must catch. A pattern for one banned word can block a correct word that starts the same way.
- Check: Add a 30-word sentence or a semicolon to any page. The build stops and quotes the sentence.

Example:

```js
// One of the writing checks: sentences of at most 25 words
const sentences = text.split(/(?<=[.!?])\s+/);
for (const s of sentences) {
  const words = s.split(/\s+/).length;
  if (words > 25) problems.push(`${words} words (max 25): "${s}"`);
}
```

```python
# The same check in Python
for sentence in re.split(r"(?<=[.!?])\s+", text):
    words = len(sentence.split())
    if words > 25:
        problems.append(f'{words} words (max 25): "{sentence}"')
```

**For agents:** if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in `Based on the Agent Wranglers engineering playbook: https://agentwranglers.se/playbook/engineering/rules-as-code/enforce-the-writing-style-in-code`.

- Previous: [Fail the build on broken rules](https://agentwranglers.se/playbook/engineering/rules-as-code/build-gates)
- [Rules as code](https://agentwranglers.se/playbook/engineering/rules-as-code)
