Dev Command
The dev
command runs your ElizaOS project or plugin in development mode with auto-rebuild and restart on file changes. This is the recommended way to develop and test your implementations locally.
Usage
npx @elizaos/cli dev [options]
Options
Option | Description |
---|---|
--port , -p | Port to listen on |
--configure | Reconfigure services and AI models (skips using saved configuration) |
--character | Path or URL to character file to use instead of default |
--build | Build the project before starting |
Development Features
When you run dev
, ElizaOS provides several developer-friendly features:
- Auto Rebuilding: Automatically rebuilds your project when source files change
- Auto Restarting: Restarts the server after rebuilds to apply changes
- File Watching: Monitors your source files for changes
- TypeScript Support: Compiles TypeScript files during rebuilds
What Happens During Dev Mode
When you run the dev
command, ElizaOS:
- Detects whether you're in a project or plugin directory
- Builds the project initially
- Starts the server using the
start
command with your options - Sets up file watching for .ts, .js, .tsx, and .jsx files
- Rebuilds and restarts when files change
Examples
Basic Development Mode
Start your project in development mode:
# Navigate to your project
cd my-agent-project
# Start development mode
npx @elizaos/cli dev
Custom Port
Run the development server on a specific port:
npx @elizaos/cli dev --port 8080
Using a Custom Character
Use a specific character file:
npx @elizaos/cli dev --character ./characters/custom-assistant.json
Force Configuration
Skip using saved configuration and reconfigure services:
npx @elizaos/cli dev --configure
Development Process
A typical development workflow with ElizaOS:
- Edit code: Modify TypeScript/JavaScript files in your project
- Automatic rebuild: The dev server detects changes and rebuilds
- Automatic restart: The server restarts with your changes
- Test: Interact with your updated implementation
- Repeat: Continue the development cycle
File Watching
The dev command watches for changes in your project's source files, specifically:
- TypeScript files (
.ts
,.tsx
) - JavaScript files (
.js
,.jsx
)
The file watcher ignores:
node_modules/
directorydist/
directory.git/
directory
Logs and Debugging
The dev mode provides information about the file watching and rebuild process:
[info] Running in project mode
[info] Building project...
[success] Build successful
[info] Starting server...
[info] Setting up file watching for directory: /path/to/your/project
[success] File watching initialized in: /path/to/your/project/src
[info] File event: change - src/index.ts
[info] Triggering rebuild for file change: src/index.ts
[info] Rebuilding project after file change...
[success] Rebuild successful, restarting server...
Project Type Detection
The dev command automatically detects whether you're working with:
- Project: A complete ElizaOS project with agents
- Plugin: An ElizaOS plugin that provides extensions
It determines this by checking:
- The package.json metadata
- Export patterns in src/index.ts
- Project structure
Exiting Dev Mode
To stop the development server:
- Press
Ctrl+C
in the terminal - The server and file watcher will gracefully shut down
Troubleshooting
Build failures
If your project fails to build:
[error] Initial build failed: Error message
[info] Continuing with dev mode anyway...
The server will still start, but you'll need to fix the build errors for proper functionality.
File watching issues
If file changes aren't being detected:
- Check if your files are in the watched directories
- Ensure you're modifying the right types of files (.ts, .js, .tsx, .jsx)
- Check for error messages in the console