thunderbird-cli
AGENTS.md72 starsChanged 8 months agoMITView on GitHub
Repo guide for AI coding agents working in this codebase (Cursor, Cline, Codex CLI, Claude Code, Windsurf, Aider, etc.). Looking for the end-user skill that teaches Claude how to use this tool? That's in skills/thunderbird-cli/. This file is about working on the code. Four published artifacts, one architecture: Everything localhost-only. Thunderbird holds credentials; no creds pass through the agent. Node 20+ required. All three packages are ES modules ("type": "module"). Every command outputs atomic JSON: Error codes: BRIDGE_UNREACHABLE, EXTENSION_DISCONNECTED, AUTH_REQUIRED,…
- Installs packages
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,266 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- docs/CLAUDE.mdCLAUDE.md
- thunderbird-cliSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 49
Every command outputs atomic JSON:
- Distinctive: line 77
If you add a new tool or command that returns structured data, support these three options.
- Very specific: line 93
All four package.json files (package.json, cli/package.json, bridge/package.json, mcp/package.json) move together.
- Distinctive: line 140
Don't propose these without discussing first:
- Very specific: line 149
Check SPEC.md first. If it's not there, open an issue — don't guess at behavior from the WebExtension side.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md 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
AGENTS.md — thunderbird-cli
Repo guide for AI coding agents working in this codebase (Cursor, Cline, Codex CLI, Claude Code, Windsurf, Aider, etc.).
Looking for the end-user skill that teaches Claude how to use this tool? That's in
skills/thunderbird-cli/. This file is about working on the code.
What this repo ships
Four published artifacts, one architecture:
| Artifact | What | Where |
thunderbird-cli | tb CLI (38 commands) | cli/ → npm: thunderbird-cli |
thunderbird-cli-bridge | Stateless HTTP↔WS proxy daemon | bridge/ → npm: thunderbird-cli-bridge |
thunderbird-cli-mcp | MCP server (12 tools for Claude Desktop) | mcp/ → npm: thunderbird-cli-mcp |
| Thunderbird WebExtension | WS client inside Thunderbird | extension/ → XPI distributed via addons.thunderbird.net (no embedded signature) |
AI Agent ─→ tb CLI ─┐
├─→ bridge daemon ─→ Thunderbird WebExtension ─→ messenger.* APIs → your accounts
Claude ─→ tb-mcp MCP ─┘ HTTP :7700 WebSocket :7701Everything localhost-only. Thunderbird holds credentials; no creds pass through the agent.
Setup (before editing)
npm install # installs workspace deps for cli/, bridge/, mcp/
npm test # 46 CLI/bridge integration tests
npm run test:mcp # 34 MCP server tests
npm run bridge # start bridge (needed for live tests; not for unit tests)Node 20+ required. All three packages are ES modules ("type": "module").
Conventions you need to follow
Code style
- ES modules throughout,
"type": "module"in everypackage.json. - CLI framework:
commander.js. Command definitions incli/src/cli.js; HTTP client + formatters incli/src/client.js. - Bridge: vanilla Node
http+ws. Zero business logic — it's a UUID-correlated proxy. Don't add state. - MCP server:
@modelcontextprotocol/sdk. Stdio transport. Reusescli/src/client.js— don't re-implement the HTTP client inmcp/. - Extension: pure WebExtension (
manifest_version: 2). No Experiment APIs. Compatible with Thunderbird 128+.
Output format
Every command outputs atomic JSON:
{ "ok": true, "data": { ... } }
{ "ok": false, "error": "message", "code": "ERROR_CODE" }Error codes: BRIDGE_UNREACHABLE, EXTENSION_DISCONNECTED, AUTH_REQUIRED, FORBIDDEN, TIMEOUT, NOT_FOUND, INVALID_ARGS, THUNDERBIRD_ERROR. Don't invent new ones — pick an existing one or extend the union intentionally.
Safety defaults (NEVER weaken)
These are defaults the end-user agent relies on. Don't flip them:
email_searchexcludes junk unlessinclude_junk: trueis explicitemail_compose/email_reply/email_forwarddefault tomode: "draft"email_archive operation=deleterequirespermanent=trueANDconfirm=truefor permanent deletion- CLI bulk ops (
tb bulk delete,tb folder-delete) require--confirm
See SECURITY.md for the full threat model.
Token efficiency
The MCP + CLI both support:
fields(MCP) /--fields(CLI): comma-separated allowlist of keys in the responsecompact(MCP) /--compact(CLI): stripnullvaluesmax_body(MCP) /--max-body(CLI): truncate message bodies
If you add a new tool or command that returns structured data, support these three options. They're the difference between an agent fitting 50 results in context vs. 5.
Commit style
Conventional commits. Short form:
feat(scope): ...— new capabilityfix(scope): ...— bug fixdocs: ...— docs-onlychore: ...— metadata / toolingtest(scope): ...— test-only
Scopes: cli, bridge, mcp, extension, docker, meta, release.
Version bumps
All four package.json files (package.json, cli/package.json, bridge/package.json, mcp/package.json) move together. server.json (for the MCP Registry) must match the package version. Update CHANGELOG.md in the same commit.
Tests before pushing
npm test && npm run test:mcpprepublishOnly enforces this at publish time, but run it locally first — it'll save you a failed CI cycle. CI runs on Node 20 + 22.
Before opening a PR
- All four
package.jsonfiles match versions if you bumped server.jsonversion matches (when bumping)CHANGELOG.mdhas an entry- New CLI command? → add a test in
test/quick-test.mjs - New MCP tool? → add a test in
test/mcp-test.mjsand register it inmcp/src/tools.js - New error code? → document it in
SPEC.md - New destructive op? → gate it behind
--confirm/confirm: true - Did you change the MCP tool surface? → update
skills/thunderbird-cli/SKILL.mdso the end-user skill stays accurate
Release
Tagging vX.Y.Z fires .github/workflows/release.yml:
- Runs all 80 tests
- Builds the unsigned XPI
- Finds the release XPI in
dist/releases/(the file returned by ATN; must be checked in) - Creates the GitHub Release with both XPIs attached
npm publish is manual (cd cli && npm publish) — intentionally, so a release tag without publish is a no-op you can recover from.
Key files to know
| File | What's in it |
SPEC.md | Full technical specification — source of truth for tool surface |
SECURITY.md | Threat model, CLI defenses, agent patterns |
docs/SETUP.md | User install guide |
docs/COMMANDS.md | All 38 CLI commands reference |
docs/CLAUDE.md | Claude Code–focused CLI quick-ref (end-user oriented) |
docs/distribution-log.md | Launch venue submission tracker |
skills/thunderbird-cli/SKILL.md | End-user Claude skill (separate from this file) |
CONTRIBUTING.md | Local dev setup, PR process |
Non-goals
Don't propose these without discussing first:
- Server-side filtering logic. Thunderbird is source of truth; we don't reimplement IMAP filter semantics.
- Cloud deployment. Bridge is localhost-only by design. No remote auth, no TLS, no tunnels.
- New credential flow. We never touch user email credentials. If a feature needs OAuth, it doesn't belong here.
- Breaking the CLI ↔ MCP symmetry. CLI is the superset (38 cmds); MCP is the curated 12-tool subset. When adding a bulk op, CLI-only is the correct choice — don't expose it as an MCP tool unless it's individually-scoped.
Questions / weirdness
Check SPEC.md first. If it's not there, open an issue — don't guess at behavior from the WebExtension side. Thunderbird's messenger.* API has sharp edges (async races, provider-specific IMAP quirks, Gmail's label-not-folder model) that are documented in SPEC.md as we discover them.
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.

