Skip to content

Universal SEO skill for Claude Code. 26 sub-skills + 19 sub-agents covering technical SEO, E-E-A-T, schema, GEO/AEO, agent readiness (Lighthouse Agentic Browsing, WebMCP, llms.txt), backlinks, local SEO, e-commerce, international SEO, Google APIs, and PDF/Excel reporting. 9 optional extensions for live SEO data.

feat: strip invisible Unicode watermark chars in content_humanize

Gina3a13b30b89cc
diff --git a/scripts/content_humanize.py b/scripts/content_humanize.py
index 0a67b59..e72b0a5 100644
--- a/scripts/content_humanize.py
+++ b/scripts/content_humanize.py
@@ -1,8 +1,18 @@
#!/usr/bin/env python3
"""
AI-pattern remover. Rewrites filler / AI-typical phrasings into
-direct prose. Conservative by design: only replaces phrases listed in
-``_REPLACEMENTS``. Unknown idiom? Leave it alone.
+direct prose, and strips invisible Unicode artifacts ("text
+watermarks") that AI tools and copy-paste pipelines leave behind:
+zero-width characters, directional marks, exotic spaces, and Unicode
+tag characters. Conservative by design: only replaces phrases listed
+in ``_REPLACEMENTS``, and keeps zero-width joiners / variation
+selectors that are part of real emoji sequences. Unknown idiom?
+Leave it alone.
+
+Statistical watermarks (e.g. SynthID-style token-probability
+watermarks) live in word choice, not codepoints; nothing here — or
+anywhere — reliably detects or strips those, so this tool does not
+claim to.
Use case: a content editor running last-mile cleanup on a draft. This
is NOT a paraphraser or a translation tool; it does not introduce new
@@ -92,6 +102,98 @@ _PATTERNS = [
]
+# Invisible / format characters deleted outright. They render as
+# nothing, break regex word boundaries, inflate diffs, and are the
+# codepoints used to fingerprint or smuggle hidden text in AI output.
+_INVISIBLE_DELETE = {
+ "\u00ad": "soft-hyphen",
+ "\u180e": "mongolian-vowel-separator",
+ "\u200b": "zero-width-space",
+ "\u200e": "left-to-right-mark",
+ "\u200f": "right-to-left-mark",
+ "\u202a": "lre-embedding",
+ "\u202b": "rle-embedding",
+ "\u202c": "pop-directional",
+ "\u202d": "lro-override",
+ "\u202e": "rlo-override",
+ "\u2060": "word-joiner",
+ "\u2061": "function-application",
+ "\u2062": "invisible-times",
+ "\u2063": "invisible-separator",
+ "\u2064": "invisible-plus",
+ "\u2066": "lri-isolate",
+ "\u2067": "rli-isolate",
+ "\u2068": "fsi-isolate",
+ "\u2069": "pop-isolate",
+ "\u3164": "hangul-filler",
+ "\ufeff": "zero-width-no-break-space",
+ "\uffa0": "halfwidth-hangul-filler",
+}
+
+# Exotic whitespace normalised to a plain equivalent instead of deleted.
+_INVISIBLE_SPACE = {
+ "\u00a0": ("space", " "), # no-break space
+ "\u2000": ("space", " "), # en quad
+ "\u2001": ("space", " "), # em quad
+ "\u2002": ("space", " "), # en space
+ "\u2003": ("space", " "), # em space
+ "\u2004": ("space", " "), # three-per-em space
+ "\u2005": ("space", " "), # four-per-em space
+ "\u2006": ("space", " "), # six-per-em space
+ "\u2007": ("space", " "), # figure space
+ "\u2008": ("space", " "), # punctuation space
+ "\u2009": ("space", " "), # thin space
+ "\u200a": ("space", " "), # hair space
+ "\u202f": ("space", " "), # narrow no-break space
+ "\u205f": ("space", " "), # medium mathematical space
+ "\u2028": ("newline", "\n"), # line separator
+ "\u2029": ("newline", "\n\n"), # paragraph separator
+}
+
+# Legitimate inside emoji sequences (family/warning/keycap emoji);
+# stripped only when nothing emoji-like sits next to them.
+_EMOJI_GLUE = {
+ "\u200c": "zero-width-non-joiner",
+ "\u200d": "zero-width-joiner",
+ "\ufe0e": "variation-selector-15",
+ "\ufe0f": "variation-selector-16",
+}
+
+
+def _emoji_adjacent(prev: str, nxt: str) -> bool:
+ """True when either neighbour is plausibly part of an emoji sequence."""
+ for ch in (prev, nxt):
+ if ch and (ord(ch) >= 0x2100 or ch == "\u20e3"):
+ return True
+ return False
+
+
+def strip_invisible(text: str) -> tuple[str, dict]:
+ """Remove invisible watermark characters; return (cleaned, counts)."""
+ removed: dict[str, int] = {}
+ out: list[str] = []
+ for i, ch in enumerate(text):
+ if ch in _INVISIBLE_DELETE:
+ label = _INVISIBLE_DELETE[ch]
+ elif ch in _INVISIBLE_SPACE:
+ label, replacement = _INVISIBLE_SPACE[ch]
+ out.append(replacement)
+ elif ch in _EMOJI_GLUE:
+ prev = text[i - 1] if i else ""
+ nxt = text[i + 1] if i + 1 < len(text) else ""
+ if _emoji_adjacent(prev, nxt):
+ out.append(ch)
+ continue
+ label = _EMOJI_GLUE[ch]
+ elif 0xE0000 <= ord(ch) <= 0xE007F:
+ label = "unicode-tag-character"
+ else:
+ out.append(ch)
+ continue
+ removed[label] = removed.get(label, 0) + 1
+ return "".join(out), removed
+
+
def _preserve_case(match_text: str, replacement: str) -> str:
"""If the original starts uppercase, capitalise the replacement."""
if not replacement:
@@ -104,7 +206,9 @@ def _preserve_case(match_text: str, replacement: str) -> str:
def humanize(text: str) -> dict:
"""Apply every replacement; return the cleaned text plus a change log."""
changes: list[dict] = []
- cleaned = text
+ # Strip invisible characters first: zero-width codepoints inside
+ # words would otherwise defeat the \b boundaries below.
+ cleaned, invisible_removed = strip_invisible(text)
for pattern, replacement, label in _PATTERNS:
def _repl(match):
@@ -127,6 +231,8 @@ def humanize(text: str) -> dict:
"cleaned": cleaned,
"changes": changes,
"change_count": len(changes),
+ "invisible_removed": invisible_removed,
+ "invisible_count": sum(invisible_removed.values()),
}
@@ -164,6 +270,14 @@ def main() -> int:
else:
sys.stdout.write(result["cleaned"])
+ if result["invisible_count"]:
+ print(
+ f"\n--- {result['invisible_count']} invisible characters removed ---",
+ file=sys.stderr,
+ )
+ for label, count in sorted(result["invisible_removed"].items()):
+ print(f" {label}: {count}", file=sys.stderr)
+
if result["change_count"]:
print(f"\n--- {result['change_count']} replacements ---", file=sys.stderr)
seen: set[str] = set()
diff --git a/skills/seo-content/SKILL.md b/skills/seo-content/SKILL.md
index 0665c8a..172f295 100644
--- a/skills/seo-content/SKILL.md
+++ b/skills/seo-content/SKILL.md
@@ -1,9 +1,11 @@
---
name: seo-content
description: >
- Content quality and E-E-A-T analysis with AI citation readiness assessment.
- Use when user says "content quality", "E-E-A-T", "content analysis",
- "readability check", "thin content", or "content audit".
+ Content quality and E-E-A-T analysis with AI citation readiness assessment,
+ plus last-mile draft cleanup (AI-typical phrasing and invisible Unicode
+ watermark characters). Use when user says "content quality", "E-E-A-T",
+ "content analysis", "readability check", "thin content", "content audit",
+ "humanize", "AI phrasing", "remove watermarks", or "invisible characters".
user-invocable: true
argument-hint: "[url]"
license: MIT
@@ -136,6 +138,32 @@ Google's raters assess low-quality, scaled, copied, or AI-generated main content
> **Honest scoping (Google docs, 2026-06-05):** per "Using third-party SEO tools, services, and advice," no tool guarantees rankings and third-party tools have no access to Google's internal ranking data. claude-seo's scores are **heuristics**, not Google-internal signals, so say so in reports, and validate GEO/AEO findings against Google's official guidance (Search Console is the first-party source).
+## Draft Cleanup: AI Phrasing & Invisible Watermarks
+
+For "humanize this", "remove watermarks", or "clean up this draft", run the
+bundled cleanup script on the user's own content:
+
+```bash
+claude-seo run content_humanize.py draft.md -o cleaned.md
+cat draft.md | claude-seo run content_humanize.py --json
+```
+
+Two deterministic passes, both logged in the JSON output:
+
+1. **Invisible characters** (`invisible_removed`): strips zero-width
+ codepoints, directional marks/overrides, Unicode tag characters (hidden
+ text smuggling), and normalizes exotic spaces. Emoji sequences (ZWJ,
+ variation selectors next to emoji) are preserved.
+2. **AI-typical phrasing** (`changes`): conservative 1:1 swaps from the
+ replacement table ("delve into" → "explore", etc.). Nothing is
+ paraphrased or added.
+
+Scope honesty: statistical watermarks (SynthID-style token-probability
+schemes) live in word choice, not codepoints. No tool reliably detects or
+removes them; do not claim otherwise in reports. This cleanup is for
+editing the user's own drafts, not for laundering third-party content —
+decline requests to strip provenance from content the user doesn't own.
+
## AI Citation Readiness (GEO signals)
Optimize for AI search engines (ChatGPT, Perplexity, Google AI Overviews):
diff --git a/tests/test_content_humanize.py b/tests/test_content_humanize.py
new file mode 100644
index 0000000..376fbc6
--- /dev/null
+++ b/tests/test_content_humanize.py
@@ -0,0 +1,71 @@
+"""Tests for content_humanize.py: phrase swaps + invisible-character strip."""
+
+import sys
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "scripts"))
+
+from content_humanize import humanize, strip_invisible # noqa: E402
+
+
+def test_zero_width_space_removed_inside_word():
+ cleaned, removed = strip_invisible("wat​er​mark")
+ assert cleaned == "watermark"
+ assert removed == {"zero-width-space": 2}
+
+
+def test_exotic_spaces_normalised():
+ cleaned, removed = strip_invisible("10 GW and more")
+ assert cleaned == "10 GW and more"
+ assert removed["space"] == 2
+
+
+def test_line_separator_becomes_newline():
+ cleaned, _ = strip_invisible("a
b")
+ assert cleaned == "a\nb"
+
+
+def test_emoji_sequences_preserved():
+ family = "\U0001f468‍\U0001f469‍\U0001f467"
+ warning = "⚠️"
+ keycap = "1️⃣"
+ text = f"{family} {warning} {keycap}"
+ cleaned, removed = strip_invisible(text)
+ assert cleaned == text
+ assert removed == {}
+
+
+def test_stray_variation_selector_stripped():
+ # VS-16 sandwiched between plain ASCII is a fingerprint, not an emoji.
+ cleaned, removed = strip_invisible("pla️in")
+ assert cleaned == "plain"
+ assert removed == {"variation-selector-16": 1}
+
+
+def test_unicode_tag_characters_stripped():
+ # Tag characters (U+E0000 block) are used to smuggle hidden text.
+ hidden = "".join(chr(0xE0000 + ord(c)) for c in "hi")
+ cleaned, removed = strip_invisible(f"visible{hidden}")
+ assert cleaned == "visible"
+ assert removed == {"unicode-tag-character": 2}
+
+
+def test_directional_override_stripped():
+ cleaned, removed = strip_invisible("safe‮vil")
+ assert cleaned == "safevil"
+ assert removed == {"rlo-override": 1}
+
+
+def test_humanize_strips_invisible_before_phrase_matching():
+ # A zero-width space inside "delve" must not defeat the \b pattern.
+ result = humanize("Let's del​ve into roofing.")
+ assert "delve" not in result["cleaned"]
+ assert result["invisible_count"] == 1
+ assert any(c["label"] == "delve-into" for c in result["changes"])
+
+
+def test_humanize_reports_zero_on_clean_text():
+ result = humanize("Plain honest prose about roof repair.")
+ assert result["cleaned"] == "Plain honest prose about roof repair."
+ assert result["invisible_count"] == 0
+ assert result["change_count"] == 0