Prerequisites
Before starting development, ensure you have:- Node.js 22.x (LTS)
- npm 10.x
- PostgreSQL 16 (for cloud mode testing)
Initial Setup
1. Clone and Install
2. Configure Environment Variables
Copy the example environment file:packages/backend/.env with the following minimal configuration:
Generate a secure
BETTER_AUTH_SECRET with: openssl rand -hex 323. Set Up PostgreSQL (Optional)
For local mode (default for development), PostgreSQL is not required — Manifest uses sql.js (WASM SQLite). If testing cloud mode features, start a PostgreSQL container:DATABASE_URL in your .env file accordingly.
Running the Development Server
The backend requires the
.env file to be loaded before import time. Always use NODE_OPTIONS='-r dotenv/config' or the commands shown below.Start All Services
Open three terminal windows and run: Terminal 1 — BackendThe root command
npm run dev starts the frontend and plugin but NOT the backend (because the backend script is start:dev, not dev). Always start the backend separately.Access the Application
- Frontend (dev server): http://localhost:3000
- Backend API: http://localhost:3001
/api and /otlp requests to the backend automatically.
Development Modes
Local Mode (Default)
Local mode uses sql.js (WASM SQLite) and skips Better Auth. This is the primary development target.- No PostgreSQL required
- No authentication setup needed
- Fast startup
- Auto-login on localhost
Cloud Mode
Cloud mode uses PostgreSQL and Better Auth (email/password + OAuth providers).Plugin Dev Mode
When testing the OpenClaw plugin integration (routing, telemetry, OTLP), use dev mode:Seeding Development Data
WithSEED_DATA=true in your .env, the app seeds demo data on startup:
- Admin user:
[email protected]/manifest - Tenant:
seed-tenant-001 - Agent:
demo-agentwith OTLP keydev-otlp-key-001 - API key:
dev-api-key-manifest-001 - Security events: 12 sample events
- Model pricing: 28 models (Anthropic, OpenAI, Google, DeepSeek, etc.)
[email protected] / manifest to access the dashboard.
Database Migrations
TypeORM migrations run automatically on app startup (migrationsRun: true).
Generate a Migration
After modifying an entity:Other Migration Commands
Building for Production
Build all packages:- Frontend (Vite →
packages/frontend/dist/) - Backend (NestJS →
packages/backend/dist/) - Plugin (esbuild →
packages/openclaw-plugin/dist/)
Troubleshooting
Backend won’t start
- Ensure
BETTER_AUTH_SECRETis set in.env(min 32 chars) - Check that
NODE_OPTIONS='-r dotenv/config'is used - Verify PostgreSQL is running (if using cloud mode)
Frontend can’t reach API
- Ensure the backend is running on port 3001
- Check Vite proxy config in
packages/frontend/vite.config.ts
Plugin not receiving telemetry
- Restart the gateway:
openclaw gateway restart - Check endpoint URL:
openclaw config get plugins.entries.manifest.config.endpoint - Verify the backend is running and accessible
- The gateway batches telemetry every 10-30 seconds — wait a moment for data to appear
OpenClaw plugin in bad state
Reset the plugin configuration:Next Steps
- Review the Architecture to understand the codebase structure
- Read the Testing Guide to learn how to write tests
- Check the Contributing Guidelines before submitting PRs