Claude Cursor Skill

deid

Scrub a person's or organization's data from a shared repository or artifact when it may hold their data or is about to go public. Needles come from that owner's own records (names in every script, handles, emails, phone numbers, addresses, account and client ids); each hit becom

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Download lilmgenius-paperthin-skills_depth_deid-dd00a4a.zip · 35 KB

Install

skills CLI npx skills add https://github.com/LilMGenius/paperthin/tree/main/skills/depth/deid
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install lilmgenius-paperthin@llmmart
Git git clone https://github.com/LilMGenius/paperthin.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole lilmgenius/paperthin collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

Find one owner's data in a shared artifact with needles built from that owner's records, replace each hit with the role it plays, report which commits still carry it, and rewrite those commits once the repository's owner approves.

Goal

A shared artifact (a public repository, a template, a fixture set, a deliverable) holds nothing that belongs to one person or one organization, and still works: each leaked value is replaced by the role it plays or a placeholder that exercises the same code, or kept with a stated reason when it is already public. The working tree is changed only through a recorded decision file, so a rerun replays the same decisions. History is read first: the run lists where the repository's history carries a needle. Rewriting it is the repository owner's decision, and on their approval the same decision file rewrites the past commits into new ones. The run moves no ref: it hands over a map file of old and new ids, and whoever moves the refs works from it.

The scope is what the human named: one artifact and one owner. The run never picks its own target or widens either.

Workflow

  1. Pin the artifact and the owner. Name the folder or repository and the one person or organization whose data must leave it. If the human named neither, ask; if several owners are involved, run once per owner.
  2. Build the needles from the owner's own records. Read the records the human points to (identity and login files, profiles, business and payout settings, client lists, ledgers, message exports) read-only, and ask for them when none were named, and write a needle file: a JSON array of { "label": "...", "value": "...", "ci": true, "regex": true } rows, ci and regex optional, every label unique and naming the kind of value (client-phone, owner-name-ko), never the value itself, since labels are printed. Spell each value every way it is written (a name in each script and order, a phone with and without separators and with the country code, an email in any case, an id with and without its prefix). A short or common word becomes a regex with boundaries, since the script refuses a plain needle under three characters. \b knows only ASCII letters, digits and the underscore, so a word in any other script (Hangul, kana, Cyrillic, a Latin word that starts or ends with an accented letter) is bounded by lookarounds on that script's letters, as (?<![가-힣])길동(?![가-힣]) for a Korean given name; the script compiles no Unicode property escape such as \p{L} and refuses a needle that uses one. Keep the file outside the artifact or under a gitignored local name, and never print a value: every later step names a needle by its label.
  3. List the hits. From this skill's folder run node scripts/deid.mjs scan <root> --needles <file> [--decisions <file>] [--no-git] [--json]. Inside a git work tree it reads every file git does not ignore; --no-git reads every file under the root. It prints each hit as file, line, column and label, never the value; a needle in the file's name or a folder above it is a hit marked (path), and every printed path shows a needle in it as <label>. Exit 0 means no hit, 3 hits, 2 a usage error or a broken needle file. Every file that is not UTF-8 text is listed whether or not it hits, its hits carry no line, and it is never rewritten: one that opens with a UTF-16 byte-order mark is read as UTF-16, and any other is searched byte for byte, so a needle written in another encoding (Hangul in a legacy Korean code page, UTF-16 with no mark) stays unseen in it. A listed file that could hold the owner's data is named in the report for a person to check.
  4. Judge each hit and record the decision. Read the hit in context to judge it, and quote neither the value nor the line around it back (Rules), then decide one of three things. A value already public by the owner's choice (the repository's own address, a published author credit, a public profile the artifact cites) is kept with its reason. A value in prose becomes the role it plays (the operator, the client, the company). A value in code, a test or a fixture becomes a placeholder of the same shape that still exercises the same branch: a reserved example domain for an email, an obviously synthetic number of the same length, a made-up name; check every assertion that reads it. Write a decision file, a JSON array of { "needle": "<label>", "replace": "..." } or { "needle": "<label>", "keep": "<reason>" } rows with optional "paths": [globs] matched against the path relative to the root the script was given (in history and rewrite, the repository's top folder), where ** crosses folders, * and ? stay inside one, and a glob with no wildcard also names a folder and everything under it. A row with paths decides only files under them; a row without decides every hit, history's messages, identities and refs included. The first row whose needle and paths fit a hit decides it, so put scoped rows before general ones. A needle in a path is decided like one in text: a replace moves the file to the path it gives, and since a link or import naming that path carries the same needle, a row without paths rewrites both alike. The script refuses a replacement that itself carries a needle. Keep this file beside the needle file.
  5. State how serious the findings are, then apply on the human's go-ahead. Before any change, tell the human what kind of data was found (identity, contact, credentials, client records, business figures, platform ids) and how much: for each kind, its hits and the files they sit in, as labels and counts only. The remedy they pick depends on it, so wait for their go-ahead, then run node scripts/deid.mjs apply <root> --needles <file> --decisions <file> [--no-git] [--json], passing --no-git exactly when the scan did, since it decides which files are read. It rewrites only files whose text changes, moves a file whose path a decision changes (removing a folder the move empties, and refusing a move onto a path another file holds or one that empties a name), resolves overlapping needles to the earliest, then the longest, and leaves a hit no decision fits in place; exit 3 means hits are still open. Repeat steps 4 and 5 until scan with --decisions exits 0, or until every hit it still lists sits in a file that is not UTF-8 text, which no decision rewrites: the report names each such file for the person to re-export, edit or remove, and a scan after their change closes it. Then run the artifact's own tests and checks; a failure goes back into the decision file as a better placeholder, never into a hand edit.
  6. Scan history read-only. In a git repository run node scripts/deid.mjs history <root> --needles <file> [--decisions <file>] [--rev <rev>]... [--json]. It reads every ref in this clone, remote-tracking ones included, unless --rev names some, and changes nothing. In those refs it reads every past file (decoded as scan decodes it), every file path, every commit's message, author and committer, and every ref's name with an annotated tag's tagger and message. Per needle label it lists the commits that entered the needle into a file or a path, the commits whose message or identity carries it, the refs whose name or tag message carries it, and the annotated tags whose tagger does. A commit enters a needle into a file when that file holds more occurrences than the same path in every parent, and into a path when it adds a path that carries it; so a rename is listed under its new path, and an edit or merge that only carries the needle is not. Message and identity hits print the commit id only, and a needle inside a printed path or ref name prints as <label>. A keep decision hides the hits it fits; a replace decision hides none, since the past still holds the value. Exit 0 means history is clean, 3 that a past file, path, message or ref still carries a needle, 4 that only identities do (an author, a committer or a tagger), which no rewrite changes (step 8), and 2 a usage error or a folder outside git.
  7. Report, and put the history to its owner. Report the working tree result (files rewritten or moved, values kept and why, hits left open, files not UTF-8 text for a person to check) and the history result. When history carries a needle, put the rewrite to the repository's owner, the person who controls the repository and its host, who may not be the owner whose data it is. Tell them what it costs and ask whether to run it: every listed commit and each of its descendants, which carry the needle until a later commit removes it, get new ids; a rewritten commit someone else committed with a signature comes back unsigned, and so does every annotated tag on a rewritten commit, since each tag is made again; the rewrite keeps every author, committer and tagger line, so one that spells a needle stays until the repository's owner has it replaced outside this run (step 9); every ref on them moves and is force pushed; every other clone and fork keeps the old commits until it is re-cloned; and the host may keep serving them until its support purges them. Recreating the repository is the alternative. The human running the skill gives that approval only when they are that owner, and otherwise carries the question to them. Without the approval the run ends at this report.
  8. Rewrite on the repository's owner's approval. Run node scripts/deid.mjs rewrite <root> --needles <file> --decisions <file> [--rev <rev>]... --json and save its whole output as UTF-8 to a new file beside the decision file, never over the earlier map file. Exits 0, 3 and 4 print a map, and that new file becomes the map file the later steps use; exit 2 prints none, and the earlier one stays in use. It reads the refs history reads and applies the decision file to every past file, path and commit message in them as apply does to the working tree, leaving a file that is not UTF-8 text, and a path under a name that is not UTF-8, as they were. Each commit keeps its author, its committer, both dates and its other headers byte for byte, and one no needle reaches, directly or through a parent, keeps its id. A rewritten commit that carried a signature is signed again with user.signingkey when the repository's user (user.email) committed it, one git commit-tree -S call each, and otherwise comes back unsigned, since a signature would claim someone else's commit; the JSON counts those under unsigned. A commit that carried no signature stays unsigned, so a user who never signs needs no key, and with user.email unset every signed commit comes back unsigned. It writes new objects and moves no ref. Its JSON holds map, each old commit id to its new one in the shape re0-git's rebuild.mjs prints; refs, each ref on a rewritten commit (a ref on any other commit is not listed, though step 6 lists its name if it spells a needle) with its masked name (ref), its kind (ref, annotated tag or remote-tracking), the commit it reaches (old) and its new one (new), the id it holds now (lease, which for an annotated tag is the tag object), the needles its name or tag message still spells (carries) and those its tagger spells (tagger); and check, a history run over the rewritten commits and their ancestors. The rewrite never changes a file or name that is not UTF-8, a ref's name or tag message, a commit older than a --rev range, or an identity: it keeps every author, committer and tagger, so a needle in one is the expected residue, which check and tagger list apart from open hits and the report names per commit and tag for the repository's owner. Exit 0 means nothing is left in the rewritten commits and the refs on them, 4 that only that identity residue is, and 3 that something open is: a hit no decision fits goes back to step 4, where a rerun starts again from the unmoved refs and saves a new map file the later steps use instead, and a ref name or tag message in carries goes to the repository's owner at step 10. Exit 2 is a usage error or a refusal made before anything is written: a shallow clone, a move onto a path a past tree already holds, or a signed commit of the user's to sign again with user.signingkey unset or with a header signing would drop.
  9. Settle whether an identity is replaced before the refs move, and if so, rewrite it between step 10's local moves and its pushes. Replacing an author, committer or tagger is outside this skill's keep-authorship rule and is the repository's owner's call. If they want it, the route runs in this order, each part as below: the human saves the remote's URL and notes the leases; the refs move locally and each branch is checked to contain its remote (step 10); remote branches without a local one get one; the tool runs and its backup refs are deleted; history finds no identity left to replace; and only then are the refs pushed (step 10). First, the human saves the remote's URL to push to if the tool drops the remote, and notes the lease each push will take by step 10's rules, so a push made after the rewrite read the refs still refuses; a ref with no refs entry takes, for a branch, its remote-tracking ref's id and, for a tag, its own. After the local moves, they give a local branch to each remote branch that has none and either has a remote-tracking entry or reaches a commit the tool must change, at the new of its entry or, with no entry, at its remote-tracking ref, so the tool and the check below reach every commit a push sends. A remote branch reaches such a commit when history with the decision file and --rev refs/remotes/<remote>/<branch> lists an identity the repository's owner chose to replace. The repository's owner, or the human on their word, then runs a tool of their choice that rewrites authorship over the local branches and tags only, and any backup ref it leaves is deleted, since step 11 reads every ref. Before anything is pushed, history with the decision file and a --rev for each local branch and tag must list no identity the repository's owner chose to replace; one it still lists goes back to the tool. The tool records its old-to-new ids in its own form; converted to a JSON object whose keys are old full ids and whose values are new ones, they are a second map, a shape stale --map accepts besides rewrite's whole output.
  10. Hand the map to the ref move, and wait. The ref move works from the map file: its map for every commit and its refs for each ref to move. refs masks every needle a name spells as <label>, kept or open, so the real name of each entry whose ref shows one is read before the ref moves, from git for-each-ref --points-at <lease> among the refs of the entry's kind. That command lists every ref sharing the lease, such as another branch on the same commit or an outer tag around an inner one, and the entry's own is the one whose name matches its ref outside the masks. When the repository's owner wants an identity replaced (step 9), whichever route moves the refs stops after the local moves and pushes only once that rewrite has run. /re0-git takes the whole file in its ref steps, which the human runs: they plan the moves with rebuild.mjs refs --map <map file>, re-create each annotated tag, carry over commits pushed to the remote after the rewrite read the refs, and push each ref with a lease. Where it is not installed, the human moves each ref entry with git update-ref <ref> <new> <lease>, then runs a mixed git reset -q in each worktree that has that branch checked out, since update-ref leaves the old tree in its index, where the next commit would bring the needle back; the reset keeps the files. Each annotated tag entry is made again by piping git cat-file tag <lease>, its object line set to <new>, its type line to commit and any signature block after the message removed, to git mktag, which keeps the tagger, its date and the message, then moved with git update-ref <ref> <tag id> <lease>. A tag of a tag, whose lease is the outer tag, comes back pointing straight at <new>, without the inner one. Each branch is pushed with git push --force-with-lease=<ref>:<old> <remote> <branch>. <old> is the old of the branch's remote-tracking entry. A branch whose remote commit kept its id has no such entry, and takes <old> from git rev-parse refs/remotes/<remote>/<branch>. After the local moves and before any step 9 tool runs, every branch to be pushed, moved or not, is checked to contain what its remote holds, the new of its remote-tracking entry or else that remote-tracking ref (git merge-base --is-ancestor <that id> <branch>): a branch behind or apart from its remote would drop the remote's commits under the force push, so the human first brings a branch only behind up to it with git merge --ff-only <that id>. Each tag, lightweight or annotated, is pushed with --force-with-lease=<ref>:<lease>. A ref the remote does not hold is pushed without a lease. A refused lease means someone pushed after the rewrite read the refs. A branch apart from its remote and a refused lease both need someone else's commits carried onto rewritten ones, which the hand route has no command for, so the human stops that ref there, installs /re0-git and moves and pushes it with that skill's ref steps. A remote-tracking entry is never moved by hand: it holds what the remote had, and the push moves it. One with no local branch is pushed as git push --force-with-lease=refs/heads/<name>:<old> <remote> <new>:refs/heads/<name>, where <name> is its real name, read as above, past refs/remotes/<remote>/; on step 9's route it has a local branch by then and is pushed as that branch. A ref whose name or tag message still spells a needle is named for the repository's owner to rename or reword as it moves. The run waits here until the human says the refs have moved, and otherwise ends with the report and the map file.
  11. Check every ref, then list what still holds an old commit. Once the refs have moved and been pushed, run history again without --rev and with the decision file. It must exit 0 over every ref, or 4 when what it still lists is identity residue step 8 named and the repository's owner kept (step 9), and the report names anything it still lists. Under 3, a ref name or tag message goes to the repository's owner to rename or reword, and any other hit goes back to step 4. Then run node scripts/deid.mjs stale <root> --needles <file> --map <map file> [--write] [--json] with the rewrite's map, and again with step 9's second map if there is one. It lists every ref, worktree and reflog that still names a rewritten commit's old id, and every citation of one in the working tree, a full id or a prefix of seven or more hex digits. --write replaces each citation that names one commit with its new id at the same length, for the human to commit; an ambiguous one is listed for a hand fix. Exit 0 means nothing here holds an old id, 3 that something does. A moved ref's reflog still names its old id, so stale stays at 3 until the human expires the reflogs, which this run never does: that is the expected end. Report each holder, and that the old objects stay in this clone until its reflogs expire and git gc prunes them.

Rules

  • One artifact and one owner per run, both named by the human; the run never widens either.
  • A needle's value never reaches the output, and neither does a label, a keep reason, a path or a ref name that spells it, so a report copies a path or ref from the script's masked form. The output is what the run says or writes for someone else: its messages, the report, the artifact and commits. The agent's own reads and commands are its working, not output. The needle and decision files stay outside the artifact or under a gitignored local name, and the scripts never read them as part of the tree.
  • The owner's records are read, never written.
  • The working tree changes only through apply and past commits only through rewrite, both from the decision file; a hand edit goes back into that file so the next run replays it. stale --write changes nothing but old commit ids.
  • A replacement never borrows another real person's or company's data; it is a role noun or a value that is synthetic on its face.
  • A keep carries its reason. Already public means public by the owner's choice, never merely findable.
  • History is rewritten only on the repository owner's explicit approval (step 7), and the rewrite keeps every author, committer and date and signs again only the repository user's own commits that were signed. Moving and pushing refs, expiring reflogs, pruning, re-cloning and asking a host to purge are named in the report and never run.
  • A file that is not UTF-8 text is reported for a person to handle and never rewritten.
  • A pass that finds no needle changes nothing and says so.

Verification

Before finishing, confirm:

  1. scan with the decision file exits 0 on the working tree, or every hit it still lists sits in a file that is not UTF-8 text and the report names that file for the person; and the artifact's own tests and checks pass after apply.
  2. No needle value appears in the output (Rules): the report, drafted into a scratch folder outside the artifact, passes scan <that folder> --needles <file> --no-git with exit 0 before it is sent.
  3. Every keep in the decision file states its reason.
  4. The history result is reported. Without the repository's owner's approval, the report names their decision and no commit was rewritten. With it, every item rewrite left open went back to step 4 or is named for the repository's owner, and the map went to the ref move. Where the repository's owner had an identity replaced, history with the decision file and a --rev for each local branch and tag listed none of the identities they chose to replace before anything was pushed (step 9). Once the refs have moved, history over every ref with the decision file exits 0, or 4 only with identity residue the repository's owner kept, each identity named in the report per commit or tag. stale runs once per map, the rewrite's and step 9's second map if there is one, and each run exits 0 or the report names each holder (the moved refs' reflogs at least, until the human expires them), with the clones, forks and host that keep the old commits.
Files (paperthin)
  • agents
    • openai.yaml 186 B
      Loading…
  • scripts
    • deid.mjs 52.5 KB · in bundle
    • deid.test.mjs 51 KB · in bundle
  • SKILL.md 22.7 KB
    ---
    name: deid
    description: "Scrub a person's or organization's data from a shared repository or artifact when it may hold their data or is about to go public. Needles come from that owner's own records (names in every script, handles, emails, phone numbers, addresses, account and client ids); each hit becomes a role or placeholder that keeps the artifact working, and the past commits that still carry them are listed and rewritten on the repository owner's approval. Also use for a template, fixture set, docs or deliverable that may hold an operator's, a client's or a teammate's personal or business data, when someone asks to de-identify, anonymize, scrub or depersonalize an artifact, before open-sourcing a repository, or when a person's data must leave a codebase every operator runs or its history."
    ---
    
    Find one owner's data in a shared artifact with needles built from that owner's records, replace each hit with the role it plays, report which commits still carry it, and rewrite those commits once the repository's owner approves.
    
    ## Goal
    
    A shared artifact (a public repository, a template, a fixture set, a deliverable) holds nothing that belongs to one person or one organization, and still works: each leaked value is replaced by the role it plays or a placeholder that exercises the same code, or kept with a stated reason when it is already public. The working tree is changed only through a recorded decision file, so a rerun replays the same decisions. History is read first: the run lists where the repository's history carries a needle. Rewriting it is the repository owner's decision, and on their approval the same decision file rewrites the past commits into new ones. The run moves no ref: it hands over a map file of old and new ids, and whoever moves the refs works from it.
    
    The scope is what the human named: one artifact and one owner. The run never picks its own target or widens either.
    
    ## Workflow
    
    1. **Pin the artifact and the owner.** Name the folder or repository and the one person or organization whose data must leave it. If the human named neither, ask; if several owners are involved, run once per owner.
    2. **Build the needles from the owner's own records.** Read the records the human points to (identity and login files, profiles, business and payout settings, client lists, ledgers, message exports) read-only, and ask for them when none were named, and write a needle file: a JSON array of `{ "label": "...", "value": "...", "ci": true, "regex": true }` rows, `ci` and `regex` optional, every label unique and naming the kind of value (`client-phone`, `owner-name-ko`), never the value itself, since labels are printed. Spell each value every way it is written (a name in each script and order, a phone with and without separators and with the country code, an email in any case, an id with and without its prefix). A short or common word becomes a regex with boundaries, since the script refuses a plain needle under three characters. `\b` knows only ASCII letters, digits and the underscore, so a word in any other script (Hangul, kana, Cyrillic, a Latin word that starts or ends with an accented letter) is bounded by lookarounds on that script's letters, as `(?<![가-힣])길동(?![가-힣])` for a Korean given name; the script compiles no Unicode property escape such as `\p{L}` and refuses a needle that uses one. Keep the file outside the artifact or under a gitignored local name, and never print a value: every later step names a needle by its label.
    3. **List the hits.** From this skill's folder run `node scripts/deid.mjs scan <root> --needles <file> [--decisions <file>] [--no-git] [--json]`. Inside a git work tree it reads every file git does not ignore; `--no-git` reads every file under the root. It prints each hit as file, line, column and label, never the value; a needle in the file's name or a folder above it is a hit marked `(path)`, and every printed path shows a needle in it as `<label>`. Exit 0 means no hit, 3 hits, 2 a usage error or a broken needle file. Every file that is not UTF-8 text is listed whether or not it hits, its hits carry no line, and it is never rewritten: one that opens with a UTF-16 byte-order mark is read as UTF-16, and any other is searched byte for byte, so a needle written in another encoding (Hangul in a legacy Korean code page, UTF-16 with no mark) stays unseen in it. A listed file that could hold the owner's data is named in the report for a person to check.
    4. **Judge each hit and record the decision.** Read the hit in context to judge it, and quote neither the value nor the line around it back (Rules), then decide one of three things. A value already public by the owner's choice (the repository's own address, a published author credit, a public profile the artifact cites) is kept with its reason. A value in prose becomes the role it plays (the operator, the client, the company). A value in code, a test or a fixture becomes a placeholder of the same shape that still exercises the same branch: a reserved example domain for an email, an obviously synthetic number of the same length, a made-up name; check every assertion that reads it. Write a decision file, a JSON array of `{ "needle": "<label>", "replace": "..." }` or `{ "needle": "<label>", "keep": "<reason>" }` rows with optional `"paths": [globs]` matched against the path relative to the root the script was given (in `history` and `rewrite`, the repository's top folder), where `**` crosses folders, `*` and `?` stay inside one, and a glob with no wildcard also names a folder and everything under it. A row with paths decides only files under them; a row without decides every hit, history's messages, identities and refs included. The first row whose needle and paths fit a hit decides it, so put scoped rows before general ones. A needle in a path is decided like one in text: a replace moves the file to the path it gives, and since a link or import naming that path carries the same needle, a row without paths rewrites both alike. The script refuses a replacement that itself carries a needle. Keep this file beside the needle file.
    5. **State how serious the findings are, then apply on the human's go-ahead.** Before any change, tell the human what kind of data was found (identity, contact, credentials, client records, business figures, platform ids) and how much: for each kind, its hits and the files they sit in, as labels and counts only. The remedy they pick depends on it, so wait for their go-ahead, then run `node scripts/deid.mjs apply <root> --needles <file> --decisions <file> [--no-git] [--json]`, passing `--no-git` exactly when the scan did, since it decides which files are read. It rewrites only files whose text changes, moves a file whose path a decision changes (removing a folder the move empties, and refusing a move onto a path another file holds or one that empties a name), resolves overlapping needles to the earliest, then the longest, and leaves a hit no decision fits in place; exit 3 means hits are still open. Repeat steps 4 and 5 until `scan` with `--decisions` exits 0, or until every hit it still lists sits in a file that is not UTF-8 text, which no decision rewrites: the report names each such file for the person to re-export, edit or remove, and a scan after their change closes it. Then run the artifact's own tests and checks; a failure goes back into the decision file as a better placeholder, never into a hand edit.
    6. **Scan history read-only.** In a git repository run `node scripts/deid.mjs history <root> --needles <file> [--decisions <file>] [--rev <rev>]... [--json]`. It reads every ref in this clone, remote-tracking ones included, unless `--rev` names some, and changes nothing. In those refs it reads every past file (decoded as `scan` decodes it), every file path, every commit's message, author and committer, and every ref's name with an annotated tag's tagger and message. Per needle label it lists the commits that entered the needle into a file or a path, the commits whose message or identity carries it, the refs whose name or tag message carries it, and the annotated tags whose tagger does. A commit enters a needle into a file when that file holds more occurrences than the same path in every parent, and into a path when it adds a path that carries it; so a rename is listed under its new path, and an edit or merge that only carries the needle is not. Message and identity hits print the commit id only, and a needle inside a printed path or ref name prints as `<label>`. A keep decision hides the hits it fits; a replace decision hides none, since the past still holds the value. Exit 0 means history is clean, 3 that a past file, path, message or ref still carries a needle, 4 that only identities do (an author, a committer or a tagger), which no rewrite changes (step 8), and 2 a usage error or a folder outside git.
    7. **Report, and put the history to its owner.** Report the working tree result (files rewritten or moved, values kept and why, hits left open, files not UTF-8 text for a person to check) and the history result. When history carries a needle, put the rewrite to the repository's owner, the person who controls the repository and its host, who may not be the owner whose data it is. Tell them what it costs and ask whether to run it: every listed commit and each of its descendants, which carry the needle until a later commit removes it, get new ids; a rewritten commit someone else committed with a signature comes back unsigned, and so does every annotated tag on a rewritten commit, since each tag is made again; the rewrite keeps every author, committer and tagger line, so one that spells a needle stays until the repository's owner has it replaced outside this run (step 9); every ref on them moves and is force pushed; every other clone and fork keeps the old commits until it is re-cloned; and the host may keep serving them until its support purges them. Recreating the repository is the alternative. The human running the skill gives that approval only when they are that owner, and otherwise carries the question to them. Without the approval the run ends at this report.
    8. **Rewrite on the repository's owner's approval.** Run `node scripts/deid.mjs rewrite <root> --needles <file> --decisions <file> [--rev <rev>]... --json` and save its whole output as UTF-8 to a new file beside the decision file, never over the earlier map file. Exits 0, 3 and 4 print a map, and that new file becomes the map file the later steps use; exit 2 prints none, and the earlier one stays in use. It reads the refs `history` reads and applies the decision file to every past file, path and commit message in them as `apply` does to the working tree, leaving a file that is not UTF-8 text, and a path under a name that is not UTF-8, as they were. Each commit keeps its author, its committer, both dates and its other headers byte for byte, and one no needle reaches, directly or through a parent, keeps its id. A rewritten commit that carried a signature is signed again with `user.signingkey` when the repository's user (`user.email`) committed it, one `git commit-tree -S` call each, and otherwise comes back unsigned, since a signature would claim someone else's commit; the JSON counts those under `unsigned`. A commit that carried no signature stays unsigned, so a user who never signs needs no key, and with `user.email` unset every signed commit comes back unsigned. It writes new objects and moves no ref. Its JSON holds `map`, each old commit id to its new one in the shape re0-git's `rebuild.mjs` prints; `refs`, each ref on a rewritten commit (a ref on any other commit is not listed, though step 6 lists its name if it spells a needle) with its masked name (`ref`), its kind (`ref`, `annotated tag` or `remote-tracking`), the commit it reaches (`old`) and its new one (`new`), the id it holds now (`lease`, which for an annotated tag is the tag object), the needles its name or tag message still spells (`carries`) and those its tagger spells (`tagger`); and `check`, a `history` run over the rewritten commits and their ancestors. The rewrite never changes a file or name that is not UTF-8, a ref's name or tag message, a commit older than a `--rev` range, or an identity: it keeps every author, committer and tagger, so a needle in one is the expected residue, which `check` and `tagger` list apart from open hits and the report names per commit and tag for the repository's owner. Exit 0 means nothing is left in the rewritten commits and the refs on them, 4 that only that identity residue is, and 3 that something open is: a hit no decision fits goes back to step 4, where a rerun starts again from the unmoved refs and saves a new map file the later steps use instead, and a ref name or tag message in `carries` goes to the repository's owner at step 10. Exit 2 is a usage error or a refusal made before anything is written: a shallow clone, a move onto a path a past tree already holds, or a signed commit of the user's to sign again with `user.signingkey` unset or with a header signing would drop.
    9. **Settle whether an identity is replaced before the refs move, and if so, rewrite it between step 10's local moves and its pushes.** Replacing an author, committer or tagger is outside this skill's keep-authorship rule and is the repository's owner's call. If they want it, the route runs in this order, each part as below: the human saves the remote's URL and notes the leases; the refs move locally and each branch is checked to contain its remote (step 10); remote branches without a local one get one; the tool runs and its backup refs are deleted; `history` finds no identity left to replace; and only then are the refs pushed (step 10). First, the human saves the remote's URL to push to if the tool drops the remote, and notes the lease each push will take by step 10's rules, so a push made after the rewrite read the refs still refuses; a ref with no `refs` entry takes, for a branch, its remote-tracking ref's id and, for a tag, its own. After the local moves, they give a local branch to each remote branch that has none and either has a `remote-tracking` entry or reaches a commit the tool must change, at the `new` of its entry or, with no entry, at its remote-tracking ref, so the tool and the check below reach every commit a push sends. A remote branch reaches such a commit when `history` with the decision file and `--rev refs/remotes/<remote>/<branch>` lists an identity the repository's owner chose to replace. The repository's owner, or the human on their word, then runs a tool of their choice that rewrites authorship over the local branches and tags only, and any backup ref it leaves is deleted, since step 11 reads every ref. Before anything is pushed, `history` with the decision file and a `--rev` for each local branch and tag must list no identity the repository's owner chose to replace; one it still lists goes back to the tool. The tool records its old-to-new ids in its own form; converted to a JSON object whose keys are old full ids and whose values are new ones, they are a second map, a shape `stale --map` accepts besides `rewrite`'s whole output.
    10. **Hand the map to the ref move, and wait.** The ref move works from the map file: its `map` for every commit and its `refs` for each ref to move. `refs` masks every needle a name spells as `<label>`, kept or open, so the real name of each entry whose `ref` shows one is read before the ref moves, from `git for-each-ref --points-at <lease>` among the refs of the entry's kind. That command lists every ref sharing the lease, such as another branch on the same commit or an outer tag around an inner one, and the entry's own is the one whose name matches its `ref` outside the masks. When the repository's owner wants an identity replaced (step 9), whichever route moves the refs stops after the local moves and pushes only once that rewrite has run. `/re0-git` takes the whole file in its ref steps, which the human runs: they plan the moves with `rebuild.mjs refs --map <map file>`, re-create each annotated tag, carry over commits pushed to the remote after the rewrite read the refs, and push each ref with a lease. Where it is not installed, the human moves each `ref` entry with `git update-ref <ref> <new> <lease>`, then runs a mixed `git reset -q` in each worktree that has that branch checked out, since `update-ref` leaves the old tree in its index, where the next commit would bring the needle back; the reset keeps the files. Each `annotated tag` entry is made again by piping `git cat-file tag <lease>`, its `object` line set to `<new>`, its `type` line to `commit` and any signature block after the message removed, to `git mktag`, which keeps the tagger, its date and the message, then moved with `git update-ref <ref> <tag id> <lease>`. A tag of a tag, whose `lease` is the outer tag, comes back pointing straight at `<new>`, without the inner one. Each branch is pushed with `git push --force-with-lease=<ref>:<old> <remote> <branch>`. `<old>` is the `old` of the branch's `remote-tracking` entry. A branch whose remote commit kept its id has no such entry, and takes `<old>` from `git rev-parse refs/remotes/<remote>/<branch>`. After the local moves and before any step 9 tool runs, every branch to be pushed, moved or not, is checked to contain what its remote holds, the `new` of its `remote-tracking` entry or else that remote-tracking ref (`git merge-base --is-ancestor <that id> <branch>`): a branch behind or apart from its remote would drop the remote's commits under the force push, so the human first brings a branch only behind up to it with `git merge --ff-only <that id>`. Each tag, lightweight or annotated, is pushed with `--force-with-lease=<ref>:<lease>`. A ref the remote does not hold is pushed without a lease. A refused lease means someone pushed after the rewrite read the refs. A branch apart from its remote and a refused lease both need someone else's commits carried onto rewritten ones, which the hand route has no command for, so the human stops that ref there, installs `/re0-git` and moves and pushes it with that skill's ref steps. A `remote-tracking` entry is never moved by hand: it holds what the remote had, and the push moves it. One with no local branch is pushed as `git push --force-with-lease=refs/heads/<name>:<old> <remote> <new>:refs/heads/<name>`, where `<name>` is its real name, read as above, past `refs/remotes/<remote>/`; on step 9's route it has a local branch by then and is pushed as that branch. A ref whose name or tag message still spells a needle is named for the repository's owner to rename or reword as it moves. The run waits here until the human says the refs have moved, and otherwise ends with the report and the map file.
    11. **Check every ref, then list what still holds an old commit.** Once the refs have moved and been pushed, run `history` again without `--rev` and with the decision file. It must exit 0 over every ref, or 4 when what it still lists is identity residue step 8 named and the repository's owner kept (step 9), and the report names anything it still lists. Under 3, a ref name or tag message goes to the repository's owner to rename or reword, and any other hit goes back to step 4. Then run `node scripts/deid.mjs stale <root> --needles <file> --map <map file> [--write] [--json]` with the rewrite's map, and again with step 9's second map if there is one. It lists every ref, worktree and reflog that still names a rewritten commit's old id, and every citation of one in the working tree, a full id or a prefix of seven or more hex digits. `--write` replaces each citation that names one commit with its new id at the same length, for the human to commit; an ambiguous one is listed for a hand fix. Exit 0 means nothing here holds an old id, 3 that something does. A moved ref's reflog still names its old id, so `stale` stays at 3 until the human expires the reflogs, which this run never does: that is the expected end. Report each holder, and that the old objects stay in this clone until its reflogs expire and `git gc` prunes them.
    
    ## Rules
    
    - One artifact and one owner per run, both named by the human; the run never widens either.
    - A needle's value never reaches the output, and neither does a label, a keep reason, a path or a ref name that spells it, so a report copies a path or ref from the script's masked form. The output is what the run says or writes for someone else: its messages, the report, the artifact and commits. The agent's own reads and commands are its working, not output. The needle and decision files stay outside the artifact or under a gitignored local name, and the scripts never read them as part of the tree.
    - The owner's records are read, never written.
    - The working tree changes only through `apply` and past commits only through `rewrite`, both from the decision file; a hand edit goes back into that file so the next run replays it. `stale --write` changes nothing but old commit ids.
    - A replacement never borrows another real person's or company's data; it is a role noun or a value that is synthetic on its face.
    - A keep carries its reason. Already public means public by the owner's choice, never merely findable.
    - History is rewritten only on the repository owner's explicit approval (step 7), and the rewrite keeps every author, committer and date and signs again only the repository user's own commits that were signed. Moving and pushing refs, expiring reflogs, pruning, re-cloning and asking a host to purge are named in the report and never run.
    - A file that is not UTF-8 text is reported for a person to handle and never rewritten.
    - A pass that finds no needle changes nothing and says so.
    
    ## Verification
    
    Before finishing, confirm:
    
    1. `scan` with the decision file exits 0 on the working tree, or every hit it still lists sits in a file that is not UTF-8 text and the report names that file for the person; and the artifact's own tests and checks pass after `apply`.
    2. No needle value appears in the output (Rules): the report, drafted into a scratch folder outside the artifact, passes `scan <that folder> --needles <file> --no-git` with exit 0 before it is sent.
    3. Every keep in the decision file states its reason.
    4. The history result is reported. Without the repository's owner's approval, the report names their decision and no commit was rewritten. With it, every item `rewrite` left open went back to step 4 or is named for the repository's owner, and the map went to the ref move. Where the repository's owner had an identity replaced, `history` with the decision file and a `--rev` for each local branch and tag listed none of the identities they chose to replace before anything was pushed (step 9). Once the refs have moved, `history` over every ref with the decision file exits 0, or 4 only with identity residue the repository's owner kept, each identity named in the report per commit or tag. `stale` runs once per map, the rewrite's and step 9's second map if there is one, and each run exits 0 or the report names each holder (the moved refs' reflogs at least, until the human expires them), with the clones, forks and host that keep the old commits.
    

Comments

Sign in to join the conversation.

No comments yet. Start the conversation.

Reviews (0)

No reviews yet.