Use with AI agents
AI coding agents such as Claude Code, Cursor or Codex can run terminal commands, so they can
drive fob-mail directly. Ask in plain language, for example "which bills came in this week and
nobody has picked up?", and the agent runs the commands, reads the JSON and answers.
fob-mail works with the client mailboxes your firm has connected in Mail. For your own mailbox
over IMAP, point the agent at fob-email
instead.
1. Install and connect
Install the CLI and add a profile yourself (install, setup). If
you'd rather the agent do it, tell it to run fob-mail getting-started. That command checks for
an existing profile first, and tells agents to ask you for the API key and secret rather than make
them up.
The API key's preset is the real boundary: Mail refuses what the key isn't allowed to do. For an agent that only answers questions, create a Read only key. Use Read and label if it should triage, and Read, label and send only if it should send mail, with approval prompts on. Limit the key to the mailboxes the agent needs.
2. Tell the agent about fob-mail
Add a short note to your project's agent instructions (CLAUDE.md, AGENTS.md, .cursorrules
or similar):
## Client mail
Use the `fob-mail` CLI for anything in our clients' mailboxes (not `fob-email`, which is for a personal IMAP mailbox).
- Start with `fob-mail config profiles current` to confirm which firm you're in, and `fob-mail mailboxes list` to see the mailboxes this key may use.
- Discover commands with `fob-mail --help` and `fob-mail <resource> <action> --help`.
- Use `--json` and parse the output; don't scrape tables. Add `--all` to get every page.
- If a command fails, read the next step printed under the error before retrying.
- Never run `threads reply` or `messages send` without showing me the text and recipients first: sent mail can't be unsent.
- Ask before `threads edit`, `labels create` or `config profiles remove`.
- Docs (raw Markdown index): https://mail.finopsbricks.com/llms.txt
3. Ask
Some requests that work well:
- "Which open threads have no one assigned? Group them by mailbox." The agent runs
threads list --status open --assignee none --all --json, thenmailboxes list --jsonfor the names. - "Download every attachment from [email protected] this month into ./bills." The agent runs
threads list --from [email protected] --since 2026-11-01 --json,threads show <id> --jsonfor the attachment ids, thenattachments pull <id> -o ./bills/for each. - "Find the email with Message-ID
<[email protected]>and summarise it." The agent runsmessages list --message-id '<[email protected]>' --json, thenmessages show <id> --json. - "Label every open invoice thread as
billand assign it to the key." The agent lists the threads, shows you the list, then runsthreads edit <id> --add-label bill --assignee meper thread. - "Draft a reply to the latest statement request." The agent reads the thread with
threads show <id> --jsonand writes the text. You read it, then let it runthreads reply.
fob-mail does one thing per command and the agent strings them together. That's expected.
What the agent can't do
fob-mail can't move, delete or mark mail in the client's mailbox, and has no drafts. Sending is
plain text from Google mailboxes only, with no attachments yet. Connecting a new mailbox takes the
client's sign-in, so a person does it in Mail. If the agent says it can't do one of these, it's
right.
Running it again is safe
threads reply and messages send derive an idempotency key from what they send. If the agent
retries the same command after a timeout, Mail returns the first result and sends nothing. A
pending send status means Gmail's answer was lost: check the client's Sent folder before sending
again.
Docs for agents
Every docs page is also served as raw Markdown, which is easier for agents to read than HTML:
- Index of all pages:
/llms.txt(also at/docs/md/sitemap) - Any page: add
/mdafter/docs. For example, this page is at/docs/md/cli/ai-agents - Automations that call the API directly: API reference and LLM access