ClaudeMods
☰
EN
● — online · Views — times
SponsorsSubmit a project
Official examples · by anthropics

privacy

A built-in Claude Code mod that refuses shell, file, web fetch, or MCP calls carrying the signed-in account's email address beside a word declaring client identity, and restricts user-tier plugins from reading session identity.

Translated

About this mod

The privacy mod hooks tool.check to inspect Bash, PowerShell, Monitor, Write, Edit, NotebookEdit, WebFetch and mcp__* inputs. It refuses a call when the session's email address appears together with a client-identity marker such as a User-Agent word, an identity flag (set_identity, --identity, mailto=, SEC EDGAR site words), or a From header, and it also inspects the text of scripts named on the command line. The refusal is unconditional, ignores allow rules and classifier approvals, and instructs the model to use a generic client name or ask the person. Additionally, a session.identity hook denies user-tier plugin reads of the identity object while allowing builtin callers, and the mod can be disabled via /plugin disable, enabledPlugins, a server-side switch, or by a higher-priority plugin hook. It is explicitly a courtesy guard, not a security boundary, with documented false positives and bypasses.

Installation

Check the author's README for the marketplace and plugin name first. Commands may change as the repository evolves.

claude plugin marketplace add anthropics/claude-code
claude plugin install privacy@claude-code-plugins
Original text / README

privacy

The context hands the model the signed-in account's address to identify the user. This mod keeps that address from going out as a client's identity, and says who reads it through $.session.identity(). Its tool.check hook reads each tool as below. The address counts in any case or percent-encoded.

  • Bash, PowerShell, Monitor: the whole input, and the text of each script its command names outside a git or gh command, are refused if they hold the address and a word that declares who is calling. A line that only touches files reads none.
  • Write, Edit, NotebookEdit: what is being written, by the same test. Not the path. An Edit is refused only when new_string meets the test and old_string doesn't, since carrying over a line the file already holds adds nothing.
  • WebFetch: the address in url is refused with no second word, since the URL is what goes out.
  • mcp__*: the whole input, keys included, by the same test.

A word that declares who is calling is one of:

  • A User-Agent: USER_AGENT_WORD (User-Agent, user_agent, --user-agent, -UserAgent, a prefix of those flags, UA=) or CLIENT_FLAGS (curl -A, wget -U, and -User for PowerShell's web commands and Windows PowerShell's curl and wget aliases of them, with PowerShell's other dashes too, the en dash, em dash and horizontal bar).
  • IDENTITY_WORD: set_identity, identity= (so EDGAR_IDENTITY=), --identity, mailto=, and site words that catch an address given by position, as in Downloader("Acme", address): sec_edgar, edgartools, browse-edgar, from edgar import, import edgar and sec.gov. A bare edgar does not count, since a person's name or home folder can be one.
  • A From header: FROM_FLAG (-H "From: ..."), or FROM_KEY (a quoted "From" key) after the word headers, so a mail API's body passes.

COMPUTED_ADDRESS counts as the address beside any of these words on its own line: git config user.email in its usual spellings, unless it is given a value to set, $GIT_AUTHOR_EMAIL and $GIT_COMMITTER_EMAIL, and the names of the two variables that can hold the address in a cloud session, however the line reads them: CLAUDE_CODE_USER_EMAIL and CCR_SESSION_ACCOUNT_EMAIL. The address itself counts with a word anywhere in the text.

Scripts are found by a word match, not a parser: relative names with a script's extension, and ./name with no extension, up to MOST_SCRIPTS per line, one level only. This closes a script made any way and then run. Only the line a shell tool runs is searched, not a field such as description. A git command is taken out of it first: from a first word git, after any VAR=value assignments, to the next &, |, ; or newline, with whole quotes and a heredoc to its closing word. So neither git add fetch.py nor a multi-line commit message that names it is refused for what the script holds. A heredoc that isn't git's, such as bash <<EOF, stays searched. Any other spelling of git is read like any other line: "git", (git, env X=1 git, git.exe, NAME="Jo Smith" git add, and Tmux's send-keys git add fetch.py, which types keys rather than running a line. A gh command is taken out the same way, so a pull request body may name a script. The hook runs before any approval, so it follows no link that its walk sees: it walks each name's components from the working directory with $.fs.list, and reads a plain file only if none is a link. A link swapped in between by a process already writing the folder isn't covered. A file that cannot be read (missing, over 4 MiB, a network path) holds nothing, and the call goes on.

A line only touches files where every command starts with git or another of TOUCH_WORDS (gh, cat, sed, mv, chmod, linters, formatters, test runners, Get-Content), by git's own pattern, heredocs included, after plain VAR=value assignments and one python -m, uv run, npx or bunx. A bare word only, so not ./cat. A line isn't exempt if it holds a backtick, $( other than $(cat <<, <(, >(, @(, <<<, a separator on a heredoc's opening line, a quote or << in a comment, or in PowerShell a backslash right before ;, |, &, " or a newline. Any other line is read as above, so mv fetch.py g.py && python3 g.py is refused.

The refusal raises no prompt, whoever is there and whatever the permission mode. REFUSAL tells the model to use a generic client name, and to ask the person if a site needs a real contact. To send this address, the person sets it themselves in an environment variable the script reads, or runs the command themselves with !, which calls the shell tool with no permission check. A saved allow rule and auto mode's classifier do not clear the refusal. A deny beneath keeps its own reason.

The test is two word matches over the whole text. There is no parser, on purpose: it keeps the test simple. So a call that sets a User-Agent and sends the address elsewhere is refused, and so is one that only mentions a word beside the address (git log --author=<address> --grep=sec.gov), one that touches a script holding both on a line that isn't exempt (sudo rm fetch.py, python3 ok.py && cat fetch.py), a script with the address in an @author tag, curl on one line and grep -A on another, or real curl's -user (-u ser). Those false refusals are accepted for simplicity.

What passes

This is a courtesy against a well-meaning model, not a boundary. These pass, and leave the machine if the call sends them:

  • The address with no word beside it: a URL, a request body or curl -u on a shell line, an MCP field such as a calendar invite, or a file such as package metadata or an @author tag.
  • A positional address to a library with no identity word and no named site: Client("Acme", address), or a site named only by a bare edgar.
  • A quoted "From" key in a text that never says headers.
  • A value read while a script runs: settings.json, or $(cat contact.txt). A hook sees only the text it is given.
  • A run-time read on one line and the word on another: EMAIL=$(git config user.email), then curl -A "$EMAIL".
  • An Edit that carries over a line the file already holds with the address and a word.
  • A script reached by a link, by an absolute path or from outside the working directory, which goes unread. Write and Edit still catch the address and an identity word at write time.
  • A script that a touch command runs: a test runner (pytest fetch.py, bun test), a flag, variable or alias (rg --pre ./fetch.py, GH_PAGER=./fetch.py gh), zsh's =(...) or PowerShell's Get-Content (python fetch.py).
  • A script named only in a git or gh command, even one it runs: git bisect run ./fetch.py, git commit -m "$(python3 fetch.py)", or gh pr create --body "$(python3 fetch.py)".
  • A script that a git or touch command's stray quote or unclosed heredoc runs over, since an ambiguous spelling goes unread (git log --grep=don't, $'it\'s', <<EOF-1 or a lone carriage return, then ./fetch.py), or one on the opening line of git's or gh's heredoc.
  • A file reached through imports or make, or a name that is not read against the session's directory, such as after a cd, or written ~/x.py or $DIR/x.py, or one with a space or a non-ASCII letter.
  • A client not named here, or one that sets the header in another way, such as a PowerShell hashtable splatted with a User key.
  • Any encoding other than one pass of percent-encoding, and a non-ASCII address percent-encoded.
  • The address only in a WebFetch prompt. WebSearch, the browser tools and the local read tools are not checked.

The address is the one the context hands the model, read as contextEmail from $.session.identity(). Where the context hands none, it is email.

Who reads the identity

The engine answers $.session.identity() alike for every caller. This mod's hook on session.identity goes by the caller's tier:

  • user: refused. The call resolves with deny.
  • builtin: answered whole, this mod's own read included.
  • Any other: answered less contextEmail, pin or no pin. email, the pinned account's, is left as it is.

The field is left off that caller's own answer. A hook above this one still sees it on a built-in's read.

Where the hook fails, its .catch refuses.

By design, without sec-default a person's hook sits above this one and can see or answer the call, and with this mod off too a person's mod is answered. The address already reaches it at prompt.context. Under a pin, what it sees includes the organization's fields and the pinned email.

What turns it off

  • /plugin disable, or "cc-plugin-privacy@builtin": false under enabledPlugins in user, --settings or managed settings. A repository's settings do not.
  • A server-side switch, read once per session.
  • A hook of an installed plugin, which sits above this one: on tool.check it may overrule the refusal, and on session.identity it may answer in this mod's place or, from a managed tier, continue past it.
  • A session where no hooks module loads, where hooks/register.ts does not run.

Get a badge

Is this your project? Add this badge to your README or website. It links back to this page.

Featured on ClaudeMods
Size
Theme
Markdown
HTML

Similar projects