Jakeschincariol/linkedin-agent-skill / skills/li-human
li-human
VerifiedStrip the machine fingerprint out of any draft - em dashes, AI slop words, invisible watermark characters - and score it against a five-check detection panel before it goes out. Use whenever text needs to sound human, when the user says humanize, "does this sound like AI", "remove the em dashes", "de-slop this", "will this get flagged", or before any LinkedIn post, comment, reply or DM is shown to the user.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 4.4 KB |
| detect.pyexecutable | script | 8.3 KB |
| humanize.pyexecutable | script | 9.2 KB |
| slop.json | config | 15.5 KB |
humanize.py
View on GitHub#!/usr/bin/env python3
"""
humanize.py - strip the machine fingerprint out of a draft.
Three passes, in this order:
1. INVISIBLE delete or normalise the characters a human keyboard never
produces: zero-width joiners, word joiners, soft hyphens,
BOMs, Unicode tag characters, non-breaking and narrow spaces.
These survive copy-paste and are the most mechanical tell in
any generated text.
2. TYPOGRAPHIC em dash -> comma, en dash -> hyphen, curly quotes -> straight,
ellipsis -> three dots, bullet -> hyphen.
3. LEXICAL replace the slop lexicon in slop.json with plain words,
preserving capitalisation and leaving URLs untouched.
Structural tells (rule-of-three, "not just X, it's Y", hashtag walls) are
REPORTED, never auto-rewritten - rewriting a sentence's shape needs judgement,
so that is the model's job, not a regex's.
Usage
python3 humanize.py draft.txt
python3 humanize.py draft.txt --report
pbpaste | python3 humanize.py - --report
python3 humanize.py draft.txt --json
python3 humanize.py draft.txt -o clean.txt
"""
import argparse
import json
import os
import re
import sys
import unicodedata
HERE = os.path.dirname(os.path.abspath(__file__))
LEX = os.path.join(HERE, "slop.json")
URL_RE = re.compile(r"https?://\S+|www\.\S+|\S+@\S+\.\S+")
SENT_RE = re.compile(r"[^.!?\n]+[.!?]*")
def load_lexicon(path=LEX):
with open(path, encoding="utf-8") as fh:
return json.load(fh)
def _cp(spec):
"""'U+200B' -> '\\u200b'; 'U+E0000-U+E007F' -> (start, end)."""
if "-" in spec:
a, b = spec.split("-")
return (int(a[2:], 16), int(b[2:], 16))
return int(spec[2:], 16)
def protect_urls(text):
"""Swap URLs for placeholders so no pass rewrites inside a link."""
found = []
def stash(m):
found.append(m.group(0))
return f"\x00URL{len(found) - 1}\x00"
return URL_RE.sub(stash, text), found
def restore_urls(text, found):
for i, url in enumerate(found):
text = text.replace(f"\x00URL{i}\x00", url)
return text
def pass_invisible(text, lex):
"""Delete or space-normalise invisible characters. Returns (text, hits)."""
hits = []
for entry in lex["invisible"]:
cp = _cp(entry["cp"])
if isinstance(cp, tuple):
pattern = "[" + re.escape(chr(cp[0])) + "-" + re.escape(chr(cp[1])) + "]"
else:
pattern = re.escape(chr(cp))
n = len(re.findall(pattern, text))
if n:
hits.append({"name": entry["cp"] + " " + entry["name"], "count": n,
"action": entry["action"]})
text = re.sub(pattern, "" if entry["action"] == "delete" else " ", text)
# Any remaining Cf (format) character is invisible by definition.
stray = [c for c in text if unicodedata.category(c) == "Cf"]
if stray:
hits.append({"name": "other invisible format chars", "count": len(stray),
"action": "delete"})
text = "".join(c for c in text if unicodedata.category(c) != "Cf")
return text, hits
def pass_typographic(text, lex):
hits = []
for entry in lex["typographic"]:
ch = entry["from"]
n = text.count(ch)
if not n:
continue
hits.append({"name": f"{ch} {entry['name']}", "count": n, "to": entry["to"].strip() or "(space)"})
if ch == "—":
# " word — word " and "word—word" both collapse to a comma + space.
text = re.sub(r"\s*—\s*", ", ", text)
elif ch == "–":
text = re.sub(r"\s*–\s*(?=\d)", "-", text) # 5–10 -> 5-10
text = re.sub(r"\s+–\s+", ", ", text) # used as em dash
text = text.replace("–", "-")
else:
text = text.replace(ch, entry["to"])
# A comma inserted before existing punctuation reads wrong.
text = re.sub(r",\s*([,.;:!?])", r"\1", text)
text = re.sub(r",\s*\n", "\n", text)
return text, hits
def _match_case(src, repl):
if not repl:
return repl
if src.isupper() and len(src) > 1:
return repl.upper()
if src[0].isupper():
return repl[0].upper() + repl[1:]
return repl
def pass_lexical(text, lex):
"""Replace slop words and phrases. Longest first so phrases win."""
hits = []
entries = sorted(lex["phrases"] + lex["words"],
key=lambda e: len(e["find"]), reverse=True)
for entry in entries:
find = entry["find"]
pattern = re.compile(r"\b" + re.escape(find).replace(r"\ ", r"\s+") + r"\b",
re.IGNORECASE)
found = pattern.findall(text)
if not found:
continue
hits.append({"find": find, "replace": entry["replace"] or "(deleted)",
"count": len(found), "family": entry["family"]})
text = pattern.sub(lambda m: _match_case(m.group(0), entry["replace"]), text)
# Clean up after deletions.
text = re.sub(r"[ \t]{2,}", " ", text)
text = re.sub(r"(?m)^[ \t]*([,.;:])\s*", "", text)
text = re.sub(r"\s+([,.;:!?])", r"\1", text)
text = re.sub(r"(?m)^[ \t]+$", "", text)
text = re.sub(r"\n{3,}", "\n\n", text)
# An em dash that became a comma, followed by a sentence connective, leaves
# a splice ("is important, also, it's proof"). Promote it to a full stop.
text = re.sub(r",\s*(also|so|still|basically|in the end)\s*,\s*",
lambda m: ". " + m.group(1)[0].upper() + m.group(1)[1:] + ", ", text)
return text, hits
def scan_structures(text, lex):
flags = []
for s in lex["structures"]:
try:
pattern = re.compile(s["regex"], re.MULTILINE)
except re.error:
continue
found = pattern.findall(text)
if found:
flags.append({"name": s["name"], "count": len(found), "fix": s["fix"]})
# Sentence-length uniformity is structural too.
lens = [len(s.split()) for s in SENT_RE.findall(text) if len(s.split()) > 2]
if len(lens) >= 4:
mean = sum(lens) / len(lens)
var = sum((n - mean) ** 2 for n in lens) / len(lens)
cv = (var ** 0.5) / mean if mean else 0
if cv < 0.35:
flags.append({
"name": f"Uniform sentence length (variation {cv:.2f})",
"count": len(lens),
"fix": "Break one sentence in half. Let another run long. Machines write even.",
})
return flags
def humanize(text, lex):
text, urls = protect_urls(text)
text, inv = pass_invisible(text, lex)
text, typo = pass_typographic(text, lex)
text, lexi = pass_lexical(text, lex)
text = restore_urls(text, urls)
return text.strip() + "\n", {
"invisible": inv,
"typographic": typo,
"lexical": lexi,
"structures": scan_structures(text, lex),
}
def render_report(report, out=sys.stderr):
def head(title):
print(f"\n{title}\n" + "-" * len(title), file=out)
total = sum(h["count"] for h in report["invisible"]) \
+ sum(h["count"] for h in report["typographic"]) \
+ sum(h["count"] for h in report["lexical"])
head("HUMANIZE REPORT")
print(f"{total} machine artefacts removed, "
f"{len(report['structures'])} structural tells flagged for rewrite", file=out)
if report["invisible"]:
head("1. INVISIBLE CHARACTERS")
for h in report["invisible"]:
print(f" {h['count']:>3}x {h['name']} -> {h['action']}", file=out)
if report["typographic"]:
head("2. TYPOGRAPHY")
for h in report["typographic"]:
print(f" {h['count']:>3}x {h['name']} -> {h['to']}", file=out)
if report["lexical"]:
head("3. SLOP LEXICON")
for h in report["lexical"]:
print(f" {h['count']:>3}x {h['find']} -> {h['replace']} [{h['family']}]", file=out)
if report["structures"]:
head("4. STRUCTURAL TELLS (not auto-fixed - rewrite these yourself)")
for h in report["structures"]:
print(f" {h['count']:>3}x {h['name']}\n {h['fix']}", file=out)
if not any(report.values()):
head("CLEAN")
print(" Nothing to strip.", file=out)
print("", file=out)
def main():
ap = argparse.ArgumentParser(description="Strip the machine fingerprint out of a draft.")
ap.add_argument("input", nargs="?", default="-", help="file, or - for stdin")
ap.add_argument("-o", "--out", help="write cleaned text here instead of stdout")
ap.add_argument("--report", action="store_true", help="print what changed, to stderr")
ap.add_argument("--json", action="store_true", help="emit {text, report} as JSON")
ap.add_argument("--lexicon", default=LEX, help="path to slop.json")
args = ap.parse_args()
raw = sys.stdin.read() if args.input == "-" else open(args.input, encoding="utf-8").read()
lex = load_lexicon(args.lexicon)
clean, report = humanize(raw, lex)
if args.json:
print(json.dumps({"text": clean, "report": report}, indent=2, ensure_ascii=False))
return
if args.out:
with open(args.out, "w", encoding="utf-8") as fh:
fh.write(clean)
print(f"wrote {args.out}", file=sys.stderr)
else:
sys.stdout.write(clean)
if args.report:
render_report(report)
if __name__ == "__main__":
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |