---
name: plain-text-normalization
source: https://app.decimal.ai/s/plain-text-normalization@1/SKILL.md
source_sha256: c8343b88a639
---

# Plain-text normalization

## Contract

Enforces three fixed plain-text conventions when cleaning up prose without
rewording it: (1) every sentence starts with a capital letter, (2) exactly one
space separates one sentence from the next, and (3) no line carries trailing
whitespace. Apply whenever asked to tidy, clean up, or make presentable a block
of raw text — a pasted note, chat transcript, dictation, or scraped paragraph —
where the job is to fix spacing and capitalization, not to rewrite the wording.
(Trailing spaces below are shown as `␣` so they are visible.)

## Rules

1. **Sentence-initial capitalization.** The first alphabetic character of every
   sentence is uppercase. A sentence begins at the very start of the text and
   immediately after every sentence-ending `.`, `?`, or `!`. Uppercase that first
   letter even if the input typed it lowercase. Do not change the case of any
   other word (leave existing proper nouns and mid-sentence words as-is).

2. **Exactly one space after a sentence-ending period.** Between a period that
   ends a sentence and the first character of the next sentence there is exactly
   ONE ordinary space:
   - Never ZERO — a period glued to the next word (`done.Next`, `done.next`) gets
     a single space inserted (`done. Next`).
   - Never TWO OR MORE — a run of spaces (`done.  Next`, `done.   Next`, or a tab)
     collapses to one (`done. Next`).
   This is the modern single-space-between-sentences convention, not the
   typewriter two-space habit. The same one-space rule applies after a sentence
   that ends in `?` or `!`.

3. **No trailing whitespace.** Strip every space and tab that sits at the end of a
   line (before the newline) and at the very end of the text. A blank line becomes
   truly empty — no spaces on it. This never removes meaningful content, only the
   invisible run-off at line ends.

4. **Preserve the wording.** Change ONLY capitalization and whitespace. Do not add,
   drop, reorder, or reword sentences; do not touch internal punctuation, numbers,
   or line breaks other than trailing-space removal. The output is the same text,
   correctly cased and spaced.

## Worked examples

**Rule 1 — a lowercase sentence start is capitalized (both the first word and the
one after a period).**

```
BEFORE:  the kettle boiled. we brewed a fresh pot.
AFTER:   The kettle boiled. We brewed a fresh pot.
```

**Rule 2 (missing space) — a period glued to the next sentence gets one space.**

```
BEFORE:  Add the flour.Stir gently until it thickens.
AFTER:   Add the flour. Stir gently until it thickens.
```

**Rule 2 (extra spaces) — two spaces after the period collapse to one.**

```
BEFORE:  The trail was steep.  The summit view repaid every step.
AFTER:   The trail was steep. The summit view repaid every step.
```

**Rule 1 + 2 combined — glued AND lowercase.**

```
BEFORE:  the garden needs water.the tomatoes are wilting.
AFTER:   The garden needs water. The tomatoes are wilting.
```

**Rule 3 — trailing spaces at line ends are stripped (`␣` = a trailing space).**

```
BEFORE:  Pack the tent.␣␣
         Fill the water bottles.␣
AFTER:   Pack the tent.
         Fill the water bottles.
```

**Rule 4 — spacing/case only; wording is untouched (a `?` sentence too).**

```
BEFORE:  did the ferry leave?we missed it by minutes.
AFTER:   Did the ferry leave? We missed it by minutes.
```

## Edge cases & exceptions

- **Abbreviations are not sentence ends.** A period inside `e.g.`, `i.e.`, `etc.`,
  `Dr.`, `Mr.`, `U.S.`, `a.m.` does NOT start a new sentence: keep the following
  word's case unchanged and do not force a capital. `we ship many formats, e.g.
  json and yaml.` → `We ship many formats, e.g. json and yaml.` (leading `we`
  capitalized; `json` stays lowercase).
- **Decimals and version numbers.** The dot in `3.14`, `v2.0`, or `1.5 cups` is not
  a sentence terminator — never insert a space and never capitalize after it.
- **Dotted tokens.** Dots inside `config.yaml`, `example.com`, or `a.b.c` are part
  of the token; do not treat them as sentence breaks.
- **Ellipsis.** Leave `...` (or `…`) intact — do not split it into separated
  periods and do not insert spaces between the dots.
- **Already-correct text.** If a sentence is already capitalized and single-spaced,
  leave it exactly as-is; do not "re-fix" what already conforms.
- **First line of the text.** Its opening letter is capitalized like any sentence
  start, even though no period precedes it.

## Do / Don't

- **Never** leave a sentence starting with a lowercase letter. **Always** uppercase
  the first letter of every sentence.
- **Never** keep two-or-more spaces after a sentence-ending period. **Always**
  collapse them to exactly one.
- **Never** leave a period glued to the next sentence. **Always** insert one space.
- **Never** leave trailing spaces or tabs at the end of a line. **Always** strip
  them.
- **Never** reword, reorder, or delete the author's sentences. **Always** change
  only capitalization and whitespace.
- **Never** treat an abbreviation dot or a decimal point as a sentence boundary.
  **Always** limit the sentence-boundary rules to real sentence ends.

## Common mistakes

- Mirroring the input's spacing: passing through the two spaces after a period that
  the source used instead of normalizing to one.
- Failing to split a glued `word.Word`, leaving the two sentences run together.
- Capitalizing the first sentence but missing the capital on later sentences that
  followed a period on the same line.
- Leaving invisible trailing spaces at line ends because they are not visible in
  the rendered text.
- Over-correcting: capitalizing the word after `e.g.` / `Dr.` / a decimal, or
  inserting a space inside `3.14` or `config.json`.
- Silently rewording or "improving" the sentences instead of only fixing spacing
  and case.

## Quick checklist

- [ ] Every sentence starts with a capital letter (first sentence and each one
      after a `.`, `?`, or `!`).
- [ ] Exactly one space after each sentence-ending period — no glued periods, no
      double spaces.
- [ ] No trailing spaces or tabs at any line end.
- [ ] Wording, order, numbers, and internal punctuation unchanged.
- [ ] Abbreviation dots, decimals, and dotted tokens not treated as sentence ends.
