commandkit dev command starts a development server with hot module reloading (HMR), allowing you to see changes instantly without restarting your bot.
Basic Usage
Start the development server:- Build your project in development mode
- Start your Discord bot
- Watch for file changes
- Automatically reload commands and events
The development build is optimized for speed and includes source maps for debugging.
Command Options
Custom Config Path
Specify a custom config file:The default config path is
./commandkit.js in your project root.Hot Module Reloading (HMR)
The development server includes intelligent hot reloading that updates your bot without a full restart:What Gets Hot Reloaded?
- Commands
- Events
- Other Files
When you modify files in
src/app/commands/, the CLI:- Detects the change
- Rebuilds the affected command
- Reloads all commands in your bot
- Keeps the bot connection alive
Development Commands
While the dev server is running, you can type these commands in the terminal:r
Restart ServerManually restart the entire bot
rc
Reload CommandsForce reload all commands
re
Reload EventsForce reload all event handlers
Watched Directories
The CLI automatically watches these locations:src/**/*- All source filescommandkit.js/commandkit.ts- Config filecommandkit.config.js/commandkit.config.ts- Alternative config names
Config File Changes
When you modify the CommandKit config file:Development Environment
Environment Variables
In development mode, the CLI automatically loads:Build Output
Development builds are written to.commandkit/ directory:
The
.commandkit/ directory is temporary and should be added to your .gitignore.Anti-Crash Monitor
The development server includes an anti-crash monitor by default:Performance
The development server is optimized for fast rebuilds:Fast Rebuild Times
- Initial build: ~1-2 seconds
- Hot reload: ~100-300ms
- Full restart: ~1-2 seconds
TypeScript Support
The CLI includes zero-config TypeScript support:- No
tsconfig.jsonrequired (but respected if present) - Automatic type checking (disabled by default in dev mode)
- Full JSX/TSX support with
commandkitas JSX runtime
Debugging
Development builds include full source maps for debugging:Using Chrome DevTools
Using VSCode Debugger
Add this to.vscode/launch.json:
Troubleshooting
HMR not working
HMR not working
If hot module reloading isn’t working:
- Check that you’re editing files in
src/app/commands/orsrc/app/events/ - Ensure file changes are being saved
- Try manually reloading with
rcorrecommands - If still not working, restart with
r
Bot keeps restarting
Bot keeps restarting
If your bot restarts frequently:
- Check for syntax errors in your code
- Look for circular dependencies
- Ensure you’re not modifying files outside of commands/events
- Check the console for specific error messages
TypeScript errors
TypeScript errors
If you’re seeing TypeScript errors:
- TypeScript type checking is disabled by default in dev mode
- Run
commandkit buildto see full type checking - Install TypeScript if not present:
npm install -D typescript
Config changes not applying
Config changes not applying
Config file changes require manual restart:
- Press
rin the terminal to restart - Or stop and restart
commandkit dev
Next Steps
Production Builds
Learn how to build optimized bundles for deployment
Code Generators
Generate commands and events quickly