agentleFS
vitalio-shvitalio-sh/thunderbird-cli/AGENTS.md

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.

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
  1. Distinctive:

    Every command outputs atomic JSON:

    line 49
  2. Distinctive:

    If you add a new tool or command that returns structured data, support these three options.

    line 77
  3. Very specific:

    All four package.json files (package.json, cli/package.json, bridge/package.json, mcp/package.json) move together.

    line 93
  4. Distinctive:

    Don't propose these without discussing first:

    line 140
  5. Very specific:

    Check SPEC.md first. If it's not there, open an issue — don't guess at behavior from the WebExtension side.

    line 149

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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:

ArtifactWhatWhere
thunderbird-clitb CLI (38 commands)cli/ → npm: thunderbird-cli
thunderbird-cli-bridgeStateless HTTP↔WS proxy daemonbridge/ → npm: thunderbird-cli-bridge
thunderbird-cli-mcpMCP server (12 tools for Claude Desktop)mcp/ → npm: thunderbird-cli-mcp
Thunderbird WebExtensionWS client inside Thunderbirdextension/ → 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 :7701

Everything 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 every package.json.
  • CLI framework: commander.js. Command definitions in cli/src/cli.js; HTTP client + formatters in cli/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. Reuses cli/src/client.js — don't re-implement the HTTP client in mcp/.
  • 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_search excludes junk unless include_junk: true is explicit
  • email_compose / email_reply / email_forward default to mode: "draft"
  • email_archive operation=delete requires permanent=true AND confirm=true for 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 response
  • compact (MCP) / --compact (CLI): strip null values
  • max_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 capability
  • fix(scope): ... — bug fix
  • docs: ... — docs-only
  • chore: ... — metadata / tooling
  • test(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:mcp

prepublishOnly 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.json files match versions if you bumped
  • server.json version matches (when bumping)
  • CHANGELOG.md has an entry
  • New CLI command? → add a test in test/quick-test.mjs
  • New MCP tool? → add a test in test/mcp-test.mjs and register it in mcp/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.md so the end-user skill stays accurate

Release

Tagging vX.Y.Z fires .github/workflows/release.yml:

  1. Runs all 80 tests
  2. Builds the unsigned XPI
  3. Finds the release XPI in dist/releases/ (the file returned by ATN; must be checked in)
  4. 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

FileWhat's in it
SPEC.mdFull technical specification — source of truth for tool surface
SECURITY.mdThreat model, CLI defenses, agent patterns
docs/SETUP.mdUser install guide
docs/COMMANDS.mdAll 38 CLI commands reference
docs/CLAUDE.mdClaude Code–focused CLI quick-ref (end-user oriented)
docs/distribution-log.mdLaunch venue submission tracker
skills/thunderbird-cli/SKILL.mdEnd-user Claude skill (separate from this file)
CONTRIBUTING.mdLocal 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.