heinzel-email
Skill94 starsChanged 2 months agoMITView on GitHub
Send an email about a managed server — ad-hoc text
- Reads credentials
- Installs packages
In this repository5 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- heinzel-fleet-auditSkill
- heinzel-housekeepingSkill
- heinzel-macos-cleanupSkill
- heinzel-securitySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
25 rules. About 0 are common, 6 are distinctive, and 19 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈6
Distinctive · estimate
This author's own choices. Worth a look.
19
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
Onboarding pipeline: Run rules/first-connection.md in full.
- Distinctive: line 62
Never guess or invent a recipient.
- Very specific: line 64
Consent gate 0 — sender side (local vs remote): Check memory.md for Email source: local | remote:
- Very specific: line 72
Remote — always for this host: write Email source: remote into memory.md, then continue to 5R.
- Very specific: line 77
Local — always for this host: write Email source: local into memory.md, then jump to 5L.
- Very specific: line 125
5R.2 Consent gate A — existing MTA: If 5R.1 found a working MTA, check memory.md for Email send policy: <always|never>:
- Distinctive: line 138
If 5R.1 found a working MTA, skip 5R.3 entirely.
- Very specific: line 140
5R.3 Consent gate B — install a new MTA: Only reached when 5R.1 found nothing.
- Very specific: line 154
Before any install — whichever answer allowed it — run the mandatory service class conflict check from rules/service-class-check.md.
- Very specific: line 171
Before installing, surface the deliverability caveat: the server's IP probably has no PTR/SPF/DKIM, so mail to gmail-style providers will …
- Distinctive: line 198
If no non-root sender is viable, send as root and tag the report WARN with the reason.
- Very specific: line 277
Never write <Operator> (via heinzel), <Operator> via heinzel, or any phrasing that frames the operator as the author with Heinzel as a …
- Distinctive: line 284
Greeting: Before the signature, every outgoing message carries a fixed two-line human close, separated from the body above by one blank …
- Very specific: line 306
Signature: Every outgoing message ends with a fixed three-line signature block, separated from the greeting above by one blank line and …
- Distinctive: line 319
Keep it to these three lines.
- Very specific: line 342
If even $USER is empty, ask once via the picker and persist the answer.
- Very specific: line 349
Do not overwrite an Operator name: line that already exists.
- Very specific: line 408
If still nothing, omit the Reply-To header, tag the report WARN with the reason, and tell the user before sending — don't ship a Heinzel …
- Very specific: line 417
Do not overwrite an existing Reply-To: line.
- Very specific: line 419
Anti-auto-reply headers: Every Heinzel email is an automated status message about a managed server.
- Very specific: line 446
Do not make them per-host configurable.
- Distinctive: line 515
Verify delivery: Check the send command's exit code, then probe the appropriate mail log from the last minute:
- Very specific: line 526
Look for status=sent (or msmtp's delivery successful).
- Very specific: line 539
Update
memory.md: if anything new was learned (source chosen, transport discovered or installed, recipient added, policy set, sender … - Very specific: line 560
No new file. The skill reads and updates lines in the existing memory/servers/<host>/memory.md, extending the existing per-server memory …
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
heinzel-email
Send ad-hoc text and file attachments by email about a managed server. The report content is about the server; whether the mail leaves from the server or from your workstation is a per-host preference that's asked once and remembered.
The full heinzel first-connection onboarding pipeline still applies before any of this runs.
Workflow
- Onboarding pipeline. Run
rules/first-connection.mdin full. No "quick question" exception — even a one-line email still goes through blacklist/read-only check, DNS alias detection, SSH user lookup, OS detection, server memory load, and activity check. - Load overrides. Apply the heinzel rule-override chain
(later wins):
memory/custom-rules/heinzel-email.mdif present.memory/servers/<host>/memory.md(recipient, source, transport, policies — see "Per-server memory" below).memory/servers/<host>/rules.mdif present.memory/custom-rules/all.mdis already loaded by the session-start preflight — do not re-read it.
- Resolve recipient. In order of precedence:
- User said an explicit address ("send to alice@…", "mail it to bob@example.com") → use that. Don't override it with stored values.
- Per-server memory —
memory/servers/<host>/memory.mdhas anAlert email:line (the established pattern) → use that. - "Send me" shorthand ("email me", "send me", "mail it
to me") and the user's default email is recorded in
Claude Code's auto-memory (the
MEMORY.mdindex will show a "Default email" entry under User → load that file and use the address) → use it without prompting. Still write the address back to the per-servermemory.mdas- Alert email: <addr>on first use so the skill stays self-contained for future runs. - Otherwise, ask once via the picker, then persist to
memory.mdas in (3).
- Never guess or invent a recipient.
Consent gate 0 — sender side (local vs remote). Check
memory.mdforEmail source: local | remote:local→ jump to step 5L.remote→ continue with step 5R.- Missing → ask the user with four options:
"First-time email for
<host>. Send from where?"- Remote — once: send from the server this time, ask again next time.
- Remote — always for this host: write
Email source: remoteintomemory.md, then continue to 5R. - Local — once: send from this workstation this time, ask again next time.
- Local — always for this host: write
Email source: localintomemory.md, then jump to 5L.
Why this gate exists: some hosts have great mail infrastructure (e.g. a working local Postfix relaying to an external smarthost); others have none and the user may prefer not to install anything on them. Either side is a perfectly valid choice the user should be able to lock in once.
5L. Local-side workflow
5L.1 Probe the workstation for a local transport:
command -v mail || command -v mailx || command -v sendmail
|| command -v msmtp. On macOS, also confirm Postfix is
loaded: launchctl print system/com.apple.postfix.master
exits 0.
5L.2 No install fallback locally. If nothing's there,
refuse cleanly: "no mail tooling on this workstation —
install msmtp locally and rerun, or pick remote next time by
deleting Email source: local from memory.md." Do not
auto-install on the workstation.
5L.3 Skip Gate A (5R.2) and Gate B (5R.3) entirely — those are remote-only.
5L.4 Skip the sender-identity step (5R.4). Local sending runs as the current shell user.
5L.5 Continue at the shared step 6 (Compose). At step 7 (Send) the command runs locally. At step 8 (Verify) inspect local logs:
- macOS:
log show --style compact --last 1m --predicate 'process == "smtpd" OR process == "smtp"' - Linux workstation:
journalctl --since "1 minute ago" -t postfixortail -50 /var/log/mail.log
5R. Remote-side workflow
5R.1 Resolve transport — probe in this order on the remote host:
command -v mail || command -v mailx || command -v s-nailcommand -v sendmailcommand -v msmtpsystemctl is-active postfix opensmtpd exim4(any active)
5R.2 Consent gate A — existing MTA. If 5R.1 found a
working MTA, check memory.md for Email send policy:
<always|never>:
always→ proceed silently.never→ refuse with the reason; do not send.- missing → ask:
"Use the MTA already on
<host>(<detected tool>)?"- Once — send this time, ask again next time.
- Always (recommended) — write
Email send policy: alwaysintomemory.md, send. - Never — write
Email send policy: neverintomemory.md, abort.
If 5R.1 found a working MTA, skip 5R.3 entirely.
5R.3 Consent gate B — install a new MTA. Only reached
when 5R.1 found nothing. Check memory.md for MTA install
policy: <always|never>:
always→ install silently using the OS-family default below.never→ refuse; do not install, do not send.- missing → ask:
"No MTA found on
<host>. Install one?"- Once — install this time, ask again next time.
- Always — write
MTA install policy: alwaysintomemory.md, install. - Never — write
MTA install policy: neverintomemory.md, abort.
Before any install — whichever answer allowed it — run the
mandatory service class conflict check from
rules/service-class-check.md. An MTA is a service class:
the check can find a member the 5R.1 transport probe missed
(e.g. an installed-but-stopped postfix), and a second MTA
must never be added without explicit user approval.
Install targets (OS-family defaults):
- Debian/Ubuntu:
apt-get install -y msmtp-mta bsd-mailx - RHEL/Fedora:
dnf install -y msmtp s-nail - SUSE:
zypper install -y msmtp s-nail - FreeBSD:
pkg install -y msmtp(mail(1)is in base) - macOS as a managed target: do not install. Use
/usr/bin/mailif a working Postfix is already configured; otherwise refuse cleanly and explain (residential macOS rarely sends).
Before installing, surface the deliverability caveat: the
server's IP probably has no PTR/SPF/DKIM, so mail to
gmail-style providers will likely be filtered. Recommend a
smarthost relay (msmtp config) if the user has one. If a
smarthost is configured during install, follow
rules/backups.md (back up /etc/msmtprc before edits) and
store credentials with 0600 root:root.
5R.4 Pick the sender identity — least privilege. Sending mail almost never needs root. Choose the UID for the send, in this order:
- Current SSH user is non-root → use that user.
- Current SSH user is root (common on hosts that allow only
root SSH with no usable sudo, or after privileged earlier
work in the session):
- First check
memory.mdfor anEmail sender:line — if present, use it without re-probing. - Otherwise read
memory/user.mdfor the preferred username. id <user>to verify the account exists on the host.su - <user> -c 'command -v <transport>'to verify the account can invoke the chosen transport. If group perms on/etc/msmtprcblock it, fall to case 3.- Drop privileges for the send only:
runuser -u <user> -- sh -c '…'(Linux util-linux) orsu - <user> -c '…'(portable, FreeBSD).
- First check
- If no non-root sender is viable, send as root and tag the report WARN with the reason. Never invent a user.
The install step (5R.3) still requires root/sudo — that is the only root-privileged operation in the workflow.
Shared steps (both 5L and 5R converge here)
Compose.
- Default subject:
[heinzel/<short-hostname>] <topic>— even on the local-side path, the subject names the server the report is about. - Body: plain text, in this order and nothing else — one line naming what ran and on which host, the report or the user's content verbatim, then the Heinzel closing (see Greeting and Signature below). If the user asks to send command output, run the command and embed stdout/stderr inline in a fenced block in place of the report.
- Ceiling: 5 lines of your own text around that block,
per "Talking to Humans" in
CLAUDE.md. No cover sentence, no restatement of the subject, no "as requested", no recap under the report. A report goes in exactly as its skill produced it — nothing added before or after it. Attachments get one line each: name and size, not a description of the contents.
Attachments (e.g. "email me /var/log/auth.log"):
a. Per file,
statthe path on the side that holds it (remote when the path lives on the server; local otherwise). Refuse if it doesn't exist; never invent paths. b. Readability check. Confirm the chosen sender UID (5R.4 result on the remote path, current shell user on the local path) can read it:[ -r path ]under that UID. If not, do not silently escalate. Show the perms (ls -l) and ask:- skip the file (default offered);
- copy via root to a temp file
0600 <sender>:<sender>the sender can read, then clean up after send; - send as root with a WARN.
c. Size check. If the file is over 10 MB, show the
size and Gmail's 25 MB cap, then ask: send as-is, gzip
first (recommended for text logs), or skip.
d. Sensitive-content nudge. Log files often contain
secrets, IPs, hostnames, internal email addresses.
Show the file's
head -5and ask "ok to attach?" before proceeding. The user can override globally for the session by saying "skip the log preview" — do not persist that override to memory.
Likely-secret files are default-refuse. For
.env,id_*,*_key,*.pemwith private key material,shadow,msmtprc,.netrc, cloud credential files, or anything under/etc/ssl/private/: warn explicitly and attach only on an explicit per-file override. Never show their content as a preview — the preview itself would leak. Preview withls -l+fileinstead. Seerules/secrets.md. The session-wide "skip the log preview" override does NOT apply to these files. e. Multiple attachments: repeat a–d per file. Hard cap of 5 attachments per message in v1; refuse the 6th and suggest splitting the mail.Voice. Heinzel, not the operator, is the apparent author of every outgoing message. Body text — including any casual sign-off the user asks for above the fixed greeting — must speak in Heinzel's voice on the operator's behalf. If a closing line precedes the greeting (e.g. "Have a good week,"), attribute it to Heinzel acting for the operator, like:
Have a good week, Heinzel (for <Operator name>)Never write
<Operator> (via heinzel),<Operator> via heinzel, or any phrasing that frames the operator as the author with Heinzel as a delivery channel. The persona is "Heinzel for<Operator>", not "<Operator>via Heinzel". Same applies to the subject and any inline narration.Greeting. Before the signature, every outgoing message carries a fixed two-line human close, separated from the body above by one blank line and from the signature below by another blank line:
Viele Grüße HeinzelHeinzel is the author of the closing — not the operator. The operator attribution lives in the signature block below. Keep the greeting fixed across languages; the subject and body may be English, the "Viele Grüße / Heinzel" close stays the tool's voice. Users who want a different wording can set a
Greeting:line inmemory/user.md(global) ormemory/servers/<host>/memory.md(per-host); if present, it replaces both lines verbatim (multi-line allowed). Per-send instructions ("use 'Mit freundlichen Grüßen' this time") always win over memory.Signature. Every outgoing message ends with a fixed three-line signature block, separated from the greeting above by one blank line and opened by the RFC 3676 delimiter
"-- "(two hyphens, one space, then newline — most MUAs collapse the sig visually only when the delimiter is exact):-- Sent by Heinzel on behalf of <Operator name> https://github.com/wintermeyer/heinzelKeep it to these three lines. No timestamp, no hostname, no extra attribution — the subject already names the host. Plain text only; no HTML.
Resolve
<Operator name>in this order, stop at the first hit. Never fabricate a name from a short handle likerootoradmin:Operator name:line inmemory/servers/<host>/memory.md(per-host override, rare).Operator name:line inmemory/user.md(global, canonical).- Claude Code auto-memory — the
user_profile.mdfile referenced fromMEMORY.md. Take the human name from its front-mattername:field (strip any suffix like— user profile). This is the same auto-memory channel step 3 uses for the default email. git config --global user.nameon the workstation.- GECOS full name:
getent passwd "$USER" | cut -d: -f5 | cut -d, -f1on Linux,id -Fon macOS/BSD. $USERas a last resort.- If even
$USERis empty, ask once via the picker and persist the answer.
Persist on first resolution via 3/4/5/6 — write
Operator name: <name>intomemory/user.mdunder the existing# Preferencessection so the next run skips the probes and the user can edit the canonical value. Do not overwrite anOperator name:line that already exists; user edits win.From header. Heinzel mail is machine-generated. Set
From: noreply@<sending-host-fqdn>so recipients see at a glance that the mailbox is not monitored:- Remote path:
<sending-host-fqdn>is the per-server hostname (the directory name undermemory/servers/<host>/). - Local path:
<sending-host-fqdn>is the workstation's FQDN (hostname -f, fall back tohostname).
The
noreply@…mailbox does not need to exist on the host. Real bounces follow the envelope sender (the submitter UID picked in 5R.4, or the current shell user on the local path) — that is always a real account that can receive MAILER-DAEMON notices. The From header is purely visual, for the recipient's MUA.A host can pin a different From mailbox by adding a
From:line to itsmemory.md(rare — only useful when a host needs a non-noreply@identity such asalerts@<host>).Reply-To header. Because the From mailbox is unread, every Heinzel message MUST carry a
Reply-To:pointing at the human operator, so recipients hitting "Reply" land in a real inbox.The operator email is the address of the human using Heinzel — the same person logged into Claude Code right now. It is never an account on the managed server: no
root@<host>, no<ssh-user>@<host>, no alias derived from/etc/aliasesor~/.forwardon the target. Do not probegetent passwd,id, or any mail metadata on the managed host to resolve it. Replies must land in the operator's real inbox, not on the server they were asking Heinzel to work on.Resolve
<operator email>in this order, stop at the first hit. Never fabricate an email from a short handle likerootoradmin, and never derive it from a managed host:Reply-To:line inmemory/servers/<host>/memory.md(per-host override, rare — e.g. a different operator fields replies for one specific host; still must be a real off-server inbox).Reply-To:line inmemory/user.md(global, canonical).- Claude Code auto-memory — the "Default email"
entry under User in
MEMORY.md. Load the linked file and use the address. Same channel step 3 of "Resolve recipient" uses. git config --global user.emailon the workstation.- If still nothing, omit the Reply-To header, tag the report WARN with the reason, and tell the user before sending — don't ship a Heinzel mail with no working reply path silently.
Persist on first resolution via 3/4 — write
Reply-To: <addr>intomemory/user.mdunder the# Preferencessection so the next run skips the probes and the user can edit the canonical value. Do not overwrite an existingReply-To:line.Anti-auto-reply headers. Every Heinzel email is an automated status message about a managed server. It should never fan out out-of-office or vacation replies back at the operator. To that end, every outgoing message carries this fixed header triple, regardless of path or attachments:
Auto-Submitted: auto-generated Precedence: bulk X-Auto-Response-Suppress: OOF, AutoReplyAuto-Submitted: auto-generatedis the RFC 3834 signal. Standards-compliant auto-responders (vacation(1), Sievevacation, recent postfix, well-behaved providers) MUST NOT reply to a message that carries it.Precedence: bulkis the older sendmail convention, still honoured by many legacy responders.X-Auto-Response-Suppress: OOF, AutoReplyis the Microsoft Exchange / Outlook-specific knob that suppresses OOF replies and "I'm out of the office" auto-responses when the recipient uses Exchange.
Together the three cover RFC-compliant systems, legacy Unix responders, and the Exchange-flavoured world. Do not make them per-host configurable; there is no realistic Heinzel message that should be treated as a normal human email by an auto-responder.
- Default subject:
Send. Because Heinzel always injects custom headers (the anti-auto-reply triple above, plus MIME headers when attaching), the canonical send path builds the full RFC 822 message and pipes it to a sendmail-style agent that reads headers from stdin (
-tmode). This is uniform across Postfix, msmtp-mta, exim, opensmtpd, and macOS Postfix — they all expose/usr/sbin/sendmailwith compatible-tsemantics.The composed message always has this shape (headers, blank line, body + greeting + signature):
From: noreply@<sending-host-fqdn> Reply-To: <operator email> To: <recipient> Subject: <subject> Auto-Submitted: auto-generated Precedence: bulk X-Auto-Response-Suppress: OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 <body> <greeting> -- <signature>From:andReply-To:are resolved per the rules above. IfReply-To:could not be resolved (case 5), omit the line entirely after warning the user.No attachments. Pipe the message to
sendmail -t -oi(-oiprevents a lone.on a line from ending input). Prefer the MTA-provided/usr/sbin/sendmail; fall back tomsmtp -twhen only msmtp is present.With attachments, build a MIME multipart message by hand —
text/plainbody plus parts that aretext/plainfortext/*MIME types (detected viafile --mime-type) and base64-encodedapplication/octet-streamotherwise. Heinzel constructs the headers (including the anti-auto-reply triple) and the boundary itself, then pipes intosendmail -t -oi(ormsmtp -twhen only msmtp is present). This replaces the earlier tool-specific shell-outs tomuttandmail -a: a single code path means headers are guaranteed to survive every send.macOS local path.
/usr/bin/sendmailon macOS is a Postfix compatibility shim and accepts the same-tinvocation, so the same composed message pipes through without change./usr/bin/mailis not used for the send itself anymore; we only consulted it during the 5L.1 probe to confirm a working local MTA exists.Remote path: run under the user chosen in 5R.4, via
runuser -u <user> -- sh -c '…'orsu - <user> -c '…'. Local path: under the current shell user.Verify delivery. Check the send command's exit code, then probe the appropriate mail log from the last minute:
- Linux remote:
journalctl -u postfix --since "1 minute ago" | tail -20(substitute the active MTA unit), ortail -50 /var/log/mail.log(Debian) //var/log/maillog(RHEL/FreeBSD). - macOS local:
log show --style compact --last 1m --predicate 'process == "smtpd" OR process == "smtp"'. - Linux workstation local:
journalctl --since "1 minute ago" -t postfixor/var/log/mail.log.
Look for
status=sent(or msmtp'sdelivery successful). Flagdeferred/bouncedas CRITICAL and report verbatim instead of claiming success. Never call a send successful on the basis of the command's exit code alone.On the remote path, confirm the log line's
from=<…>matches the chosen sender user (not root, unless 5R.4 fell to case 3). This is the envelope sender (the Return-Path), which always reflects the submitter UID; the visibleFrom:header isnoreply@…and is independent — do not flag the mismatch as a problem.- Linux remote:
- Update
memory.mdif anything new was learned (source chosen, transport discovered or installed, recipient added, policy set, sender identity confirmed, per-host operator override requested). Use the shape under "Per-server memory" below. Only write…alwaysor…neverlines when the user explicitly picked them; absence means "ask next time". The globalOperator nameis persisted tomemory/user.md, not to per-server memory — write a per-hostOperator name:line only when the user asks for a different signer on that specific host. Log to changelog per
rules/changelog.md:logger -t heinzel "Email to <recipient> from \ <local|remote/<user>>: <subject>"
Per-server memory
No new file. The skill reads and updates lines in the
existing memory/servers/<host>/memory.md, extending the
existing per-server memory format. Policy lines are only
written once the user picks Always or Never;
absence means "ask next time".
- Mail: <transport summary> # remote path only
# e.g. "postfix + bsd-mailx
# (outbound via Google MX)"
# or "msmtp via smtp.fastmail.com:587"
- Alert email: <recipient address>
- Email source: local | remote # gate 0 — sender side
- Email sender: <username> # remote path only — non-root user
- Email send policy: always | never # gate A — use existing remote MTA
- MTA install policy: always | never # gate B — install a new remote MTA
- Operator name: <full name> # per-host override for signature
# (global default in memory/user.md)
- Greeting: <closing text> # per-host override for the greeting
# (global default in memory/user.md;
# absent = "Viele Grüße / Heinzel")
- From: <mailbox> # per-host From override
# (default: noreply@<host>)
- Reply-To: <addr> # per-host Reply-To override
# (global default in memory/user.md)The two policy lines are deliberately separate: a user may
be happy to use a mature postfix that's already there
("send: always") but want to be asked every time before
heinzel installs new packages on a different server
("install: ask" = line absent). Mirrors the shape of
memory/service-policy.md's split between restart-auto
and restart-never.
References (read on demand)
rules/first-connection.md— the mandatory onboarding pipeline.rules/server-memory.md— server memory file format.rules/changelog.md— session logging procedure.rules/best-practices.md— anti-pattern review before installing software.rules/service-class-check.md— mandatory conflict check before installing an MTA (gate B).rules/backups.md— config backup before any edit (e.g./etc/msmtprc).rules/secrets.md— secrets hygiene; default-refuse attachment gate for likely-secret files.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

