/qfs:qfs-gmailfrom qfs
Use when a task needs to read or triage Gmail through qfs — search, read, summarize, draft, send, relabel, or trash mail via the /mail path and its pipe-SQL queries. Covers connecting a Google account and the label, message, thread, attachment, and draft surface.
Ships in qfs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Your whole mailbox becomes a set of queryable paths. Labels are directories, messages are files, and one pipe-SQL language searches, triages, drafts, sends, relabels, and cleans up — the same verbs you already use on a database, a git repo, or a folder of files.
Show me the mail that actually needs me — unread, this quarter, from a real human (not a
noreply robot), newest first:
/mail/unread
|> where date > '2026-04-01'
AND NOT from LIKE '%noreply%'
|> select date, from, subject
|> order by date DESC
|> limit 20
date from subject
2026-06-30 [email protected] Re: Q3 renewal — a couple of questions
2026-06-29 [email protected] Contract redlines attached
2026-06-27 [email protected] Can we move the review to Thursday?
… 20 rows
That read runs the instant you connect an account. Now the smart part — star and mark-read a
message you found (a Gmail write acts on an exact message id; find it with a select first),
and it previews before it touches anything:
update /mail/inbox
set add_labels = 'STARRED', remove_labels = 'UNREAD'
where id == '18f2a9c1b7'
PREVIEW: 1 effect(s)
#0 UPDATE -> mail:/mail/inbox [affected 1]
total affected: 1
::: tip Reads run now; writes preview
Every read returns rows immediately. Every write (update, insert, remove, call)
previews by default and changes nothing — add --commit to apply it, --commit-irreversible for
the ones that can't be undone (sending, trashing). Paste any recipe below and safely watch what it
would do first.
:::
Gmail isn't reachable until you connect a Google account to a path — about five minutes, once, in Setup. After that every recipe on this page works verbatim.
::: tip Prerequisites — an operator, an account, a mount
Reaching a cloud service takes three one-time steps: a signed-in operator (qfs init —
The operator identity), an authorized account (qfs account add …), and a
mount binding that account to a path (qfs connect …). The happy path below is exactly those
three, plus registering your OAuth app.
:::
You connect Gmail once. The happy path is four commands:
qfs init [email protected] # 1. the operator + the vault
cat credentials.json | qfs app add google qmu # 2. your OAuth app
qfs account add google --app qmu # 3. authorize (paste-back consent)
qfs connect /mail --driver gmail --account [email protected] # 4. mount it at /mail
The rest of this section explains each line and the alternatives.
client_id + client_secret), downloaded from the
Google Cloud console as credentials.json,
with the Gmail API enabled for the project.Cloud drivers require a signed-in operator — qfs fails closed for an anonymous one. qfs init
creates the encrypted credential store (where the refresh token is sealed at rest — see
The QFS passphrase) and registers you as this machine's operator. There is
no password: your OS login is the authentication, and the email is an accountability label.
Re-running it is safe — it reports what already exists:
qfs init [email protected]
Register the downloaded credentials.json in qfs's own encrypted store, so it no longer depends on
a file on disk:
cat credentials.json | qfs app add google qmu
CI and agents can instead export QFS_GOOGLE_CLIENT_ID and QFS_GOOGLE_CLIENT_SECRET.
Pick one path. Either way, one authorization can serve Gmail, Google Drive, and Google Analytics — the account is stored once, under your email as its label and the chosen app label.
A — Fresh browser consent (recommended). On a terminal, one command prints a Google consent
URL. Open it in your local browser (press c to copy it to your local clipboard — this works
across SSH and tmux), approve, and your browser lands on a http://localhost/... URL that fails
to load — that's expected: nothing listens there. Paste that entire URL (or just its code=
value) back into the terminal, and qfs seals the refresh token and records your consent. Because
the redirect never needs to reach the qfs host, this works the same on your laptop or over plain
SSH — no port-forward:
qfs account add google --app qmu
B — Pipe an existing refresh token (reuse one a prior tool already obtained, or automate on a headless box with no browser). The token comes in on stdin, never argv, and the email is the account's label:
printf '%s' "$REFRESH_TOKEN" | qfs account add google [email protected] --app qmu
qfs account list shows the authorized accounts; qfs account remove google [email protected] deletes
one along with its consent record.
Mount Gmail wherever you like — the mount carries the account, and the rest of this cookbook
assumes /mail:
qfs connect /mail --driver gmail --account [email protected]
qfs connect --list now lists it, and qfs describe /mail shows the schema and verbs.
qfs disconnect /mail removes the mount.
::: info The mount path is yours — and so is the account it carries
/work/gmail works just as well as /mail — mount with
qfs connect /work/gmail --driver gmail --account [email protected] and every /mail/… recipe below
simply becomes /work/gmail/…. Two Gmail accounts are simply two mounts in the same process:
qfs connect /mail --driver gmail --account [email protected]
qfs connect /mail2 --driver gmail --account [email protected]
:::
qfs run "/mail/inbox |> select date, from, subject |> limit 5"
Real messages come back. If a read reports connect a Google account to read mail, revisit steps 1–3: the path resolved (you're past addressing), but the cloud bind gate has no signed-in operator or recorded consent yet.
Once connected, /mail is your Gmail account as an append log mapped onto a filesystem shape:
| Gmail thing | qfs path | it is a… |
|---|---|---|
| a label | /mail/inbox, /mail/sent, /mail/<UserLabel> | directory of messages |
| a message | /mail/inbox/<msg-id> or id:<msg-id> | file |
| a thread | id:thread:<thread-id> | file (the whole conversation) |
| an attachment | /mail/inbox/<msg-id>/<att-id> | nested entry |
| your drafts | /mail/drafts | the append target you write new mail to |
Message columns: id, thread_id, date, from, subject, snippet, label_ids,
attachments. Attachment columns: filename, mime, size. You address an attachment by its
position — att0 is the first, att1 the second (Gmail's internal attachment id is ephemeral,
so qfs addresses by the stable index; see below). Run qfs describe /mail/inbox for the exact schema
and verbs of any node.
::: tip Labels are written verbatim
A label segment reaches Gmail exactly as you write it — qfs never rewrites the case. It becomes a
label: search term, which Gmail matches case-insensitively, so lowercase just works: sent,
spam, trash, starred, important, unread, the category_* tabs, and your own user labels
all read the same way. drafts is qfs's reserved write collection (the INSERT target), not a label.
:::
List your labels — the directories under /mail:
/mail |> select name
Read any label — the system ones (inbox, sent, starred, important, spam, unread) and
your own (e.g. /mail/Receipts):
/mail/inbox |> select date, from, subject |> limit 20
/mail/sent |> select date, subject |> limit 20
/mail/starred |> select date, from, subject
WHERE and LIMIT push down into Gmail's own search — qfs turns the predicate into a Gmail q
query and re-filters locally only the parts Gmail can't express exactly.
Find invoices, newest first:
/mail/inbox
|> where subject LIKE '%invoice%'
|> select date, from, subject
|> order by date DESC
|> limit 20
Everything from one sender:
/mail/inbox
|> where from == '[email protected]'
|> select date, subject, snippet
A date range, with the attachments column:
/mail/inbox
|> where date BETWEEN '2026-01-01' AND '2026-03-31'
|> select date, from, subject, attachments
Unread from the last quarter, across the whole mailbox:
/mail/unread
|> where date > '2026-04-01'
|> select date, from, subject
|> order by date DESC
A single message as a file under its label — the message id is the last segment (a listing's
id and thread_id columns give you the ids):
/mail/inbox/18f1a2b3c4
|> select date, from, subject, snippet
List a message's attachments — they come back in order, so the first is att0, the second
att1. Then download one by that index: the attachment node /mail/<label>/<msg-id>/att<N>
reads filename, mime, size, and the decoded content bytes:
/mail/inbox/18f1a2b3c4
|> select attachments
/mail/inbox/18f1a2b3c4/att0
|> select filename, mime, size, content
Addressing by index (not the raw Gmail attachment id) is deliberate: the id is ephemeral — regenerated on every read — so qfs resolves the live id for you inside the read. That is what lets a one-statement transfer work, e.g. save the first attachment straight into a Drive folder:
/mail/inbox/18f1a2b3c4/att0
|> select filename as name, mime as mime_type, content as bytes
|> insert into /drive/my/Reports
Who emails you most?
/mail/inbox
|> group by from
|> aggregate count(id) as messages
|> order by messages DESC
|> limit 10
Relabeling is an UPDATE that names an exact message — Gmail writes act on a specific message
id, not a fuzzy search (Gmail's search is lossy, so a set-wide write could touch the wrong mail).
The triage flow is read to find, then act by id: select id, from, subject … to find the
message, then update it. set add_labels / remove_labels (comma-separated label ids) picks what
to add and remove; it previews like any effect and only applies on --commit.
You can name the message two equivalent ways — by the collection with an exact where id ==, or by
its message node /mail/inbox/<id>:
Star and mark-read one message:
update /mail/inbox
set add_labels = 'STARRED', remove_labels = 'UNREAD'
where id == '18f2a9c1b7'
Archive a message — archiving is just removing the INBOX label; the message stays in All
Mail. Here by its message node:
update /mail/inbox/18f2a9c1b7
set remove_labels = 'INBOX'
File a receipt under a user label:
update /mail/inbox
set add_labels = 'Receipts'
where id == '18f2a9c1b7'
Create a new label first. Labels are the mailbox's directories, so making one is an INSERT
into the /mail/labels collection — a nested Parent/Child name creates the hierarchy. It previews
like any write and only applies on --commit:
insert into /mail/labels
values ('Work/Receipts')
Draft an email — reversible; creating a draft sends nothing. It previews until you --commit.
Name the columns you write (to, subject, body): drafts are an append target whose read shape
(message rows) differs from its compose fields, so a bare positional values ('a','b','c') is
rejected — name them so to is unambiguous:
insert into /mail/drafts
values (to, subject, body)
('[email protected]', 'Q3 report', 'See attached.')
PREVIEW: 1 effect(s)
#0 INSERT -> mail:/mail/drafts [affected 1]
total affected: 1
Draft with an attachment. The attachments column is an array of structs, each
{ filename, mime, bytes }. Give bytes a hex X'…' literal (or a plain string for text), and name
the columns so the array lands in attachments:
insert into /mail/drafts
values (to, subject, body, attachments)
('[email protected]', 'Q3 report', 'See attached.',
[ { filename: 'hello.txt', mime: 'text/plain', bytes: X'68656c6c6f' } ])
The draft is built as a multipart/mixed message with the file attached — still a reversible preview
until you --commit. Piping a Google Drive download straight into this column (instead of an
inline literal) is the cross-service attach-and-send recipe.
Draft, then send it. The draft is reversible; the send is the irreversible step. Create the
draft, read /mail/drafts to find its draft id (the id column), then send that draft by
addressing it — /mail/drafts/<draft-id> |> call mail.send:
insert into /mail/drafts
values (to, subject, body)
('[email protected]', 'Q3 report', 'See attached.')
/mail/drafts |> select id, subject
/mail/drafts/r8a1f2c4 |> call mail.send
Prefer a one-shot? Compose and send in a single step by passing the recipients to the call — no draft to look up first:
/mail/drafts |> call mail.send(to => '[email protected]', subject => 'Q3 report', body => 'See below.')
::: warning Irreversible
CALL mail.send can't be undone. In a one-shot it needs --commit --commit-irreversible. A retry
re-sends the same draft (de-duplicated by draft id), never a fresh message. A bare
/mail/drafts |> call mail.send with no addressed draft and no recipients is refused at plan time —
address a draft or pass to.
:::
Reply into a thread. To answer an email in its conversation (not as a new standalone message),
address the parent message and call mail.reply. It builds a reversible reply draft that
lands in the parent's thread — the to defaults to the parent's sender and the subject to
Re: <their subject>, so the shortest reply is just a body:
/mail/inbox/18f2a9c1b7 |> call mail.reply(body => 'Thanks — Thursday works. See you then.')
PREVIEW: 1 effect(s)
#0 CALL -> mail:id:18f2a9c1b7 [affected 1]
total affected: 1
Override any default — reply to a different address, add a cc, or set your own subject:
/mail/inbox/18f2a9c1b7
|> call mail.reply(body => 'Looping in Sam, who owns the renewal.',
cc => '[email protected]')
The reply is a normal draft (reversible — nothing is sent yet), so sending it is the same
call mail.send as any other draft: read /mail/drafts for its id, then send that draft. Because
the draft was created in the thread, the sent message threads for every mail client — Gmail's view
and the In-Reply-To/References headers both point at the parent:
/mail/drafts |> select id, subject
/mail/drafts/r9b2c1 |> call mail.send
::: tip Reply is reversible; send is not
mail.reply only drafts — it previews and can be re-run freely. The irreversible step is the
same mail.send you already know. A mail.reply with no body, or addressed at anything but a
parent message, is refused at plan time.
:::
Attaching works the same way on every form — the attachments column is always an array of
structs { filename, mime, bytes }. You already saw it on a draft (insert into /mail/drafts);
it rides a one-shot send and a reply too.
Attach on a one-shot send — pass attachments right in the call:
/mail/drafts
|> call mail.send(to => '[email protected]', subject => 'Q3 report',
body => 'See attached.',
attachments => [ { filename: 'q3.txt', mime: 'text/plain', bytes: X'68656c6c6f' } ])
Attach on a reply — same attachments, alongside the reply body:
/mail/inbox/18f2a9c1b7
|> call mail.reply(body => 'Full breakdown attached.',
attachments => [ { filename: 'breakdown.csv', mime: 'text/csv', bytes: X'612c62' } ])
Detach = replace the draft's attachment set. A draft's attachments are exactly whatever the
latest upsert row says — so you detach by re-upserting the set you want to keep, and clear them
by omitting attachments entirely. Keep one of two, dropping the other:
upsert into /mail/drafts
values (draft_id, to, subject, body, attachments)
('r8a1f2c4', '[email protected]', 'Q3 report', 'One file only now.',
[ { filename: 'q3.txt', mime: 'text/plain', bytes: X'68656c6c6f' } ])
Detach everything — same upsert, no attachments column:
upsert into /mail/drafts
values (draft_id, to, subject, body)
('r8a1f2c4', '[email protected]', 'Q3 report', 'No attachment after all.')
::: tip Re-attaching a received file
An attachment listing carries metadata only — filename, mime, size, no bytes. To
forward a file you received, fetch its bytes from the attachment node first (its content
column), then feed those bytes into an attachments bytes field. Read one file's bytes with:
/mail/inbox/18f2a9c1b7/att-9 |> select filename, mime, content
Piping that content straight into a draft's attachments (rather than a hand-typed X'…'
literal) is the cross-service attach-and-send recipe — the same shape
works to re-attach a Gmail file or a Google Drive download.
:::
Trashing names an exact message id too — the same read to find, then act by id flow as a
relabel (Gmail's lossy search makes a set-wide trash unsafe, so it is refused). Find the offenders
with a select … where subject LIKE '%unsubscribe%', then trash each by its id.
Trash one message by its message node (the id is the last segment):
remove /mail/inbox/18f1a2b3c4
PREVIEW: 1 effect(s)
#0 REMOVE -> mail:/mail/inbox/18f1a2b3c4 [affected 1] (!)
(!) irreversible: 1 node(s) [#0]
total affected: 1
The (!) marks the irreversible gate: a one-shot needs --commit --commit-irreversible to apply it.
Trash by exact id on the collection — the equivalent collection form:
remove /mail/inbox
where id == '18f1a2b3c4'
::: tip describe never lies about verbs
qfs describe reports the exact verb set for each node, derived from its real capabilities —
they differ by node, and a verb that isn't listed is rejected at parse time, never silently dropped:
describe /mail → LS SELECT — the mailbox root lists your labels.describe /mail/inbox → SELECT UPDATE REMOVE — a label is a tail you read, relabel (UPDATE),
and trash (REMOVE). You don't append new mail to your own inbox, so there's no INSERT.describe /mail/drafts → SELECT INSERT UPSERT — drafts is the append log you write to; its rows
carry the draft id (the sendable identity). A single draft /mail/drafts/<draft-id> reads
(SELECT) and sends (CALL mail.send).describe id:<msg> → SELECT REMOVE; describe id:thread:<id> → REMOVE; an attachment →
SELECT.
:::What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
14 skills in this plugin
/qfsUse when the user asks to use QFS or its connected services. Discover the live connections and available paths before reading or writing through the qfs CLI; covers pipe-SQL, preview, and commit. For Slack channel discovery and threads, also read qfs-slack./qfs-automationUse when a task needs the qfs SERVER side — scheduled jobs, triggers, HTTP endpoints, and cached views created with CREATE bindings over queries you already write./qfs-chatworkUse when a task needs Chatwork through qfs — installing and querying the DECLARED /chatwork driver (rooms, a room's latest messages, a room's unread messages, room file listings, file download, and file upload) written in the query language itself, and posting a message to a room. Covers installing the chatwork.qfs declaration, connecting it to a stored Chatwork API token, reading the latest messages versus the unread-only ones, posting a message via ENCODE form, downloading a file's bytes via the FOLLOW stage, and uploading via ENCODE multipart./qfs-cloudflareUse when a task needs Cloudflare through qfs — installing and querying the DECLARED /cloudflare driver (zones, DNS records, account-scoped KV/Queues/D1 listings, plus D1 SQL, KV get/put, queue push and queue pull) written in the query language itself. Covers installing the cloudflare.qfs declaration, connecting it to the stored Cloudflare token, reading, consuming a queue with the read-over-POST pull view, and the declared D1 SQL surface. For Artifacts Git repositories use the compiled /cf driver instead./qfs-cookbookUse for an overview of what qfs can do and which qfs cookbook skill fits a task — reading, searching, transforming, or writing across Gmail, Google Drive, databases, files, git, GitHub, Slack, and automation with one pipe-SQL language. Routes to the per-service skills./qfs-cross-serviceUse when a task spans MORE THAN ONE service in a single qfs query — joining a database to GitHub, a file to a table, or federating several services with one JOIN or UNION over their paths.npx claudepluginhub qmu/qfs --plugin qfs