Back to directory

AI Text Encoding Guard

A detector and repair tool for Chinese text corruption, or mojibake, that AI coding assistants can silently introduce when editing files, usable as a GitHub Action, a Claude Code hook, or a standalone command-line scan.

AI Text Encoding Guard

AI Text Encoding Guard scans files for seven kinds of encoding damage, including UTF-8 bytes misread as GBK, corrupted HTML tags where an AI edit swallowed an angle bracket, and telltale character patterns left by double round-trip conversions, each contributing a weighted score; a file scoring above zero is flagged as suspicious, with a higher score meaning more severe corruption. A command-line tool scans a directory and can output JSON, fail a CI pipeline when it finds corruption, or attempt an automatic fix.

The automatic fix does not blindly replace text: it tries both directions of GB18030-to-UTF-8 re-encoding, then only applies a fix if the corruption score afterward has dropped to a third or less of the original and improved by at least eight points; anything that does not clear both thresholds is left alone and flagged for manual review, with a backup file created for anything it does change. It integrates as a GitHub Action that runs on push and pull request, or as a Claude Code PostToolUse hook that checks files after every Write or Edit.

It is written in Python and released under the MIT license.

More in CLI tools

See all 181
  • grev

    github.com

    A set of Unix coreutils-style filters — grep, sort, cut and more — that answer a plain-language question about each record instead of matching a pattern, using a small decision model.

  • A Node.js script that exports a Google Doc to HTML and CSS with high fidelity, preserving headings, spacing, alignment, bullet lists, images and right-to-left text.

  • gpusched

    github.com

    A VRAM-aware GPU job scheduler for a single machine: declare how much memory each shell command needs, and it places jobs the moment a GPU has room and reports when a guess was wrong.