/chaff:chafffrom chaff
Check prose with chaff (npx chaffjs): pick the genre preset for the kind of document (contract, statute, manual, FAQ, paper, fiction, transcript…), run it on Markdown or text, read each finding, fix the text or record why not, and tune chaff.yaml with rules --json and relax --why. Use when asked to lint, proofread or tighten documents, to check that a document's totals, dates and references agree, or to set up a team's writing rules. Also use when asked to make text sound less AI-generated (「AIっぽさをなくして」「AI臭さを消して」「人間らしく書き直して」, 'make this sound human'): Light, Bold or Full mode, with Full (全面書き直し) when the request says 「全面的に」 or 'from scratch'.
Ships in chaff. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
chaff finds what makes writing hard to read — long sentences, padding, mixed styles, broken references in a contract. It also finds where a document's own numbers and dates disagree: a total that is not the sum of its items, a date and its weekday that do not match, an end date before the start. It never rewrites anything, and the same text gives the same result every time. Reading the findings and changing the text is your part. Japanese and English documents both work; the language is detected per file.
A genre is a preset for one kind of document: which rules run, where their limits are, and how the document is read. A contract checked as a blog post gets wrong findings, so choose the genre before reading any finding.
npx chaffjs genres lists every genre with what it is for:
legal/contract, legal/statute, docs/manual, docs/faq, academic/paper, literature/fiction,
speech/transcript, business/report, technical/spec, …--genre. When the file looks like another kind, the line under the header says so
(Looks like: Contract and terms. Try --genre legal/contract); use that genre if it fits.npx chaffjs --genre legal/contract contract.md. For a folder of one kind,
npx chaffjs init --genre legal/contract writes it into chaff.yaml (always pass --genre: without it,
init asks at a terminal).guide: in chaff.yaml. A
guessed or default genre shows no guide, and --no-guide leaves it out.A rule the genre turns off is listed under "did not run" with the genre as the reason. That is the preset's
choice, not a gap; turn it back on (rules: in chaff.yaml) only when the person asks. For minutes or notes made
from a transcript, use a business genre (business/meeting-notes): filler-word then reports fillers left in (ええと,
um, you know). speech/transcript is for a verbatim record and keeps them. Some of these are off
because chaff measured them to be mostly wrong for that kind of document on real, judged documents
(isamu/chaff-corpus); turning one back on brings those false findings back.
npx chaffjs --genre <genre> <file|dir|glob>... # human-readable, one block per finding (a folder or glob picks up .md / .markdown / .mdx; name a .txt file directly)
npx chaffjs . --compact # two lines per finding: line:col severity message, then the rule id
npx chaffjs <file> --experimental # also the experimental rules (new ones, not yet measured)
A run exits 1 when a finding is an error. It also exits 1 when it could not check anything: no file to
check, an unknown --genre, no package for the language. So a clean exit means the files were checked.
After the findings comes the list of rules that did not run, and why. Only the default output shows it;
--compact gives just their number. Read it before saying a document is clean. Two reasons there are not about
the genre: a rule that compares documents runs only when chaff is given two or more files or a folder, and a rule
that reads meaning runs only under npx chaffjs test (below).
Some rules read only one language and say so when they do not run: ra-nuki (見れる for 見られる) and sa-ire
(読まさせて for 読ませて) are Japanese only.
A run over several files prints only the files that have findings. To call one file clean, run chaff on that file alone and read its list.
The default output ends each file with an AI-likeness: line (low, medium or high, or why it was not scored).
npx chaffjs ai-score <file> gives the same on its own. It counts signs common in generated text against human
documents of the genre; it does not say who wrote the text.
A few checks need a reader: does the proposal state its risks, does the conclusion only restate the body, does a
number claiming an effect have a source, does the opening start from a generic problem instead of who did what
(generic-opening). chaff never runs a model in a plain check. npx chaffjs test <file|dir>
narrows the candidates by machine and sends only those passages to an AI (Anthropic or OpenAI, set by
ai_backend in chaff.yaml; it needs an API key). Run it with --dry-run first: it shows what would be sent and
calls nothing. Ask the person before a real run; the passages leave the machine.
| When | How | |
|---|---|---|
| Fix the text | The finding is right | Edit the sentence. Keep the meaning, the facts and the numbers; change only how it is said. |
| Silence that spot | Right in general, wrong here (a quotation, a term that must repeat) | <!-- stet: rule-id — reason --> before it; stet-section / stet-file for wider scope, <!-- stet-begin: rule-id — reason --> … <!-- stet-end --> for a range, rule-id["word"] to silence one matched word only. Always name the rules (there is no all-rules form) and give the reason. |
| Allow that text everywhere | The same text is always right for this team (a product name, a quoted form) | An entry under allow: in chaff.yaml: text: (literal) or pattern: (regex), reason: (required), optional rules: and files:. npx chaffjs suppressions lists what it silenced. |
| Change the rule | Wrong for this team or genre | npx chaffjs relax <rule-id> --why "reason" (or strict / off). The reason and date are written into chaff.yaml. |
npx chaffjs explain <rule-id> shows why a rule exists, its levels and the current one. Read it before
relaxing a rule. A worked before and after for a rule, with chaff's real output and the settings, is at
https://github.com/isamu/lab/blob/main/text/docs/samples/<ja|en>/<rule-id>.md when that rule has one (the index:
docs/samples/<ja|en>/README.md).
When a finding is wrong for a reason that is not about this team (chaff misread the text), tell the person and offer
npx chaffjs feedback <file> --rule <rule-id> --line <n>: it drafts a report and sends nothing. A document the
person may share can go to isamu/chaff-corpus, where wrong findings become test cases and rule fixes.
heading-marker-no-space (##Steps, #見出し: no space after the marks, so the line is not a heading) is fixed by
adding the one space; keep the level and the words. If the line was a tag or a number, not a heading, leave it and say so.
The group "Facts that disagree" in npx chaffjs rules checks what a sum or a calendar can settle. Among them:
totals and their items, quantity times price, tax and net amounts, and percentages that should add up to 100%.
Also a date and its weekday, dates and periods out of order, a reference number written two ways, and one fee or
deadline given two values. Most of these are an error.
Such a finding says two places in the document disagree. It does not say which one is wrong. Check the source (the quote, the ledger, the calendar, the booking, or the person) before changing anything, then fix the wrong one. Never "fix" it by changing the figure that was right, and never adjust both so they merely agree. If you cannot tell which is right, leave both and ask.
Some findings are Markdown slips that drop a section from the outline: pseudo-heading is a bold line standing in for
a heading ("Next steps") in a document that otherwise uses headings. Make it a real heading one level below the
heading above it; if it is not a section of its own, drop the bold and write it into the text. Do not change its words.
npx chaffjs init --genre <genre> writes a commented chaff.yaml for that genre when there is none (an
existing one is left as it is), and adds .chaff-cache/ and .env* to .gitignore.
npx chaffjs rules --json [--genre <genre>] prints every rule with its levels, the setting in effect (now,
the genre's preset included) and why a rule is off. Read it instead of guessing rule names or limits.
npx chaffjs rules shows the same as a table, grouped, with the level each rule runs at now.
A level is strict / normal / relaxed / off; when even relaxed is too tight, a positive number is the
limit itself (max-sentence-length: 260). A rule with nothing to count takes fewer levels, and no number;
levels_you_can_set in rules --json lists them.
prefer: maps spellings to the team's (e-mail: email); preferred-term: normal turns the rule on. An entry
limited to some parts of the document takes the object form: our firm: { use: our company, scope: [~quote] }.
terms: lists names and terms with one fixed form ([GitHub, JavaScript]); term-form reports a form that
differs only in case, width, hyphens or spaces (Github, GitHub, Java Script), outside code, URLs and paths.
Without terms: the rule does not run, and the list of rules not run says so.
consistent: lists groups of words that are each right but must not be mixed ([[顧客, お客様], [log in, sign in]]);
term-consistency reports the less-used member within a document (a tie is one finding that takes no side), and
cross-doc-term-variant compares the groups across the files of one run. Without consistent: the rule does not run,
and the list of rules not run says so.
Unknown rule names and unreadable values are reported on stderr — read stderr after editing chaff.yaml.
genre: sets the kind of document. by_path sets it per path, as a list of files globs, each with genre,
language, profile, rules or options, and an entry in any other shape is reported on stderr and not used:
by_path:
- files: ["guides/**/*.md"]
genre: docs/manual
rules:
max-sentence-length: relaxed
An entry's rules and options are written as the top-level ones are. A file's level, weakest first: the default,
the genre, style:, top-level rules:, then the matching by_path entries' rules (the later entry wins). A rule
an entry turns off is listed as not run with the entry named; explain lists every entry that changes the rule.
A file's front matter genre: (or type:) sets that one file, when neither genre: nor a matching by_path
entry does. Strongest first: --genre for one run, then by_path, genre:, front matter, the path, the content,
and blog/tech. rules: wins over the genre's preset.
profile: names a bundled kind of document with fixed conventions: statute, listing, property-sale,
verse (a Japanese poem: each line ends a sentence) or play (a Japanese play: stage directions in () are split
from the spoken line). Leave it out: the genre or the content chooses it, and the first line of npx chaffjs tree shows the choice. none stops the choice.
names: lists the team's names (organisations, products), each read as one name. include: adds files besides
Markdown when a folder is checked (include: ["*.yaml"]). exclude: leaves globs out of a folder walk
(exclude: [vendor/**, CHANGELOG.md], matched like by_path), and a walk also leaves out what the .gitignore
files from the repository root (the nearest folder with .git) down ignore, plus .git/info/exclude. A file named on the command line is still checked; the summary says
how many files were left out and why.
Markdown when a folder is checked (include: ["*.yaml"]).
options: { no-mixed-desumasu: { body: desumasu, list: dearu, heading: dearu } } (Japanese only) is for a team
that has chosen its register: in a region written there, a sentence in the other register is reported even with no
mix. Leave it out to keep the default, which takes no side and only flags the minority of a mix.
When the person gives house rules ("polite endings, sentences of at most 80 characters"), do not guess rule names or numbers:
npx chaffjs rules --json. Each rule has summary (what it finds), level_meaning (what a level's
number means), levels, example, not_flagged, and genres (whether it runs in each genre).summary and level_meaning fit. A
number between levels is written as the number itself (max-sentence-length: 80). Spellings go under
prefer, names with one fixed form under terms, words not to be mixed under consistent, in-house words under jargon, required headings under required_sections.no-mixed-desumasu flags a register mixed into a document, but
does not require a particular one; a document wholly in the other register is not reported.npx chaffjs explain <rule-id>, a
short sample that breaks each requirement (each must be reported), and npx chaffjs rules (the table shows the
level each rule now runs at).Pick the easiest way that can say the requirement:
| Requirement | Use |
|---|---|
| An existing rule covers it | A level, a number, prefer, terms, consistent, jargon or required_sections in chaff.yaml |
| A fixed phrase or pattern, with the team's own message | custom_rules of type words or pattern |
| Decided by part of speech or inflection | custom_rules of type tokens |
| Counting or comparing that the above cannot express | a Node function, type: module |
| The same rules shared across repositories | a rule pack of YAML files: npx chaffjs init --plugin <name>, npx chaffjs plugin-test in its folder, then plugins: in chaff.yaml |
A words rule names the words, the team's text for each field explain shows, and one example:
custom_rules:
- id: banned-word
type: words
words: [禁止ワード]
severity: warning
name: { ja: 禁止ワード }
why: { ja: この文書で避ける語です }
message: { ja: "「{matched}」は使いません" }
how_to_fix: { ja: 別の言い方にします }
example:
ja: { before: 禁止ワードを使った文, after: 別の言い方の文 }
scope: on a words, pattern or tokens rule (and on a prefer entry) limits what it reads: heading, list,
table, quote, paragraph (body text outside the others). Without it, a rule reads body text and list items. Names
without ~ choose (none: every part), then names with ~ take parts away, so [~quote] is everything but
quotations and [list, ~quote] is list items outside quotations. A rule against 。 at the end of a heading is
type: pattern, pattern: '。', scope: [heading]. An unknown name stops the run.
Test a new team rule the same way: explain, then a sample it must report and a sample it must not, before
committing chaff.yaml. The guide page "Adding a rule" covers each way and how to add a rule to chaff itself.
Use this section when asked to make a text sound less generated: 「AIっぽさをなくして」「AI臭さを消して」「人間らしく 書き直して」, "make this sound human", "this reads like AI wrote it".
chaff marks the shapes common in generated text (group "Signs of generated text" in npx chaffjs rules: ai-tell,
contrast-framing, stock-transition, announcing-opener, colon-lead-in, over-general-claim (English only),
q-fragment-answer (English only), assistant-residue, email-stock-courtesy (English emails: stacked "I hope this email finds
you well"-type courtesies), honesty-marker ("Honestly,", 「正直、」: one is reported in blog posts and business documents),
inline-triad (English only: three short phrases strung on commas with no "and", again and again),
closing-exhortation (a closing that cheers the reader on: 「ぜひ〜してみてください」,
"You've got this"), cold-open (an opening that piles a bare wish, a quoted echo of the previous sentence and a teaser),
section-reflection-ending (nearly every section closing on a personal reflection: 「〜と思います」, "I think ..."),
unprompted-denial (sentences that deny a premise nobody stated: 「〜の話ではありません」, "This isn't about tooling."), and the signals
ai-generated-composite reads, among others). Most of them do not run in technical/spec or in the legal, docs, literature and
speech genres; assistant-residue (words left from a pasted chat reply) runs in almost every genre. npx chaffjs rules --json
says per rule and genre. None of them says the text was generated. chaff never rewrites; the rewriting is yours.
Start with the plan. Run npx chaffjs fix-plan <file> (with the genre's --genre; --json to
read it as data; --depth light|structure|register when how deep the rewrite may go is already decided). It
prints, in the document's language:
ai-tell phrases found, and the spots (line and sentence);Follow it. Rewrite in the mode it recommends; a request that says 「全面的に」 or "from scratch" means Full whatever it says. Apply each rule's direction at its spots. Where a fix needs a specific the text does not give, leave [ ] and ask. Save the result under the name the plan gives, run its check commands, and report the mode and the checks' output. The mode steps below say the rest.
When the request is to remove all of it (「AI臭さを全部消して」「AIっぽさを完全になくして」, "remove every AI tell"),
run the plan with --all-ai-signs and loop until it says stop:
npx chaffjs fix-plan <file> --all-ai-signs --json (with the genre's --genre). It runs every AI-likeness rule,
also those the genre turns off or leaves out, and adds aiScore (the ai-score level and its signs), aiRules
(the AI-likeness rules with findings) and stop (when to stop). npx chaffjs facts <file> --json is the inventory
of facts to keep.ai-generated-composite fires).
Fix every spot of every rule in rules, by its direction: the AI-likeness ones and the others, so the rewrite
leaves nothing worse.npx chaffjs test <rewritten> --checks ai-tells --dry-run lists the
questions and the passages each would be asked about: invented specifics, an abstract opening, a denial of what
nobody said, a moral at the end, a benefits list that mirrors the problems, a claim restated, inflated significance,
generic content, a request recast as the reader's benefit, the same thing renamed. Run it without --dry-run only
with an API key and the person's yes (the passages leave the machine). Otherwise read the passages yourself against
each question. A specific that looks invented (in the original or in your draft) is a question for the writer:
keep it marked, 「[105cm]くらい」 / "[on a five-hour flight]", and ask them to confirm or cut it; never replace it
with another invented one. Reread your own draft for wording that changes a claim; compare sees facts, not claims.npx chaffjs fix-plan <rewritten> --all-ai-signs --before <file> --json and
npx chaffjs compare <file> <rewritten> (--distinct --allow-dropped heading --allow-added heading after a Full
rewrite).stop holds: aiRules is empty; aiScore.level is low, or the document is too
short to score; since.risen is empty (no rule has more findings than in the original); compare passes; none of
the ai-tells questions fits. Three passes at most. List what is left after the third with the reason (a placeholder
only the writer can fill, a word that is right in context).aiRules, the score, since.risen, compare.Pick one of three modes and say which.
| Mode | Changes | Pick it when |
|---|---|---|
| Light | only the flagged spots | the content and the structure are fine and only some phrasing is off |
| Bold | each section's prose, keeping the outline | the outline is fixed (a report template, a manual, required sections) |
| Full | the whole document, from scratch | the request says 「全面的に」「一から」「全部書き直して」 / "from scratch" / "rewrite the whole thing"; or the genre is blog/* or an essay (literature/essay); or ai-generated-composite fires; or the plan's structure score reaches its limit |
The plan also names a fourth way, Register: a Full rewrite that also converts the style (polite to plain endings,
です/ます to だ/である, and so on). chaff never recommends it; use it only when the person asks for the style to change
(--depth register). With --depth light, a rule whose direction needs a deeper rewrite is listed by name and
spot count only.
For a blog or an essay, and whenever ai-generated-composite fires, recommend Full. A Light or Bold pass leaves the
skeleton of generated text: a heading every few paragraphs, bold lead-ins, symmetric sections, a closing まとめ that
repeats the body. The writer usually wants the structure changed, not only the sentences.
Light (only the flagged spots):
npx chaffjs fix-plan <file> (or with the genre's --genre).Bold (section by section, outline kept):
ai-generated-composite inputs,
bold-density, bold-emphasis, contrast-framing, stock-transition, sentence-rhythm.npx chaffjs compare <old> <new> (exit 1 on a dropped or added fact; --json to act on it). Restore every
dropped fact; for one that is not a fact (a number inside a metaphor, the heading of a section you cut), say why it
stays out. --allow-dropped <kind> excludes a kind you cut on purpose. Never leave an added fact. A name listed as
respelled (a change of case, or one letter, from a spelling written once to one written at least twice) is not a failure; check
that the new spelling is the right one.Full (全面書き直し, from scratch):
Take inventory before writing. npx chaffjs facts <file> --json lists every fact compare will hold you to
(numbers, dates, times, URLs, code, names, quotations, headings, references, footnotes). npx chaffjs outline <file>
gives the old outline, its shape and its structure block: each structure measure against human articles, with ✗ on
those past 90% of them. Then write down, one line each, the writer's actual claims and every concrete
experience, example and opinion in the original. This inventory is what you write from; the old sentences are not.
Throw away the structure. Decide what the piece is for and who reads it. Choose one angle or story for the whole piece, and outline it the way a person would. Do these before writing:
ai-structure counts that outline;Size the new outline by the plan's structure targets: as many headings as the target allows for this length, no heading split into three unless the content has three parts, no bold-label lists, no closing that restates.
Show the new outline first. Put the old outline (headings from chaff outline) next to the proposed one:
headings, and one line per section on what it says. The writer then sees the structural change at a glance. Wait
for a yes, unless the person asked for it to be done without asking; then go straight on.
Write it fresh, in the writer's voice, from the inventory:
Three principles while writing:
chaff compare catches an added number or name, but not added wording such as 「朝会で冗談が出るようになり」, so
this one is yours to keep.Check.
npx chaffjs <old> and npx chaffjs <new>: the AI signals before and after.npx chaffjs outline <old> <new>: headings, average section length, text in lists, bold, and the structure score
and each structure measure, before and after. A restructure shows up here, not only in rule counts.npx chaffjs compare <old> <new> --distinct --allow-dropped heading --allow-added heading: the headings are the
structure you rebuilt on purpose; every other dropped fact is restored and no other fact is added. A cut まとめ
restates facts the body still holds, so --distinct counts a fact as kept when the new text states it at least
once.Stop when all of these hold, or after two full passes, whichever comes first:
ai-generated-composite does not fire;bold-density, bold-emphasis, stock-transition, colon-lead-in) and the share of contrast frames (contrast-framing) are under their limits;chaff outline <old> <new> shows the new structure score under the plan's limit, with no ✗ left on the measures
the plan listed as targets;compare is clean, or every exclusion has a stated reason.Show the new text, a short "what changed and why" list, then a table of the signals and the shape before and after, taken from chaff's output.
Read for these too. chaff cannot detect them mechanically, so check them by reading, in every mode:
In every mode:
--all-ai-signs), and list what is left with the reason.The guide page "Making AI-sounding text sound human" has worked examples of a Bold and a Full rewrite, with chaff's output before and after.
npx chaffjs tree <file> shows a contract or specification as a tree of addresses (3.2 for 第3条第2項 or
Section 3.2). A check reads the same tree to find references to missing provisions, numbering gaps and
terms defined twice. enumeration-marker-mix points at an item numbered in another form than the rest of its run
("1.", "2.", "3)", "4."; 「(1)」「(2)」「3.」); sub-items that count from 1 again are a level below and are left.npx chaffjs cite <source> <quotes.json> checks that quotations ([{ "address", "quote" }]) are really in
the source; exit 1 if any is not. Use it to back every quotation you put in an answer or a summary.
cite --url <URL> <quotes.json> checks against a web page; cite --scaffold <file> prints the quotations in a
file that give no source, as JSON to fill in and pass to cite.tree --format json and cite --format json give the same as data.npx chaffjs grade <items.jsonl> grades a file of model outputs, one JSON object per line (id, output, and
reference, sources and citations when there are any): findings, dropped or added facts, quotations, pass or
fail. It exits 1 when an output fails (with --baseline, when the run got worse) and sends nothing.
chaffjs/grade does the same in code. The guide page "Using chaff for AI evals" covers baselines and variants.
If a finding is wrong for the text (a false positive), or chaff missed something it should catch, draft a report for the chaff project:
npx chaffjs feedback <file> --rule <rule-id> [--line N] # a wrong finding
npx chaffjs feedback <file> --missed --line N # something missed
It writes .chaff-feedback.md: chaff's version, Node and OS, the file name, the one finding, the two lines on
each side of it, and the reported rule's setting in chaff.yaml (all of chaff.yaml only with --with-config).
When a rule has several findings in the file, add --line to pick one. It prints how to send the draft
(gh issue create …, or a link that carries the title only). It sends nothing. Show the draft to the person and let
them decide; their document may be private.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub isamu/lab --plugin chaff