Skip to content
Back to skills

Import Gmail

ASecurity

Imports into Duccio (the second brain) the project knowledge contained in the Gmail threads of a date range given by the user (meeting minutes, exchanges with the client, progress reports, decisions, incidents), creating or updating meeting, decision and note notes with the link to the thread, without copying the emails. Use when the user asks to import, index or process the emails of a period.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
ai-agentspythongobashgit

Works with

  • cli

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add gabrycaos/duccio --skill import-gmail --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Import Gmail?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Import Gmail
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrycaos-import-gmail/badge)](https://www.skillsdirectory.com/skills/gabrycaos-import-gmail)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: import-gmail
description: Imports into Duccio (the second brain) the project knowledge contained in the Gmail threads of a date range given by the user (meeting minutes, exchanges with the client, progress reports, decisions, incidents), creating or updating meeting, decision and note notes with the link to the thread, without copying the emails. Use when the user asks to import, index or process the emails of a period.
---

# import-gmail

Work from the repo root. Apply the "Writing rules" and "Git protocol" sections of `AGENTS.md`. Folder names and headings below are the English ones; in a vault of another language use the matching names from the table in "Vault language". Gmail is read-only: do not send, label, archive or modify anything.

Two operations of the Gmail tool are needed: searching threads with the Gmail search syntax and reading a whole thread as plain text. If they are not available, say so and stop.

Emails are not copied into the vault: only the extracted knowledge goes in, and `sources:` contains the web link of the thread.

## 0. Range and blocks

If the user has not given the range, ask for it. Split it into monthly blocks, from the oldest to the most recent. For each block compute:
- `START` (`YYYY/MM/DD`, inclusive): the first day of the month, or the start date of the range;
- `END` (`YYYY/MM/DD`, exclusive): the first day of the next month, or the day after the end date (tomorrow, if the range reaches today).

Months already imported: `git log --grep '^import-gmail: ' --format='%s'`. A month without notes leaves no commit. If the range includes them, warn and continue: the threads already cited are skipped anyway.

Do step 1 once, then steps 2–11 for each block.

## 1. Pull

Pull according to the Git protocol.

## 2. Query

Exclusions from `config/gmail-ignore.txt`:

```bash
.venv/bin/python - <<'EOF'
from pathlib import Path
lines = Path("config/gmail-ignore.txt").read_text(encoding="utf-8").splitlines()
print(" ".join(f"-({l.strip()})" for l in lines if l.strip() and not l.strip().startswith("#")))
EOF
```

The query of the block is `after:START before:END <exclusions>`.

## 3. Count

List the threads of the block asking only for the ids (50 per page, follow the pages to the end) and count the total. Report it to the user.

If it exceeds ~300, before continuing propose adding terms to `gmail-ignore.txt` or splitting the run over several sessions.

## 4. List

List the threads again with the lightest view that returns, for the last message of each thread: subject, sender, snippet and date. For the thread you also need the number of messages and the web link of the thread returned by the tool (`viewUrl`, form `https://mail.google.com/mail/?authuser=…#all/thread-f:<number>`): use it as it is.

The number after `thread-f:` is the thread id in decimal: `int(hex_id, 16)`, and conversely `format(number, 'x')`. If the `viewUrl` does not contain `thread-f:` (e.g. `thread-a:` for threads started by the user), build the link as `https://mail.google.com/mail/?authuser=<user's email>#all/thread-f:<int(id, 16)>`, so the check of step 5 recognizes it.

## 5. Already imported

Pass the hexadecimal ids of the block, separated by spaces:

```bash
IDS="<id1> <id2> …" .venv/bin/python - <<'EOF'
import os, re, subprocess
from pathlib import Path
import yaml
cited = {}
for path in Path("vault").rglob("*.md"):
    if {"raw", "Templates", ".obsidian", ".trash"} & set(path.parts):
        continue
    text = path.read_text(encoding="utf-8")
    if not text.startswith("---\n"):
        continue
    meta = yaml.safe_load(text[4:text.find("\n---", 3)]) or {}
    for source in meta.get("sources") or []:
        for n in re.findall(r"thread-f:(\d+)", str(source)):
            cited.setdefault(n, set()).add(str(path))
for h in os.environ["IDS"].split():
    for p in sorted(cited.get(str(int(h, 16)), ())):
        last = subprocess.run(["git", "log", "-1", "--format=%cs", "--", p], capture_output=True, text=True).stdout.strip()
        print(f"{h}\t{p}\t{last or 'uncommitted'}")
EOF
```

Each line is a thread already cited in the `sources:` of a note, with the date of the note's last commit. Discard these threads. If the last message of a thread is more recent than that date, report it in the summary, without modifying anything.

## 6. Triage

Only on subject, sender and snippet. Keep the threads that may contain project knowledge:
- meeting minutes (e.g. Gemini notes `Note: "…"`);
- exchanges with the client;
- progress reports and project status;
- decisions and requirements;
- incidents with causes or outcomes.

Gemini minutes that contain only the Meet notification (no summary or action items) have no content: discard them as "other". Discard the rest and count the discards by category: automatic notifications, organization (invitations, leave, rooms), company communications, newsletters and marketing, other.

If the same kind of noise recurs (same sender or same subject pattern, at least 3 times in the block), prepare the term to propose for `gmail-ignore.txt` (e.g. `from:training@example.com`). You ask for it in step 9.

## 7. Route

Hub signals:

```bash
.venv/bin/python - <<'EOF'
import glob, sys
sys.path.insert(0, "scripts")
import sbconfig
import yaml
from pathlib import Path
# configuration: vault language (folder names)
try:
    code = sbconfig.language()
    if code is None:
        sys.exit("vault language not configured: run scripts/setup.sh")
    folders = sbconfig.vocabulary(code).folders
except sbconfig.ConfigError as exc:
    sys.exit(str(exc))
def meta(path):
    text = Path(path).read_text(encoding="utf-8")
    if not text.startswith("---\n"):
        return {}
    return yaml.safe_load(text[4:text.find("\n---", 3)]) or {}
active = {}
for path in sorted(glob.glob(f"vault/{folders['clients']}/*/{folders['projects']}/*/*.md")):
    m = meta(path)
    if m.get("type") != "project":
        continue
    client = Path(path).parts[2]
    if m.get("status") == "active":
        active.setdefault(client, []).append(Path(path).stem)
    repos = [r.rsplit("/", 1)[-1] for r in m.get("repos") or []]
    print(f"HUB {Path(path).stem} | client {client} | {m.get('status')} | aliases {m.get('aliases') or []} | jira {m.get('jira') or []} "
          f"| confluence {m.get('confluence_spaces') or []} | repos {repos} | people {[p.strip('[]') for p in m.get('people') or []]}")
for path in sorted(glob.glob(f"vault/{folders['clients']}/*/*.md")):
    m = meta(path)
    if m.get("type") == "client":
        c = Path(path).stem
        print(f"CLIENT {c} | domains {m.get('domains') or []} | active projects {active.get(c, [])}")
EOF
```

For each kept thread decide client and project.

**Signals that are enough on their own** (in the subject, in the snippet or in the text):
- a Jira key of a hub (e.g. `PB-10`);
- the name or an alias of a project (e.g. "Portale B2B", "App Mobile");
- the name of a repo of the hub;
- a Confluence space of the hub.

**Weak signals:**
- the domain of the user's company (the one of their email) never counts;
- a domain of another client (`domains`) indicates the client, and is enough for the project only if that client has a single active project;
- the people linked to a hub count only together with another signal.

If the metadata is not enough, read the thread (step 8) and look for the signals in the text. Without a sufficient signal, or if the material requires a new client or project, the thread is **uncertain**: write nothing and keep it for step 9.

## 8. Read and extract

For each thread with a clear project, read it whole as plain text. In long threads (forwards, replies quoting the whole chain) extract the facts from the messages skipping the quoted parts (lines with `>`), signatures and disclaimers; if the result is too large to be read directly, process it in parts. Then follow the steps "6. Extract the notes" and "7. Update hubs and client note" of the `process` skill (`.agents/skills/process/SKILL.md`), with these differences:
- add the thread link to `sources:` (without removing the sources already there), and the hub's Log line ends with `(from [Gmail thread](<thread link>))` instead of `(from [[raw/archive/…]])`;
- meeting minutes become a `meeting` with the date of the meeting, not that of the email. For recurring meetings include the project in the title (e.g. `2026-10-28 Alignment Portale B2B.md`);
- attachments and links to Drive or other tools are cited in the text, without downloading them;
- **emails are historical**:
  - update the hub's `## Status` only with information more recent than what it already reports;
  - if you import a decision older than an existing one on the same topic, mark the imported one as `superseded` (with `superseded_by`), not the existing one;
- people: link in `people:` those who already have a note. Create a new person only if the thread shows a role in the project (contact person, team member), not for occasional participants, and never if they match `config/people-ignore.txt` (email or normalized name). Other names stay plain text;
- sensitive data: replace it with the redaction marker, `[REDACTED]` (in a vault of another language, the `redacted` value from the table in "Vault language"). There is no archiving choice: nothing is archived. Do not report meeting passcodes and PINs, tokens in links, personal data of end clients (emails, phone numbers, tax codes, accounts) or HR or personal content about colleagues;
- a thread may produce several notes (e.g. minutes and a decision), or none if on reading it contains no useful knowledge.

## 9. End-of-block question

If there are items to ask about, ask a single question with:
- the uncertain threads, each with subject, date, link and proposed project (or "ignore");
- the threads that require a new client or project, with the proposal (name, location, keys, as in the "3. Route" step of `process`);
- the terms proposed for `gmail-ignore.txt`;
- the recurring email domains of a client that are not yet in its `domains` (e.g. `acme.com` for Acme), excluding that of the user's company.

Then read and write the confirmed threads (step 8), add the confirmed terms to `config/gmail-ignore.txt`, at the end, with a comment, and the confirmed domains to the `domains` of the client note, with a Log line. If there is nothing to ask, skip this step.

## 10. Commit and push

Run `.venv/bin/python scripts/lint.py` and fix your notes.

Stage all the files touched by the block and only those: notes, hubs, client notes, people, technologies, `config/gmail-ignore.txt` if modified. Commit with `git commit -m "import-gmail: <YYYY-MM> (<N> notes)"`, where N is the number of meeting, decision and note notes created or updated. Then push according to the Git protocol.

If the block produced no changes, no commit.

## 11. Block summary

- threads counted, discarded by category, already imported;
- notes created and updated, with links;
- already imported threads with new messages;
- external keys added to the hubs and notes skipped because of uncommitted changes;
- pending push.

Then move on to the next block.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.