Linters keep an agent's code in shape. Almost nothing does the same for its sentences. subedit is a subeditor for AI agents. It checks every sentence an agent writes into your repository, autofixes the layout without a word, and hands back to the model only what needs rewriting, with the fix stated. Surfaces lists the kinds of file it reads.
- Built for Agents: a post-edit hook for Claude Code and Codex checks each file an agent writes, as it lands.
- Silent Autofix, Stated Rewrites: layout and spacing are autofixed without a message, and only a finding that needs the sentence's meaning goes back, with its fix stated.
- Sentence-Aware Layout: a comment breaks only at a comma that ends a clause, and a Markdown paragraph stays on one line.
- Never Touches Code: tree-sitter finds the prose, so code, string literals, and commented-out code are left as they are.
- One Report, Three Engines: native layout and structure rules, a bundled Vale style, and AutoCorrect share one config and one report.
Example
An editor wraps a comment at whatever column it reaches, so sentences break mid clause.
def reflow(comment: Comment, width: int) -> Comment:
# A sentence that fits the width stays on one line of the comment, and a longer
# one breaks only at a comma that ends a clause.
return comment.reflow(width)
subedit fix --write autofixes the layout and says nothing. The sentence is too long for one line, so it breaks at the comma where its first clause ends.
def reflow(comment: Comment, width: int) -> Comment:
# A sentence that fits the width stays on one line of the comment,
# and a longer one breaks only at a comma that ends a clause.
return comment.reflow(width)
Markdown has no column limit, yet an agent often wraps a paragraph by hand, and GitHub, Notion, and Heptabase may show each of those newlines as a break.
## cache layout
The cache keeps one entry per file,
and drops it when the file changes.
The same command joins the paragraph into one line and puts the heading in Title Case, again without a word.
## Cache Layout
The cache keeps one entry per file, and drops it when the file changes.
A sentence in a comment that runs past the width with no comma has nowhere legal to break, and only its author knows where the meaning divides, so it goes back to the agent that wrote it.
1 finding needs rewriting in src/cache.py.
Each states the fix. Apply it in place, do not add a suppression comment.
line 2 [unbreakable-sentence]
This sentence runs to 116 characters against a budget of 114 characters and contains no comma, so there is no legal place to break it. Add a comma at a clause boundary, or split it into two sentences.
Getting Started
subedit runs inside an AI agent as a plugin, and on its own from the command line.
Claude Code Plugin
The plugin needs only uv. It runs subedit from PyPI with Vale included, and warms that environment when a session starts.
/plugin marketplace add mroops0111/subedit
/plugin install subedit@mroops
The hook then acts in every project that opts in with a subedit.toml, which may be empty. Agent Integration covers Codex and registering the hook by hand.
Command Line
The command line tool needs Python 3.11 or newer, and installs from PyPI.
uv tool install 'subedit[vale]' # recommended, fetches Vale for you
uv tool install subedit # without Vale, the native rules and AutoCorrect still run
pipx install subedit and pip install subedit work as well. To try it without installing, prefix any command with uvx.
Quick Start
Every command takes files or directories, and a directory walk skips dotted and vendor directories such as .venv and node_modules.
| Command | What It Does |
|---|---|
subedit check src/ |
Reports every finding |
subedit check src/ --output=actionable |
Reports only the findings that need rewriting |
subedit check src/ --output=json |
Reports every finding as JSON, for other tools |
subedit fix src/ |
Shows the autofixes as a diff |
subedit fix src/ --write |
Applies the autofixes in place |
subedit stats src/ |
Measures comment lengths and widths, to set thresholds from data |
subedit rules |
Lists every native rule with its fix kind and default level |
To adopt subedit, add an empty subedit.toml at the project root, run fix --write once, and read what check still reports. check exits 1 on any error finding, and fix exits 1 while an error rewrite remains, so both drop into CI or a pre-commit hook. --no-delegate skips Vale and AutoCorrect.
CI Workflow: a GitHub Actions job
# .github/workflows/prose.yml
jobs:
subedit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v6
- run: uvx --from 'subedit[vale]' subedit check src/
Background
A subeditor is the editor at a newspaper who makes every article follow the paper's style guide. subedit does that for the text AI agents write in your repository.
Agents write a lot of comments and docs, and rarely go back to check them. Code formatters skip comments, and prose linters don't understand source files, so three kinds of problems slip through:
- Layout: comments are wrapped at a fixed column, so sentences break in the middle of a phrase.
- Placement: a public function gets a plain comment instead of a docstring, so it never shows up on hover.
- Wording: change history and ticket numbers end up in comments and go out of date, and punctuation drifts from the house style.
Telling the agent isn't enough. Even with a style guide or a skill, agents get layout rules wrong and forget them as the conversation grows. A tool that checks every edit doesn't forget, and by fixing what it can itself, it keeps fifty layout complaints out of the agent's context.
Design
Every finding says who can resolve it, and the whole design turns on that answer.
Fix Kinds
A rule declares one of three fix kinds, which decides what changes and who makes the change.
| Kind | What Changes | Resolved By | Example |
|---|---|---|---|
TARGETED |
A few characters, in place | The tool, silently | A missing space between CJK and Latin text |
REFLOW |
Where lines break | The tool, silently | A sentence broken mid clause |
REWRITE |
The wording itself | The author | A sentence too long to break anywhere legal |
Targeted and reflow fixes are autofixes, applied without a message. Only a rewrite reaches the author, because changing the wording needs the sentence's meaning.
Severity
A level decides whether a rewrite blocks. Every rule has a default, and every rule can be moved between levels or switched off.
| Level | check and fix |
Agent Hook |
|---|---|---|
error |
Fails with exit code 1 | Blocks the edit and sends the message to the model |
warning |
Shows the message as advice | Sends the message as context, without blocking |
off |
Skips the rule | Skips the rule |
Judgment rules, such as a long block or a date in a comment, default to warning.
Layout Model
Reflow works on sentences rather than lines, so the result reads the way the author would have broken it.
- One Line When It Fits: a sentence that fits takes one line, and a wrapped one that would fit is joined.
- Clause Commas Only: a longer sentence breaks only at a comma that ends a clause, never inside brackets or a code span, and preferably not inside a list.
- No Short Lines: no break leaves a line shorter than the
line-too-shortfloor, 24 characters by default. - Verbatim Blocks: code examples, docstring sections, and JSDoc tags are left as written.
- Markdown Paragraphs: Markdown has no column limit, so a paragraph takes one source line, and a hand-wrapped one is joined.
Pipeline
A file takes the same path through subedit whether the CLI or the agent hook started it.
- Resolve: the closest
subedit.toml, or[tool.subedit]inpyproject.toml, gives the rules and the width. - Parse: tree-sitter finds the prose, such as comments, docstrings, headings, and paragraphs, and maps where code sits. A Markdown code block is read as its own language when the project sets
code-blocks. - Lint: each native rule reads its own surface, and a Vale or AutoCorrect finding is kept only inside prose.
- Autofix: targeted edits, then reflow, rerun until nothing mechanical is left, for up to ten rounds.
- Report: what remains is a rewrite, reported as a blocking error or as advice.
Architecture
The package follows a layered design, so a new language, rule, or delegated tool is one class behind an existing port.
Rules never see a syntax tree. A parser turns the file into prose units, such as a comment group with the symbol it documents or a Markdown paragraph, and each rule reads the units of its own surface. A new surface is a ProseUnit with its SourceParser, a new language is a LanguageProfile, a format whose only prose is its line comments is one more CommentOnlyProfile, and a new agent is an AgentHarness.
Reference
Agent Integration
subedit-hook runs after every file an agent edits. It applies the autofixes in place, and exits 2 only when a sentence needs rewriting, which hands the message back to the model. In Claude Code a warning reaches the model too, as context beside the tool result, without blocking the edit.
The hook acts only in a project that opts in, with a subedit.toml or a [tool.subedit] table in pyproject.toml, in the edited file's directory or a parent. An empty table is enough. Elsewhere it exits 0 and changes nothing. The opt-in covers every surface, and a single rule is switched off by name under [rules].
Claude Code
The plugin registers the hook for you. It also ships the subedit:judging-findings skill, which gives the model the criteria for every finding a tool cannot fix, such as when a spec identifier stays and a ticket number goes. Criteria in your CLAUDE.md, AGENTS.md, or a skill of your own come first.
Manual Hook Registration: without the plugin
With subedit installed as a tool, add this to .claude/settings.json.
{
"hooks": {
"PostToolUse": [
{
"matcher": "Edit|Write|MultiEdit|NotebookEdit",
"hooks": [{ "type": "command", "command": "subedit-hook" }]
}
]
}
}
Codex
Add this to ~/.codex/hooks.json.
{
"hooks": {
"PostToolUse": [{ "command": "subedit-hook" }]
}
}
Registering the hook with both agents is fine, since each payload identifies its sender and anything else exits 0 untouched. subedit-hook --help prints the payload shapes it accepts.
Configuration
Settings come from subedit.toml, or from [tool.subedit] in pyproject.toml, whichever sits closest above the file being checked. Without either, check and fix run with the defaults. A config with a misspelled key, level, or option stops subedit with an error that names the file and the key, so a typo never leaves a project on defaults it did not choose.
A rule takes one of two forms, depending on whether it has options to set.
- Level Only: a string,
"error","warning", or"off". Every rule takes this form, including the delegated Vale and AutoCorrect rules. - Level and Options: a
[rules.<name>]table, holdingseverityand the rule's options. Leave outseverityto keep the default level. The rule reference lists each rule's options with their defaults.
[subedit]
line-width = 100
exclude = ["tests/fixtures/**"]
[rules]
mid-clause-break = "warning"
file-header-comment = "off"
"subedit.DateRef" = "off"
[rules.comment-too-long]
severity = "error"
max-plain-lines = 3
[rules.line-too-short]
min-line-characters = 30
[rules.heading-title-case]
exceptions = ["npm"]
A name Title Case must leave as written, such as npm, goes under exceptions, which headings, table headers, and list labels all follow.
In pyproject.toml, the same keys sit under [tool.subedit], [tool.subedit.rules], and [tool.subedit.rules.<name>].
Settings: the width, excluded paths, code blocks, and abbreviations
| Key | Type | Default | Meaning |
|---|---|---|---|
line-width |
Integer | The formatter's width, else 120 | The column every comment line must fit, counting indent and delimiter |
exclude |
List of globs | [] |
Paths a directory walk skips, relative to the config file |
code-blocks |
Boolean | false |
Whether the comments in a Markdown code block are read, in a language subedit supports |
abbreviations |
List of strings | [] |
Abbreviations whose period ends no sentence, each written with its period and its case, such as "Dept." |
Left unset, line-width follows the formatter that would format the file, read from its own config.
| Language | Width Read From |
|---|---|
| Python | line-length for ruff or black |
| TypeScript, JavaScript | printWidth for Prettier, lineWidth for Biome |
Rules
subedit ships 21 native rules, a bundled Vale style of 5 rules, and AutoCorrect. Every rule is set by name under [rules] to "error", "warning", or "off", and its fix kind follows Fix Kinds.
Comments and Markdown share one house style, and differ where their forms differ. A comment has a column limit and sits beside the code it explains, while Markdown has no limit and is built from paragraphs and headings.
| Concern | Comments | Markdown | Rules |
|---|---|---|---|
| Punctuation | No mid-sentence colon, semicolon, dash, or arrow | Same | Style, Wording |
| Parentheses | Half-width, spaced outside, flush inside | Same | Style |
| List Labels | Title Case, and bold only in docstrings and JSDoc | Title Case and bold | Style |
| Word Choice | The house verb for include, and no not A, but B framing | Same | Style |
| CJK Spacing | A space between CJK and Latin text | Same | Spacing |
| Line Breaks | Within the width, only at clause commas | One source line per paragraph or list item | Layout, Markdown |
| Long Sentences | Rewritten when no clause comma can carry the break | Not checked, since no line breaks | Sentence |
| Placement | A docstring on each public symbol, no banner, no restated signature, and a short block | Not checked | Structure |
| Stale References | No change narration, ticket number, or date | Not checked, since a note may tell a history | Wording |
| Headings | None | Title Case, not bold, a noun phrase, and opened by a lead sentence | Markdown |
The rule reference lists every rule by group, with what it catches, its default level, and its options.
Surfaces
A surface is a kind of file where prose lives. Every surface goes through the same pipeline.
| Surface | Status | Focus |
|---|---|---|
| Code comments and docstrings | Available | Layout, because a comment must fit a column limit |
| Markdown | Available | One line per paragraph and the shape of headings, because Markdown has no column limit |
Markdown is read from .md and .markdown files, leaving front matter, code, and HTML blocks alone, and reading only the header of a table. With code-blocks = true, the comments in a fenced block are read too, when its info string names a language subedit supports, such as python, ts, or yaml. Each block is checked as a file of that language would be, by Vale and AutoCorrect as well, except for the rules on a whole file. A code block is often an example, so this stays off unless the project asks. Editor diagnostics over LSP are planned, so the same findings show as you type.
Languages
Each language is a profile that knows its comment forms, its doc comment, and what counts as public. A data format has no doc comment or public symbol, so only the rules on wording and layout apply to its comments.
| Language | Files | Doc Comment | Public Symbol |
|---|---|---|---|
| Python | .py, .pyi |
Docstring, """ |
A name without a leading underscore |
| TypeScript | .ts, .mts, .cts, .tsx |
JSDoc, /** */ |
An exported symbol, and its members unless private, protected, or #named |
| JavaScript | .js, .mjs, .cjs, .jsx |
JSDoc, /** */ |
A symbol exported with export, and its members unless #named |
| YAML | .yml, .yaml |
None | None |
| JSON | .json, .jsonc |
None | None |
Content Left Alone: what every profile skips
- Commented-Out Code: a comment line the language's own grammar reads as code, such as
// return resultor# client.send(, is left as written. In YAML and JSON, a setting commented out, such as# timeout: 30or// "semi": false,, is too. - Doc Sections: a docstring's sections from
Args:,Parameters, or:paramonward, and a JSDoc block's tags from the first one such as@throwsonward, are left as written. A JSDoc block keeps its frame when reflowed. - Directives: a directive such as
// eslint-disable-next-line,# type: ignore, or# yaml-language-server:carries no prose, so nothing reads it. - Plain Blocks: a plain
/* */block is usually a license header or code switched off, so nothing reads it. - Code and Values: Vale and AutoCorrect findings are kept only inside comment prose, so a string in code or a value in YAML is never changed.
- Group Headings: a plain comment opening a paragraph over several declarations heads them as a group, so it documents none of them.
License
MIT. The English abbreviations that end no sentence come from the Unicode CLDR under the Unicode License v3, whose notice ships with the data file.
Metadata
Release files for subedit 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| subedit-0.5.0.tar.gz | 306.0 kB | With provenance | Details for subedit-0.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| subedit-0.5.0-py3-none-any.whl | Python 3 | none | any | Details for subedit-0.5.0-py3-none-any.whl |
Total release size: 422.1 kB
Release files / subedit-0.5.0.tar.gz
| Download URL | subedit-0.5.0.tar.gz |
|---|---|
| Size | 306.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3156c467bada3a308ca310d5071da79ddb5027092d159fba398fa2d8699b2317
|
|
BLAKE2b-256 checksum How to use checksums |
e6e5b35161852ec9d2f33428dcf8b06d59fa380429beabe7a0463ba5ad2d5e4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logRelease files / subedit-0.5.0-py3-none-any.whl
| Download URL | subedit-0.5.0-py3-none-any.whl |
|---|---|
| Size | 116.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e60d48061a864ad9a4cf414ef3b72c88a2ccfa4b29fe4a453e744c921a4c056b
|
|
BLAKE2b-256 checksum How to use checksums |
5831a8f633166adbfcad39b58eefe4d72c39945ed243501111384dbcb3d3c8b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logSecurity for subedit 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for subedit-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 7, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.