Add to Claude Code
61 addsInstall this CLAUDE.md template.
Name: Discord Bot Project Template
Save to: ./CLAUDE.md in the current project
---
# CLAUDE.md — Discord Bot (discord.js v14 + TypeScript)
## Project overview
<!-- One-sentence description of what this Discord bot does -->
## Tech stack
- **Library**: discord.js v14
- **Language**: TypeScript
- **Runtime**: Node.js 22
- **Package manager**: npm
- **Database**: SQLite via better-sqlite3 (or Prisma for larger bots)
## Development commands
```bash
npm run dev # start with hot reload
npm run build # compile TypeScript
npm run start # run compiled JS
npm run deploy # register slash commands with Discord API
```
## Project structure
```
src/
index.ts # client initialization and login
commands/ # slash command handlers
ping.ts
help.ts
events/ # event listeners
ready.ts
interactionCreate.ts
messageCreate.ts
utils/
deploy-commands.ts # command registration script
embeds.ts # shared embed builders
logger.ts # logging utility
```
## Coding conventions
- Each command is a separate file exporting `data` (SlashCommandBuilder) and `execute` (handler)
- Events export `name`, `once` (boolean), and `execute`
- Always use `interaction.reply()` or `interaction.editReply()` for slash commands
- Use embeds (`EmbedBuilder`) for rich responses, not plain text walls
- Defer replies for operations >3 seconds: `await interaction.deferReply()`
- Use `Collection` for in-memory caches, not plain objects
## Slash command template
```typescript
import { SlashCommandBuilder, ChatInputCommandInteraction } from "discord.js"
export const data = new SlashCommandBuilder()
.setName("ping")
.setDescription("Check bot latency")
export async function execute(interaction: ChatInputCommandInteraction) {
const latency = Date.now() - interaction.createdTimestamp
await interaction.reply(\`Pong! \${latency}ms\`)
}
```
## Environment variables
```
DISCORD_TOKEN=
DISCORD_CLIENT_ID=
DISCORD_GUILD_ID= # for dev: register commands to one server (instant)
```
## Common pitfalls
- Slash commands registered globally take up to 1 hour to propagate: use guild commands for dev
- `interaction.reply()` can only be called once: use `followUp()` for additional messages
- Message Content Intent must be enabled in the Developer Portal for `messageCreate` events
- Rate limits: batch operations and respect `X-RateLimit-*` headers
Paste into Claude Code to add this template. Back up any existing CLAUDE.md first.
How to add
Full guide →Click Add, then paste into Claude Code. Claude will save it as your project's CLAUDE.md.
Target: CLAUDE.md