npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@smcllns/gmail

v0.3.2

Published

Minimal Gmail CLI with restricted scopes for Claude Code and other agents

Readme

@smcllns/gmail

A minimal Gmail CLI with restricted permissions so Claude Code and other agents can autonomously read and organize your inbox.

bunx @smcllns/gmail search "in:inbox is:unread" --max 10

Why use this?

This is a fork of the excellent @mariozechner/gmcli. The original requests full Gmail permissions (mail.google.com), and I wanted to restrict capabilities to prevent agents from accidentally sending or deleting email. The intent is to let agents run autonomously to understand and manage the inbox, while requiring a human to make any one-way door decisions.

  1. Restricted OAuth scopes - The original uses mail.google.com (full access). This fork requests only:

    • gmail.modify - to read messages, threads, and change labels
    • gmail.labels - to create and edit labels
  2. Dangerous operations blocked in CLI - Even where OAuth scopes allow, the CLI blocks:

    • send and delete commands are disabled
    • Disabled commands return guidance directing users to the Gmail web interface
  3. Simplified for agent usage:

    • Renamed binary from gmcli to gmail
    • Default account config so commands don't require email prefix
    • Usage: bunx @smcllns/gmail <command> or npx @smcllns/gmail <command>

Comparison

| Feature | @mariozechner/gmcli (original) | @smcllns/gmail (this fork) | | --- | --- | --- | | Gmail permissions | Full access | Read and organize mail (no send/delete) | | OAuth scopes | mail.google.com | gmail.modify, gmail.labels | | Read email | ✅ Yes | ✅ Yes | | Send email | ✅ Yes | ❌ No | | Delete email | ✅ Yes | ❌ No | | Manage labels | ❌ No | ✅ Yes | | Shell command | gmcli | gmail | | Set default account | ❌ No | ✅ Yes |

Install

npm install -g @smcllns/gmail

Or run directly without global install:

npx @smcllns/gmail <command>

Quickstart

After setup, search your inbox:

gmail search "in:inbox is:unread" --max 10

Setup (one-time)

1. Create OAuth credentials

  1. Go to Google Cloud Console
  2. Create a new project (or select existing)
  3. Enable the Gmail API
  4. Go to "APIs & Services" → "Credentials"
  5. Create "OAuth client ID" → "Desktop app"
  6. Download the credentials JSON file

2. Configure the CLI

# Config saved in ~/.gmail-cli/

# Set up OAuth Client credentials (once per machine)
gmail accounts credentials ~/path/to/credentials.json

# Add your Gmail account (opens google sign-in in browser to auth)
gmail accounts add [email protected]

# Or use --manual for headless/server environments
gmail accounts add [email protected] --manual

Usage

Search

Uses Gmail search syntax:

gmail search "in:inbox"
gmail search "from:[email protected] is:unread"
gmail search "has:attachment filename:pdf after:2024/01/01"
gmail search "label:Work subject:urgent" --max 50
gmail search --label Label_123              # filter by label ID (from 'labels list')
gmail search "is:unread" --label INBOX      # combine query with label filter

Read threads

gmail thread <threadId>
gmail thread <threadId> --download  # saves attachments to ~/.gmail-cli/attachments/

Manage labels

gmail labels list
gmail labels create "My Label"
gmail labels create "Urgent" --text "#ffffff" --bg "#fb4c2f"  # with colors
gmail labels edit "My Label" --name "Renamed" --bg "#16a765"
gmail labels <threadId> --add Receipts --remove INBOX  # add label "Receipts" and archive thread

Get Gmail URLs to view messages in browser

gmail url <threadId>

Full command reference

USAGE

  gmail accounts <action>              Account management
  gmail config <action>                Configuration management
  gmail <command> [options]            Gmail operations (uses default account)
  gmail --account <email> <command>    Gmail operations with specific account

ACCOUNT COMMANDS

  gmail accounts credentials <file>    Set OAuth credentials (once)
  gmail accounts list                  List configured accounts
  gmail accounts add <email>           Add account (--manual for browserless OAuth)
  gmail accounts remove <email>        Remove account

CONFIG COMMANDS

  gmail config default <email>         Set default account
  gmail config show                    Show current configuration

GMAIL COMMANDS

  gmail search [query] [--max N] [--page TOKEN] [--label L]
      Search threads. Query uses Gmail syntax, --label filters by name or ID.
      Returns: thread ID, date, sender, subject, labels.

  gmail thread <threadId> [--download]
      Get full thread. --download saves attachments.

  gmail labels list
      List all labels with ID, name, type, and colors.

  gmail labels create <name> [--text HEX] [--bg HEX]
      Create a new label with optional colors.

  gmail labels edit <label> [--name <newName>] [--text HEX] [--bg HEX]
      Edit a label's name and/or colors.

  gmail labels <threadIds...> [--add L] [--remove L]
      Modify labels on threads.
      System labels: INBOX, UNREAD, STARRED, IMPORTANT, TRASH, SPAM

  gmail url <threadIds...>
      Generate Gmail web URLs for threads.

RESTRICTED (returns guidance to use Gmail web UI)

  gmail send
  gmail delete

DATA STORAGE

  ~/.gmail-cli/credentials.json   OAuth client credentials
  ~/.gmail-cli/accounts.json      Account tokens
  ~/.gmail-cli/config.json        CLI configuration
  ~/.gmail-cli/attachments/       Downloaded attachments

How to use with Claude Code

Here's an abbreviated example of how I use this with Claude Code:

1. Create a gmail skill

Show Claude how to use the CLI (independent of your specific preferences). The full content is similar to this README. Abbreviated:

# .claude/skills/gmail/SKILL.md
---
name: gmail
description: Fetches and manages Gmail using @smcllns/gmail. Use when the user asks about their email, wants an email summary, or needs to search/read/archive messages.
allowed-tools: Bash(bunx @smcllns/gmail:*)
---
# ...

# Fetch first 25 unread messages in inbox
bunx @smcllns/gmail search "in:inbox is:unread" --max 25

# ...

2. Create an /email command

This contains all my subjective instructions and preferences for how to organize my inbox and what I want done. An abbreviated version:

# .claude/commands/email.md
---
description: Read recent emails, organize into categories and write email reports to Obsidian
allowed-tools: Skill(gmail)
---
You are an executive assistant. Your task is to process email so it is efficient to review and take action.

Every email gets exactly one category

| Category | What belongs here |
|----------|-------------------|
| ⚠️ **Action** | Decision needed or response required |
| 📅 **Calendar** | Appointments, RSVPs, event reminders |
| 📦 **Packages** | Shipping, returns, food delivery |

What to elevate to my inbox for attention (everything else skips inbox)
- ...

License

MIT