motia dev (JavaScript/TypeScript)
Builds your project in development mode with full type generation support.Usage
What it does
- Generates TypeScript types - Automatically creates
types.d.tsfrom your steps and streams - Bundles your code - Uses esbuild to create
dist/index-dev.js - Preserves external packages - All dependencies remain external for faster rebuilds
- Includes source maps - Full debugging support in development
Output
Configuration
The dev command automatically:- Sets platform to
node - Targets Node.js 22+
- Uses ESM format
- Bundles code with source maps
- Keeps all npm packages external
Running the built output
After building, run your project with the iii engine:motia typegen (JavaScript/TypeScript)
Generates TypeScript type definitions from your steps and streams.Usage
Options
| Option | Alias | Description | Default |
|---|---|---|---|
--output <path> | -o | Output file path | types.d.ts |
--watch | -w | Watch for file changes | false |
Examples
Basic type generation
Custom output path
Watch mode
Generated types structure
The typegen command analyzes your steps and streams to generate:motia run (Python)
Discovers and runs Python steps and streams.Usage
Options
| Option | Alias | Description | Default |
|---|---|---|---|
--dir <directory> | -d | Directory containing step files | steps |
--verbose | -v | Enable verbose logging | false |
Examples
Basic run
Custom directory
Verbose logging
Step discovery
Therun command automatically discovers:
- All
*_step.pyfiles in the specified directory - All
*_stream.pyfiles for streaming configuration - Includes
src/directory if it exists
motia dev (Python)
Runs Python steps in development mode with optional file watching.Usage
Options
| Option | Alias | Description | Default |
|---|---|---|---|
--dir <directory> | -d | Directory containing step files | steps |
--watch | -w | Watch for file changes | false |
--verbose | -v | Enable verbose logging | false |
Examples
Development mode
Watch mode
Watch mode requires the If not available, the command runs without watching.
watchfiles package. Install it with:Auto-restart behavior
When a file changes in watch mode:- The process detects the change
- Automatically restarts using
os.execv() - Reloads all steps and streams
- Reconnects to the iii engine
Environment variables
All development commands automatically load.env files:
process.env (JavaScript/TypeScript) or os.environ (Python).
Development workflow
Typical development workflow with Motia:1. Start the iii engine
2. Build in development mode
JavaScript/TypeScript:3. Make changes to your steps
Edit files in thesteps/ directory.
4. Rebuild (JavaScript/TypeScript only)
5. Test your changes
Use the iii Console or make HTTP requests to your steps:Performance optimization
JavaScript/TypeScript builds
Development builds are optimized for speed:- External packages aren’t bundled (faster rebuilds)
- Source maps included for debugging
- No minification (faster builds)
- All dependencies bundled
- Code minified and tree-shaken
- Source maps for error tracking
Python watch mode
For large projects, specify only the directories you’re working on:Troubleshooting
Type generation fails
Build fails with import errors
Python watch mode not working
Connection refused
Next steps
Build commands
Create production-ready builds
Defining steps
Learn how to create Motia steps
Triggers
Configure HTTP, queue, cron, and stream triggers
iii Console
Monitor your application in development