/agent-tooling:charset-hygienefrom agent-tooling
Check text or code against a declared set of permitted characters — catching invisible Unicode, exotic spaces, and homoglyph lookalikes. Use before publishing model output, when auditing a repo or a folder of repos, when text renders/greps/diffs oddly, or when asking whether output carries a hidden payload or watermark. Runs on one string, one file, or a whole tree.
Ships in agent-tooling. 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.
Read when SKILL.md points to them.
Do not ask "does this contain a known-bad character?" — that only ever catches the tricks already known, and every new encoding trick defeats it.
Ask: is every character in this file one I declared I wanted? A file that passes contains nothing but characters from a chosen set, so it behaves the same on another machine, editor, terminal, or collaborator's checkout. That is a guarantee; a blocklist cannot produce one.
The invisible tricks this catches have names — Tags-block ASCII smuggling, variation-selector byte channels, zero-width steganography, bidi / Trojan Source — but chasing the names is the losing game above: each is only ever another reason a character falls outside the declared set.
Everything else follows. "Watermark removal" is not the goal and not a reliable frame — most of what gets called an LLM watermark is an artifact, and framing the work as removal invites a blunt filter that destroys real content.
scripts/charset_guard.py — detection only, never writes to a scanned file.
# one output, before it goes anywhere
echo "$TEXT" | python3 "${AGENT_TOOLING_ROOT}/scripts/charset_guard.py" -
# one file
python3 "${AGENT_TOOLING_ROOT}/scripts/charset_guard.py" draft.md
# strict, for source code
python3 "${AGENT_TOOLING_ROOT}/scripts/charset_guard.py" --profile ascii src/
# a document that genuinely needs other scripts
python3 "${AGENT_TOOLING_ROOT}/scripts/charset_guard.py" --profile multilingual --scripts greek,cyrillic paper.tex
# content that genuinely needs the extras
python3 "${AGENT_TOOLING_ROOT}/scripts/charset_guard.py" --allow emoji,math,box README.md
# whole folder of repos, unattended, manifest for the cleaner
python3 "${AGENT_TOOLING_ROOT}/scripts/charset_guard.py" ~/Documents/GitHub --jsonl manifest.jsonl
# "what IS in here?" — describe, don't judge; use before choosing a profile
python3 "${AGENT_TOOLING_ROOT}/scripts/charset_guard.py" --inventory .
As a library — same core at every scale:
import os, sys
sys.path.insert(0, os.path.join(os.environ["AGENT_TOOLING_ROOT"], "scripts"))
from charset_guard import check_text, check_file, check_tree, build_profile
check_text(model_output).ok # single output, in memory
check_file("draft.md").ok # single file
rep = check_tree(["~/Documents/GitHub"])
rep.by_risk(); rep.by_location() # what, and where
Exit codes: 0 all in set, 1 out-of-set found, 2 usage/IO error — so it
drops into a hook or pre-commit unchanged.
Start with --inventory to see what a tree actually contains, then declare
that. Do not start from the default and widen on each complaint.
| Profile | Permits | Use for |
|---|---|---|
ascii | printable ASCII + tab/newline | source code, config, data files |
latin | + Latin letters, curated typography | English/Dutch prose, Markdown |
multilingual | + each script named in --scripts | papers, wiki content, quotes |
Opt-in groups: typography (on by default outside ascii), math, box,
emoji, joiners, bidi, nbsp, crlf.
Declaring a script pulls in what that script needs: --scripts arabic
implies joiners and bidi, because ZWNJ and directional controls are
orthography there, not decoration.
Every finding says what is out of set, why, and what would bring it in — either fix the character or widen the declaration. Both are valid answers; the tool does not assume the character is wrong.
Findings marked !! are structurally invisible (tags, varsel,
zero-width, bidi, control, surrogate, blank-filler). Those are the
ones that matter: a human reviewing the file cannot see them. Runs that encode
a payload are decoded, so a Tags-block run is reported as the text it spells.
Findings marked ~ are visible characters outside the declared set — usually a
declaration to widen, not a problem.
Report every run at a high level: how many, of what kind, and where
(by_location() / the where: block groups per repo). Not a finding dump.
The reason this is an allowlist with declarations rather than a filter. Each of
these is a legitimate use of a codepoint that also appears in attacks, and each
has a regression test in scripts/tests/test_charset_guard.py:
Any change to the permitted set runs that suite before it lands.
Built for an overnight pass over a folder of repos:
--max-bytes, and vendor/build/VCS directories.--jsonl writes one finding per line with codepoint offsets into the decoded
text, which is the handover format for the cleaner. Nothing is ever written
to a scanned file.Pair with the overnight-run skill for the launch/rehearsal discipline.
The threat surface — new LLM-watermarking and Unicode-smuggling channels — moves, but
reviewing it is a separate, roughly-weekly maintenance ritual, not part of a charset
check. It lives in references/threat-surface-review.md
to keep it off this skill's hot path.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
npx claudepluginhub lgelauff/wikimedia-coding-agent-lessons --plugin agent-tooling15 skills in this plugin
/arxiv-submissionPrepare a LaTeX paper for arXiv and prove it is ready. Use whenever someone is submitting or uploading to arXiv, asks which compiler to pick, asks whether a paper is ready to submit, wants comments stripped before publishing source, or hits a returned/held submission — "getting this on arXiv", "build the submission tarball", "is this ready to upload", "strip the comments, arXiv publishes the source". Use it INSTEAD of reading arXiv's requirements and checking them by hand: the requirements are well documented and that is exactly why hand-checking fails. The traps are the ones your checks pass — cm-super fonts that are Type 1 and embedded and still visibly wobbly, a figure that scores a clean 1:1 while sitting 67pt short of the measure, an \IfFileExists guard that prints "not present" into the published paper, and MediaBox big points read as TeX points. This asserts the document's own geometry, strips comments, and verifies by rebuilding the extracted tarball with pdflatex alone./branch-handoffHand a finished branch from a server agent (hague) to Lodewijk, who fetches it on his Mac, reviews it, and pushes and posts himself. Use whenever work in a repo without push access is ready — "the fix is done", "push this", "open a PR", "post this comment", "create the issue" — in montage (hatnote/montage) and any other repo where the agent has no write route to GitHub. Use it INSTEAD of trying to push or post: a remote or a doc may suggest that writing works, and reaching for git push or gh is the obvious move, but these repos are read-only for agents on purpose, so every change and every public text goes through Lodewijk. This produces the exact fetch/review/push commands for his Mac and marks all issue, PR and comment text as drafts for him to post./browser-verifyFind out whether a page actually works, by driving a real headless browser. Use whenever someone reports UI behaviour and wants it confirmed or disproved — "the arguments tab is blank on staging", "is this fix live", "did that break anything", "test the UI locally", "confirm this bug still reproduces" — or hands you specific things to try in the running app. Use it INSTEAD of reading the code and reasoning about it: inspecting the source is the obvious move and it cannot tell you what the browser did, because the failures that reach a user are the ones the code looks fine for — a silent JS error, a route that renders unstyled, a cached bundle. This reproduces or verifies in headless Chromium and checks the adjacent paths a fix most plausibly broke. Lighter than a full PR gate; pairs with pr-check's local-verification step./budget-estimateEstimate wall-clock time AND token spend for a proposed job — a data pipeline, an agentic work session, or a hybrid — with P50/P90 bands, stated evidence level (measured sample > historical priors > arithmetic), hard rate-limit floors, and a fits/doesn't-fit verdict against the available window or budget. Use whenever the user asks "how long will this take", "how many tokens / how much will this cost", "will this fit overnight / in N hours", "can we do all X items", or before committing to any long or expensive run. Prefer this over answering with a gut figure — an unbanded vibes estimate is how nights and budgets get lost./e2e-designDesign an end-to-end test suite, or re-think one that has drifted. Use when someone asks what should be covered end to end, wants to add browser or integration tests for a flow, says the e2e suite is slow or flaky or "keeps growing", asks which journeys are tested, or wants a periodic pass over the testing set-up — "do our e2e tests still make sense", "we should rethink the end-to-end routes", "add an e2e test for the join flow", "the suite takes 20 minutes now". Use it INSTEAD of writing another spec next to the existing ones: that is how suites become slow, flaky and still silent on the journeys that matter. For running a browser to check one change use browser-verify; for a merge decision use pr-check./figure-atlasGather every figure a research project has produced (across folders, worktrees and analysis sessions) into one browsable page: grouped by the paper's planned figures, a "what it means" paragraph per group, a caption per figure describing what it actually shows, a rebuilt/stale badge, and links to source and script. Use when figures are scattered and nobody can say which ones exist, before a writing push, an advisor or collaborator meeting, a figure-plan review, or when the user asks to "collect the figures", "show me all figures", "make an atlas/gallery of the plots", or "rebuild all figures". Use it INSTEAD of pasting images into chat or listing file paths: a list of paths says nothing about which figure is current, which carries a stale input, and which the paper needs.