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 🙏

© 2026 – Pkg Stats / Ryan Hefner

agent4discord

v0.3.0

Published

Remote Claude Code sessions through Discord

Readme


Agent4Discord (A4D) is a self-hosted Discord bot that lets you interact with Claude Code through Discord channels. Each session maps to a dedicated channel, tool calls appear in threads, and permission requests show as interactive buttons.

Your PC. Your bot. Your Claude Code sessions.

How It Works

  1. You run the bot on your PC with your own Discord bot token
  2. /a4d init sets up channels in your Discord server
  3. Pick a working directory and start a Claude Code session
  4. Chat with Claude through Discord — streaming, tool calls, and permissions all work

Features

  • Directory Browser — Navigate your filesystem with select menus, buttons, and create directories
  • Model & Permission Mode — Choose opus/sonnet/haiku and permission level (default, auto-accept edits, full auto) when starting a session
  • Real-time Streaming — Live-updating embeds for text output, thinking, and tool progress
  • Tool Call Threads — Each tool execution gets its own thread with formatted input/output
  • Permission Control — Allow/Always Allow/Deny buttons for dangerous operations (auto-allow for safe tools)
  • File Attachments — Send files to Claude via Discord attachments, Claude can send files back
  • Completion Notification — @mentions you when Claude finishes responding
  • Session Resume — Resume CLI-created sessions or stopped sessions with /a4d resume
  • Usage Tracker#a4d-usage channel shows session costs, tokens, and rate limits
  • Plugin Support — Auto-loads your installed Claude Code plugins (skills, hooks)
  • CLI Interop — Sessions share the same JSONL storage as the CLI

Directory Browser

Directory Browser

Session with Streaming

Session

Permission Request

Permission

Quick Start

Prerequisites

  • Node.js >= 20.x
  • Claude Code authenticated (claude login or ANTHROPIC_API_KEY)
  • Discord bot token (create one here)

Setup

npx agent4discord@latest --setup

The setup wizard will:

  1. Ask for your Discord bot token
  2. Ask for your Client ID
  3. Verify Message Content Intent is enabled
  4. Generate an invite URL and open it in your browser

Run

npx agent4discord@latest

In Discord

  1. Run /a4d init in your server
  2. Go to #a4d-session and browse to a directory
  3. Click Session Start, pick a model, and start chatting

Commands

| Command | Description | |---|---| | /a4d init | Set up A4D channels in your server | | /a4d resume | Resume a stopped session in the current channel | | /a4d model <opus\|sonnet\|haiku> | Change model mid-session | | /a4d close | Stop the session and delete the channel |

Channel Structure

A4D - General
├── #a4d-general      — Status messages
├── #a4d-session      — Directory browser & session start
└── #a4d-usage        — Usage & rate limit tracker

A4D - Sessions
├── #a4d-myproject    — Active session channel
└── #a4d-another      — Another session

Configuration

Config is stored at ~/.agent4discord/config.json:

{
  "discordToken": "your-bot-token",
  "discordClientId": "your-client-id",
  "claudeModel": "opus",
  "permissionMode": "default",
  "logLevel": "info"
}

Development

git clone https://github.com/raravel/Agent4Discord.git
cd Agent4Discord
npm install

# Dev mode with auto-reload
npx tsx watch src/cli.ts

# Type check
npx tsc --noEmit

Project Structure

src/
├── cli.ts                    # Entry point
├── setup.ts                  # Interactive setup wizard
├── config.ts                 # Config loading (~/.agent4discord/)
├── bot.ts                    # Discord client & event handlers
├── guild.ts                  # Guild config persistence
├── commands/
│   ├── index.ts              # Slash command registry
│   ├── init.ts               # /a4d init
│   ├── resume.ts             # /a4d resume
│   ├── model.ts              # /a4d model
│   └── close.ts              # /a4d close
├── interactions/
│   ├── index.ts              # Interaction router
│   ├── directoryBrowser.ts   # Directory browser UI
│   └── permissionHandler.ts  # Allow/Always Allow/Deny buttons
├── sessions/
│   ├── sessionManager.ts     # SDK query() lifecycle
│   ├── sessionStore.ts       # Session persistence
│   ├── eventHandler.ts       # SDK events → Discord
│   ├── streamHandler.ts      # Streaming text/thinking embeds
│   ├── toolProgress.ts       # Tool execution progress
│   └── usageTracker.ts       # Rate limit & cost tracking
├── tools/
│   └── discordTools.ts       # MCP tools for Discord (file attachments)
├── formatters/
│   ├── embedBuilder.ts       # Discord embeds
│   ├── chunker.ts            # Message chunking
│   └── toolFormatter.ts      # Tool-specific formatting
└── utils/
    ├── filesystem.ts         # Directory listing
    ├── attachments.ts        # Discord attachment processing
    ├── plugins.ts            # Plugin auto-loader
    └── logger.ts             # Logging

License

MIT