Skip to content

Enforce Humanizer in Claude Code with hooks on files, replies, and thinking - #358

Open
kasutu wants to merge 6 commits into
blader:mainfrom
kasutu:feat/hook-enforcement
Open

kasutu wants to merge 6 commits into
blader:mainfrom
kasutu:feat/hook-enforcement

Conversation

@kasutu

@kasutu kasutu commented Nov 27, 2026

Copy link
Copy Markdown

The big update: Humanizer now enforces itself in Claude Code

Until now, Humanizer only ran when someone called /humanizer. With this PR, the Claude Code plugin also installs hooks. They check everything Claude writes in every session and project, and send text with AI tells back for a rewrite. Installing the plugin is enough to turn them on, with no extra setup.

Text Hook What happens
Prose files (.md, .mdx, .markdown, .txt, .rst, .adoc) PreToolUse on Write, Edit, MultiEdit The write is blocked until Claude rewrites the text.
Chat replies Stop The reply goes back, and Claude posts a rewritten one.
Thinking SessionStart, UserPromptSubmit, Stop The rules go into context each session and prompt. Tells in stored thinking are reported at the next prompt.

HUMANIZER_HOOK=off turns every hook off. This repo sets it in .claude/settings.json, because SKILL.md lists every tell.

How the hooks decide

scripts/humanizer-lint.py scores text from 0 to 1 with a small linear model over the SKILL.md patterns. It follows the approach of ste-lint, the heuristic checker in the public Simplified Technical English writing kit: strip code and quotes, count features, normalize by length, and weight the counts.

  • One-sighting tells (§1 to §5, §8 dashes, §22 chatbot residue, §23 disclaimers) flag a text alone.
  • Weaker signals flag a text only together: stock AI words, triads, bold labels, flat rhythm, repeated openers, short closers.
  • Weights for stock words follow published frequency ratios (Kobak et al. 2025; Reinhart et al. 2025). Passive voice and type-token ratio are left out, because neither points reliably at AI text (El Attar et al. 2026).
  • Code, URLs, blockquotes, quoted phrases, and a weak word named after "such as" are skipped, so text that discusses a pattern passes.

scripts/humanizer-hook.py routes each hook event to the scorer.

Evidence

  • The 16 AI fixtures are all flagged (scores 0.23 to 1.00; the lowest has a hard tell). The 18 human fixtures all pass, with a top score of 0.20.
  • The README, AGENTS.md, CHANGELOG, and the docs of stop-slop all pass. The only flagged files are word lists of the tells themselves (SKILL.md, stop-slop's references/phrases.md).
  • In a live headless session with the plugin loaded, SessionStart injected the rules. The Stop hook caught a reply full of tells (score 0.99) and sent it back, and the loop guard held.
  • Rewrites of both README "Before" examples score 0.05 and 0.08, matching the old "After" texts.

Current edges

  • Thinking can be steered but not rewritten. Claude Code often stores thinking without its text, so there is frequently nothing to score.
  • A blocked reply stays on screen, and the rewrite appears under it.
  • When the user explicitly asks for exact wording, Claude repeats it. The hook does not block twice, so the session ends cleanly but the tell stays.
  • The hooks need python3 on PATH. Without it they fail open and let text through.
  • Hooks exist only in the Claude Code plugin. npx skills, pi, and ZIP installs get the skill alone.
  • The scorer catches surface tells. It cannot catch a changed fact or an invented detail. The README rewrite test turned "completely free" into "at no extra cost", and only a manual read caught it.
  • The weights come from published ratios and judgment, not from training on labeled data. They will need retuning as model vocabulary shifts.

Other changes

  • README: restructured to the RWS application profile (Status, Requirements, Configuration, Testing, Support), reordered so Usage follows Installation, and the intro now names both parts. Both "After" examples are fresh rewrites of the same "Before" text, with four fact and style fixes. The blind-test note now says it measured an earlier rewrite.
  • scripts/validate-package.py checks hooks/hooks.json and the § labels in the scorer.
  • tests/ adds 15 tests for the scorer and every hook event. CI runs them.
  • AGENTS.md and CHANGELOG describe the new files and rules.

Review notes

Testing

python3 scripts/validate-package.py      # Humanizer package v4.0.0 is valid
python3 -m unittest discover -s tests    # Ran 15 tests ... OK
claude plugin validate .                 # Validation passed

To try it locally, run claude plugin marketplace add ./ and claude plugin install humanizer@humanizer. Start a new session outside this repo and run /hooks.

🤖 Generated with Claude Code

kasutu and others added 6 commits November 28, 2026 01:02
Add hooks/hooks.json (PreToolUse on Write|Edit|MultiEdit) running
scripts/humanizer-hook.py, which blocks prose writes containing
one-sighting tells. HUMANIZER_HOOK=off disables it. Validator checks
the hook file and its pattern labels.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split scoring into scripts/humanizer-lint.py (ste-lint style: features,
per-100-word rates, weighted logistic score, hard one-sighting tells).
humanizer-hook.py now routes SessionStart/UserPromptSubmit (inject rules,
carry thinking findings), PreToolUse (block prose writes), and Stop
(send flagged replies back). Add unittest suite and CI step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add features for §9, §15-§18, §25, fragment runs, rhetorical setups,
and summary closers; split AI words into frequency-weighted tiers;
scale weak features per 200 words; skip front matter, paths, tags, and
mentions after "such as". Expand fixtures to 16 AI / 18 human texts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Same Before inputs. Fixed fact drift ("no extra cost" -> free),
an invented detail, and a §6 triad. Blind-test note now refers to
the earlier rewrite it measured.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add Status, Requirements, Configuration, Testing, and Support; split
long sentences; label code fences; fix stale scorer notes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Usage now follows Installation; Configuration comes after. Intro names
both parts and that the plugin enables hooks in Claude Code settings.
Scorer: a lead-in line ending in a colon is not a closer (new test).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant