Skip to content
Skills Library
Law & compliance · Conversion & formats

text-anonymizer

/text-anonymizer

Depersonalizes prose and documents by replacing locale-bound references (employer, legal entity, city, region, districts, domains, email, partner banks, local brands, channel names and handles) with equivalents from another country, or by neutralizing them into generic wording. Use whenever the user wants to anonymize, depersonalize, de-identify, relocalize or "singapurize" text, remove ties to a city, region or employer, publish a case study without naming their company, swap the locale in a resume, post, article, chat export or agent memory file, or asks "find every mention of X in my projec

Licence
MIT
Last repository change
12.11.2026

Assessment and security

87/ 100Class: good
Format20 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability17 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
10
Scripts
5
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 12.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What to check before installing
  • 5 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/apply.py, scripts/common.py, scripts/restore.py, scripts/scan.py, scripts/verify.py

What it does and when to use it

Depersonalizes prose and documents by replacing locale-bound references (employer, legal entity, city, region, districts, domains, email, partner banks, local brands, channel names and handles) with equivalents from another country, or by neutralizing them into generic wording. Use whenever the user wants to anonymize, depersonalize, de-identify, relocalize or "singapurize" text, remove ties to a city, region or employer, publish a case study without naming their company, swap the locale in a resume, post, article, chat export or agent memory file, or asks "find every mention of X in my projec

Triggers from the description

singapurize
Original author description

Depersonalizes prose and documents by replacing locale-bound references (employer, legal entity, city, region, districts, domains, email, partner banks, local brands, channel names and handles) with equivalents from another country, or by neutralizing them into generic wording. Use whenever the user wants to anonymize, depersonalize, de-identify, relocalize or "singapurize" text, remove ties to a city, region or employer, publish a case study without naming their company, swap the locale in a resume, post, article, chat export or agent memory file, or asks "find every mention of X in my projec

How it works

  1. Two modes
  2. Step 0 - Intake (never skip, never assume)
  3. Step 1 - Inventory
  4. Step 2 - Build the mapping
  5. Step 3 - Get approval
  6. Step 4 - Apply
  7. Step 5 - Language and sense pass
  8. Step 6 - Verify
  9. Step 7 - Cleanup and report
  10. Step 8 - Restore the model's output (reverse pass)
Original SKILL.md headings · 265 lines, 1,987 words
SKILL.md preview
---
name: text-anonymizer
description: Depersonalizes prose and documents by replacing locale-bound references (employer, legal entity, city, region, districts, domains, email, partner banks, local brands, channel names and handles) with equivalents from another country, or by neutralizing them into generic wording. Use whenever the user wants to anonymize, depersonalize, de-identify, relocalize or "singapurize" text, remove ties to a city, region or employer, publish a case study without naming their company, swap the locale in a resume, post, article, chat export or agent memory file, or asks "find every mention of X in my project". Always ask what is being anonymized and which target country to use; never assume a default locale. Handles Russian inflection and homonym collisions, hunts invisible local ties, and verifies that no originals survive. Also reverses the job: use when the user wants to restore, un-anonymize, de-anonymize or put back the original names in a model's output after working on anonymized text («вернуть обратно», «восстановить исходные названия», «отсингапурить в обратную сторону»), keeping the re-identification key local.
---

# Text Anonymizer

Swap the locale out of a text without breaking the text. Someone wants to publish a
case study, a resume, a blog post or an agent memory dump without revealing where
they live and who they work for. The naive approach - find-and-replace the city name -
produces broken grammar, mangled unrelated words, and a false sense of safety, because
the strongest identifiers are usually the ones nobody thought to search for.

This skill runs the job as a pipeline: **intake → inventory → mapping → approval →
apply → language pass → verify → cleanup**, plus an optional **restore** pass that
puts the originals back into a model's output. Each stage exists because skipping it
has a specific, predictable failure mode.

## Two modes

Ask which one the user wants; they are not interchangeable.

| Mode | What happens | When it fits |
|---|---|---|
| `substitute` | Every local reference becomes a specific counterpart in the target country | The text should read as if the author lives there |
| `neutralize` | References become generic wording: "a telecom operator", "a large city", "a partner bank" | The author does not want to claim a new identity, just remove the old one |

`neutralize` is safer and often what a publication rule actually requires. `substitute`
creates new factual claims (a new employer, a new city, a new bank), so it needs the
user's explicit sign-off on each entity. Many jobs mix both: substitute the geography,
neutralize the employer.

## Step 0 - Intake (never skip, never assume)

The target country is the user's choice, not a default. Ask before touching anything.
Use `AskUserQuestion` when available, otherwise ask in plain text.

Required questions:

1. **What are we anonymizing?** Exact files, directories, or a scope description.
   Offer the inventory you can already see, and separate authored text from raw data
   dumps - they differ by orders of magnitude in effort and risk.
2. **Which target country / locale?** Do not propose one as the default. If the user
   has no preference, offer 2-3 concrete options and let them pick.
3. **Which mode?** `substitute`, `neutralize`, or mixed.
4. **Entity-level decisions** for anything that needs a real-world counterpart:
   legal entity, brand, product names, domains, email, partner bank, local chains.
   A wrong bank or a real company name used as a fictional employer creates a new problem.

Also confirm two boundaries that people rarely think about until it is too late:

- **Raw data** (chat exports, logs, crawled feeds): include or leave alone? These can
  hold thousands of occurrences and are often the strongest deanonymization source.
- **Non-text carriers**: images, screenshots, filenames, git history. Text replacement
  cannot fix these; the user needs to know they remain.

Record the answers. Everything downstream depends on them, and re-asking mid-job
wastes the user's time.

## Step 1 - Inventory

Run the scanner over the agreed scope:

```bash
python scripts/scan.py <paths> --terms "<employer>,<city>,<region>" --json work/inventory.json
```

It reports every inflected form with counts and sample contexts, plus filenames and
`@handles` that carry the term. Read the output before writing any mapping - the form
list tells you which declensions you have to handle.

Then do a **second pass for invisible ties**, which the scanner cannot find because
they do not contain the search terms. This is where most leaks survive. Look for:

- districts, suburbs, streets, parks, rivers, local landmarks
- regional companies, banks, railways, utilities, sports clubs, local media and bloggers
- phone area codes, postal code prefixes, regional internet domains
- local slang, demonyms, and puns built on the city name
- universities, employers' subsidiaries, conference names

`references/leak-checklist.md` has the full checklist and the cleanup rules.
For Russian text, `references/ru-inflection.md` covers declension and homonyms - read
it before building the mapping, not after the grammar breaks.

## Step 2 - Build the mapping

Write a mapping file (template: `assets/mapping.example.json`):

```json
{
  "target_locale": "<country>",
  "mode": "substitute",
  "protect": ["<homonym fragments that must never change>"],
  "pairs": [
    {"from": "<longest, most specific form>", "to": "<replacement>", "note": "legal entity"}
  ]
}
```

Rules that come from real failures:

- **Longest first.** `apply.py` sorts by length automatically, but write specific
  multi-word phrases anyway (`ООО «X» (Y)` before `Y`). A short pair applied first
  eats the context a longer pair needed, and you get duplicated tokens.
- **Protect the homonyms.** A brand root often lives inside ordinary words
  (`мотивация`, `лейтмотив`, `по мотивам`, English `motive`), surnames, and unrelated
  companies. List those fragments in `protect`; they are masked during replacement
  and restored afterwards. Replacing by bare root is the single most destructive
  mistake in this job.
- **Cover every declension** you saw in the inventory, not just the nominative.
- **Decide handles explicitly.** Changing a channel's display name while leaving
  `@city_channel` intact leaks exactly what you were hiding. Either change both or
  leave both, and tell the user which you did.
- **Keep the mapping out of the final tree.** It contains every original name in one
  place - it is a deanonymization key. Same for backups. Plan their removal in Step 7.

## Step 3 - Get approval

Show the user the mapping as a table (original → replacement → why) and the list of
things you deliberately left alone. Substitutions are editorial decisions about their
identity, not mechanical edits; a wrong counterpart is worse than no edit. Wait for
confirmation before applying.

If the scope is large, apply to one representative file first and show the diff.

## Step 4 - Apply

Dry run, then real run:

```bash
python scripts/apply.py --mapping mapping.json <paths> --dry-run
python scripts/apply.py --mapping mapping.json <paths> --backup-dir work/backup-anon
```

If the user plans to restore the originals later (the usual reason to anonymize before
sending text to a model), emit the round-trip key in the same run:

```bash
python scripts/apply.py --mapping mapping.json <paths> \
  --backup-dir work/backup-anon --emit-key work/roundtrip-key.json
```

The script preserves bytes and line endings, backs up originals, validates JSON files
after replacement (and rolls back a file if it stopped parsing), and reports
per-pair counts. It also flags suspicious artifacts for the next step.

Backups are mandatory when there is no version control. Check for a git repo first;
without one, an unrecoverable bulk edit is a real risk.

## Step 5 - Language and sense pass

Mechanical replacement is not the end. Read every changed line and fix:

- **Grammar.** Substituting a nominative form into an oblique case produces nonsense
  ("каналы Сингапур и Москвы"). The replacement has to agree with the sentence.
- **Sense.** A district name, a pun, or a sports club may need a different counterpart
  than the city does, or may need to stay untouched.
- **Artifacts.** Doubled tokens (`Globex Globex`), a replacement glued to a suffix
  (`Globexация`), a replacement inside a URL or a hex color that was never a match.
- **Factual claims.** If the text now asserts something the user never said (a real
  relocation, a real employer, a real bank relationship), flag it rather than smoothing
  it over. Anonymizing is not inventing a biography.

`apply.py` and `verify.py` list candidate artifacts; the judgement is yours.

## Step 6 - Verify

```bash
python scripts/verify.py <paths> --terms "<original terms>" --targets "<replacements>" --allowlist work/allowlist.txt
```

Exit code is non-zero while real leftovers remain, so this can drive a loop:
fix → re-verify → repeat until clean. The script separates genuine leftovers from
benign homonyms (via the allowlist of word fragments), and checks the leak vectors
that text replacement misses: filenames, `.pyc` bytecode, git logs and config,
backup directories, and the mapping file itself.

Report honestly what is still there. "Clean" means clean within the agreed scope,
not clean everywhere.

## Step 7 - Cleanup and report

Ask whether the user wants a tree with no trace of the originals. If yes, remove:

- the backup directory (and the empty folder left behind)
- the mapping file and any inventory/report JSON that quotes originals
- generated `.pyc` files - they embed the old strings and are easy to miss

Then re-run `verify.py` over the whole tree, not just the edited scope.

If a restore is planned (Step 8), do not destroy the key yet. Move it and the backups
outside the published tree instead of deleting them, and tell the user where they are.
Deleting the key before restoring makes the originals unrecoverable.

Finish with a report: what changed per file, the mapping used, what was deliberately
left alone (raw data, images, git history), and what still needs a human decision.
Name the remaining deanonymization vectors explicitly - a partial job described as
complete is the worst outcome.

## Step 8 - Restore the model's output (reverse pass)

The usual reason to anonymize before sending text to a model is to put the real names
back afterwards. Reversing is **not** symmetric, and guessing here silently corrupts
text, so `restore.py` reports instead of guessing.

```bash
python scripts/restore.py <model-output> --key work/roundtrip-key.json --dry-run
python scripts/restore.py <model-output> --key work/roundtrip-key.json \
  --backup-dir work/backup-restore --verify-against work/backup-anon
```

Three things block a clean reverse, and each has an explicit remedy:

| Blocker | What the script does | Remedy |
|---|---|---|
| Many-to-one: two originals became one replacement | Leaves those occurrences untouched and prints them with context | `--decisions-template out.json`, fill it, pass `--decisions` |
| New target forms the model produced (plural, new case, derivation) | Reports them as unknown, never guesses | Add pairs to `key.reverse_extra` |
| Legitimate mentions of the target locale | Would be reversed along with everything else | List them in `key.protect_reverse` |

Decisions can be a global choice (`"Globex": "Ромашка"`) or context rules
(`[{"contains": "Работаю в", "choose": "ООО «Ромашка»"}, {"default": "Ромашка"}]`).
The script exits non-zero while anything is unresolved, so it drives the same
fix → re-run loop as `verify.py`.

`--verify-against` compares the restored text with the pre-anonymization originals and
reports `identical` or `differs`. `differs` is expected when the model edited the text;
`identical` on an untouched file is the proof that the round trip is lossless.

**The key never goes to the model.** It maps every replacement back to the original,
so pasting it into a prompt defeats the entire anonymization. Keep it local, out of
git, and delete it once the restore is done and verified.

When designing a mapping for a job that will be restored, prefer an **injective**
mapping: one original → one distinct replacement. Collapsing several originals into
one target is what creates ambiguity, and avoiding it up front is cheaper than
resolving it occurrence by occurrence afterwards.

See `references/round-trip.md` for the key format, target-language inflection and
the failure modes in detail.

## Boundaries

This is privacy and publication hygiene: removing identifiers from text the user owns.
Keep it that way. Do not use it to fabricate credentials, alter identity or financial
documents, impersonate a real person or company, or misrepresent facts to a service
that is verifying them. If a request crosses that line, say so and stop.

Also: never invent biographical details to fill a gap. If a counterpart is unknown,
ask or neutralize - do not guess.

## Resources

- `references/ru-inflection.md` - Russian declension, homonym protection, invisible
  ties specific to Russian-language text. Read before building a mapping for Russian.
- `references/leak-checklist.md` - where identifiers hide beyond the obvious terms,
  and how to clean up without leaving a deanonymization key behind.
- `references/round-trip.md` - reverse pass: key format, ambiguity decisions,
  target-language inflection, key hygiene. Read before restoring.
- `assets/mapping.example.json` - mapping template with a fictional example.
- `scripts/scan.py` - inventory of forms, counts, contexts, filenames, handles.
- `scripts/apply.py` - ordered, protected replacement with backup and JSON safety;
  `--emit-key` writes the round-trip key.
- `scripts/verify.py` - leftover and artifact detection, leak vectors, exit code for loops.
- `scripts/restore.py` - reverse pass: puts the originals back, resolves ambiguity by
  decision rather than guesswork, checks round-trip integrity.

Scripts need Python 3.8+ and no third-party packages. Run them from the skill
directory or by absolute path; they import their shared helper from `scripts/`.
Files in this package (10)
  • SKILL.md 14 KB
  • assets/mapping.example.json 3 KB
  • references/leak-checklist.md 6 KB
  • references/round-trip.md 7 KB
  • references/ru-inflection.md 7 KB
  • scripts/apply.py 9 KB
  • scripts/common.py 13 KB
  • scripts/restore.py 11 KB
  • scripts/scan.py 5 KB
  • scripts/verify.py 10 KB

Versions

The database has no other skills named text-anonymizer.

Database snapshot: 13.11.2026 · package version af36dc152a3c (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100anonymizer
    Use when anonymizing text or images. Selective local PII and API-key masking, low–high coverage, context preserved by default.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.