SKILL.md
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.