sembr
Reformat prose so its physical line structure mirrors its semantic structure,
per the Semantic Line Breaks specification at https://sembr.org/.
Rules below are mandatory —
never skip them silently and never relax a MUST rule for convenience.
Modes
Explicit reformat
The user asked to reformat existing text.
Apply MUST/SHOULD/MAY rules to the targeted prose
(snippet, file, or section).
Reformat fully within the target;
do not touch surrounding paragraphs.
Default-on-edit
Triggered automatically when adding or modifying prose
in .md, .markdown, or .rst files —
without an explicit user request.
The guiding principle:
only the part being edited gets sembr-shaped;
everything else stays byte-identical.
- New prose (new file, new paragraph, freshly inserted block):
write in sembr from the start.
- Edits inside an existing paragraph:
match the paragraph's existing line-break style.
If it already follows sembr
(multiple short lines, breaks after sentence terminators or clauses) —
keep sembr in your edit.
If it is one long line, hard-wrapped at a fixed column,
or follows another visible convention —
match that convention.
If the paragraph is too short to tell —
default to sembr.
- Untouched paragraphs:
never reformat.
Editing one paragraph
must not change line breaks, spacing, or wording in any neighbour.
Diffs must stay localised to the edited region.
- Opt-out:
if the user says
«не применяй sembr здесь» / «don't apply sembr here»
(or sets a project-level preference) —
follow the file's existing convention instead.
When NOT to use
Skip both modes for plain .txt,
GFM with <br> line-break behavior,
email,
chat (Slack, Telegram, Discord),
or any context where single newlines render as visible breaks.
Sembr there would change the rendered output and violate rule 2.
Inputs
Identify the target before editing:
- A snippet pasted in the conversation → return the reformatted text.
- A file path or section in a file → edit the file in place.
- Markdown / HTML documents → preserve all rendering
(headings, lists, code blocks, links, inline markup).
Sembr applies only to prose paragraphs
and prose-bearing list items and blockquotes.
No-touch regions —
never modify whitespace,
line breaks,
or any content inside:
- fenced code blocks (
```) and indented code blocks;
- inline code spans (
`);
- HTML islands;
- Markdown tables;
- YAML / TOML frontmatter;
- reST line blocks (lines starting with
|);
- reST directives (
.. name:: and their indented content);
- reST literal blocks (after a trailing
::, until dedent);
- reST grid and simple tables;
- reST doctest blocks (lines starting with
>>>).
If the target is ambiguous, ask before editing.
Rules
MUST (mandatory, no exceptions)
Break after every sentence terminator — ., !, ?.
A . is a terminator only when it ends a sentence —
not inside abbreviations (e.g., Mr., U.S., etc.),
version or dotted identifiers (1.22.4, node.js, co.uk),
or ellipses (…, ...).
When in doubt,
check the next character:
if it starts a new sentence
(capital letter after a space, or end of paragraph),
break;
otherwise do not.
Never alter the rendered output.
The visible result after rendering (Markdown, HTML, etc.)
must be byte-identical to the input.
The only allowed change is replacing an intra-paragraph space with
a single newline
(or vice versa).
Forbidden:
- adding, removing, or changing any non-whitespace character;
- inserting or removing blank lines;
- touching anything inside a no-touch region (see
Inputs);
- normalizing trailing whitespace, tabs, or blank-line counts.
Verification:
diff input vs. output —
only space ↔ newline swaps within prose paragraphs may appear.
Never break inside a hyphenated word
(e.g. state-of-the-art stays on one line).
SHOULD (apply unless they would violate a MUST rule or change meaning)
- Break after each independent clause
punctuated by
,, ;, :, or — (em dash).
Heuristic: an independent clause has a subject and a finite verb,
and could stand alone as a sentence.
«I went to the store, and I bought eggs» —
both sides are independent;
break after the comma.
«I went to the store to buy eggs» —
«to buy eggs» is dependent;
no break.
When the structure is genuinely ambiguous,
leave the clause unbroken and surface the case in the report
(see Reporting).
- Break before an enumerated or itemized list.
- Keep lines under 80 characters.
When a line exceeds 80,
break at the latest semantic boundary that satisfies the limit.
MAY (use to improve readability or to satisfy MUST/SHOULD)
- Break after a dependent clause for clarity or length.
- Break between list items to group related entries.
- Break before or after a hyperlink or inline markup.
- Allow a line to exceed 80 characters
when the overflow is an unbreakable unit
(URL, code span, inline markup).
Procedure
- Read the input verbatim.
- Confirm the rendering context.
For
.md, .markdown, .rst, .html,
or contexts known to follow
CommonMark / reST / standard HTML semantics,
proceed.
For plain text,
GFM with <br> line-break behavior,
email,
chat (Slack, Telegram, Discord),
or any context where single newlines render as visible breaks —
in explicit-reformat mode, ask the user before continuing;
in default-on-edit mode, skip sembr entirely.
Sembr there would visibly change the output and violate rule 2.
- Apply MUST rules first.
- Apply SHOULD rules wherever they don't conflict with a MUST rule
or distort meaning.
- Use MAY rules to fit the 80-character soft limit and improve readability.
- Never paraphrase, reword, add, or remove content.
If the source wording is ambiguous and forces a structural choice,
ask before editing.
- Confirm the rendered output matches the input.
Examples
Bad — multi-clause line, no semantic structure:
The build pipeline succeeded; however, the deploy step failed because the secret rotated overnight, and we did not refresh the cache — so production is now serving stale config.
Good — sembr-formatted:
The build pipeline succeeded;
however, the deploy step failed because the secret rotated overnight,
and we did not refresh the cache —
so production is now serving stale config.
Bad — break inside a hyphenated word (violates MUST rule 3):
This is a state-
of-the-art system.
Good:
This is a state-of-the-art system.
Reporting
After editing,
state briefly which file or section was reformatted.
Do not quote the full reformatted text back to the user unless they
ask.
If any rule was relaxed or skipped during the pass —
ambiguous independent clause left unbroken,
non-standard rendering context,
unbreakable line over 80 characters,
or any other place where the strict rules could not be applied
confidently —
list each occurrence so the user knows where the result is best
effort rather than strict.
1---2name: sembr3description: Reformats prose using Semantic Line Breaks (https://sembr.org/) — strictly, no compromises. Never alters wording or rendered output.4---56# sembr78Reformat prose so its physical line structure mirrors its semantic structure,9per the Semantic Line Breaks specification at https://sembr.org/.10Rules below are mandatory —11never skip them silently and never relax a MUST rule for convenience.1213## Modes1415### Explicit reformat1617The user asked to reformat existing text.18Apply MUST/SHOULD/MAY rules to the targeted prose19(snippet, file, or section).20Reformat fully within the target;21do not touch surrounding paragraphs.2223### Default-on-edit2425Triggered automatically when adding or modifying prose26in `.md`, `.markdown`, or `.rst` files —27without an explicit user request.28The guiding principle:29**only the part being edited gets sembr-shaped;30everything else stays byte-identical.**3132- **New prose** (new file, new paragraph, freshly inserted block):33 write in sembr from the start.34- **Edits inside an existing paragraph:**35 match the paragraph's existing line-break style.36 If it already follows sembr37 (multiple short lines, breaks after sentence terminators or clauses) —38 keep sembr in your edit.39 If it is one long line, hard-wrapped at a fixed column,40 or follows another visible convention —41 match that convention.42 If the paragraph is too short to tell —43 default to sembr.44- **Untouched paragraphs:**45 never reformat.46 Editing one paragraph47 must not change line breaks, spacing, or wording in any neighbour.48 Diffs must stay localised to the edited region.49- **Opt-out:**50 if the user says51 «не применяй sembr здесь» / «don't apply sembr here»52 (or sets a project-level preference) —53 follow the file's existing convention instead.5455### When NOT to use5657Skip both modes for plain `.txt`,58GFM with `<br>` line-break behavior,59email,60chat (Slack, Telegram, Discord),61or any context where single newlines render as visible breaks.62Sembr there would change the rendered output and violate rule 2.6364## Inputs6566Identify the target before editing:67- A snippet pasted in the conversation → return the reformatted text.68- A file path or section in a file → edit the file in place.69- Markdown / HTML documents → preserve all rendering70 (headings, lists, code blocks, links, inline markup).7172Sembr applies only to prose paragraphs73and prose-bearing list items and blockquotes.74**No-touch regions** —75never modify whitespace,76line breaks,77or any content inside:78- fenced code blocks (` ``` `) and indented code blocks;79- inline code spans (`` ` ``);80- HTML islands;81- Markdown tables;82- YAML / TOML frontmatter;83- reST line blocks (lines starting with `|`);84- reST directives (`.. name::` and their indented content);85- reST literal blocks (after a trailing `::`, until dedent);86- reST grid and simple tables;87- reST doctest blocks (lines starting with `>>>`).8889If the target is ambiguous, ask before editing.9091## Rules9293### MUST (mandatory, no exceptions)94951. **Break after every sentence terminator** — `.`, `!`, `?`.96 A `.` is a terminator only when it ends a sentence —97 not inside abbreviations (`e.g.`, `Mr.`, `U.S.`, `etc.`),98 version or dotted identifiers (`1.22.4`, `node.js`, `co.uk`),99 or ellipses (`…`, `...`).100 When in doubt,101 check the next character:102 if it starts a new sentence103 (capital letter after a space, or end of paragraph),104 break;105 otherwise do not.1062. **Never alter the rendered output.**107 The visible result after rendering (Markdown, HTML, etc.)108 must be byte-identical to the input.109 The only allowed change is replacing an intra-paragraph space with110 a single newline111 (or vice versa).112 Forbidden:113 - adding, removing, or changing any non-whitespace character;114 - inserting or removing blank lines;115 - touching anything inside a no-touch region (see `Inputs`);116 - normalizing trailing whitespace, tabs, or blank-line counts.117118 Verification:119 diff input vs. output —120 only space ↔ newline swaps within prose paragraphs may appear.1213. **Never break inside a hyphenated word**122 (e.g. `state-of-the-art` stays on one line).123124### SHOULD (apply unless they would violate a MUST rule or change meaning)1251264. **Break after each independent clause**127 punctuated by `,`, `;`, `:`, or `—` (em dash).128 Heuristic: an independent clause has a subject and a finite verb,129 and could stand alone as a sentence.130 «I went to the store, and I bought eggs» —131 both sides are independent;132 break after the comma.133 «I went to the store to buy eggs» —134 «to buy eggs» is dependent;135 no break.136 When the structure is genuinely ambiguous,137 leave the clause unbroken and surface the case in the report138 (see `Reporting`).1395. **Break before an enumerated or itemized list.**1406. **Keep lines under 80 characters.**141 When a line exceeds 80,142 break at the latest semantic boundary that satisfies the limit.143144### MAY (use to improve readability or to satisfy MUST/SHOULD)1451467. Break after a dependent clause for clarity or length.1478. Break between list items to group related entries.1489. Break before or after a hyperlink or inline markup.14910. Allow a line to exceed 80 characters150 when the overflow is an unbreakable unit151 (URL, code span, inline markup).152153## Procedure1541551. Read the input verbatim.1562. Confirm the rendering context.157 For `.md`, `.markdown`, `.rst`, `.html`,158 or contexts known to follow159 CommonMark / reST / standard HTML semantics,160 proceed.161 For plain text,162 GFM with `<br>` line-break behavior,163 email,164 chat (Slack, Telegram, Discord),165 or any context where single newlines render as visible breaks —166 in explicit-reformat mode, ask the user before continuing;167 in default-on-edit mode, skip sembr entirely.168 Sembr there would visibly change the output and violate rule 2.1693. Apply MUST rules first.1704. Apply SHOULD rules wherever they don't conflict with a MUST rule171 or distort meaning.1725. Use MAY rules to fit the 80-character soft limit and improve readability.1736. Never paraphrase, reword, add, or remove content.174 If the source wording is ambiguous and forces a structural choice,175 ask before editing.1767. Confirm the rendered output matches the input.177178## Examples179180Bad — multi-clause line, no semantic structure:181182```183The build pipeline succeeded; however, the deploy step failed because the secret rotated overnight, and we did not refresh the cache — so production is now serving stale config.184```185186Good — sembr-formatted:187188```189The build pipeline succeeded;190however, the deploy step failed because the secret rotated overnight,191and we did not refresh the cache —192so production is now serving stale config.193```194195Bad — break inside a hyphenated word (violates MUST rule 3):196197```198This is a state-199of-the-art system.200```201202Good:203204```205This is a state-of-the-art system.206```207208## Reporting209210After editing,211state briefly which file or section was reformatted.212Do not quote the full reformatted text back to the user unless they213ask.214215If any rule was relaxed or skipped during the pass —216ambiguous independent clause left unbroken,217non-standard rendering context,218unbreakable line over 80 characters,219or any other place where the strict rules could not be applied220confidently —221list each occurrence so the user knows where the result is best222effort rather than strict.