Development Tools
Development tools for local testing and debugging.
Primary Development Mode
Just use bun run dev - This is the main way to run Babylon locally!
bun run devThis starts:
- Next.js development server on
http://localhost:3000 - Local cron simulator that calls
executeGameTick()every 60 seconds - Hot module replacement for instant updates
How It Works
The local cron simulator (scripts/local-cron-simulator.ts) mimics production behavior by calling the same executeGameTick() function that Vercel Cron uses in production.
What Runs During Development
When you run bun run dev, it automatically starts:
- Next.js Dev Server (port 3000)
- Local Cron Simulator (
scripts/local-cron-simulator.ts)
The cron simulator calls executeGameTick() every 60 seconds, exactly like production Vercel Cron.
Output Example
$ bun run dev
[Next.js] Starting server on http://localhost:3000
[Cron] Game tick started
[Cron] Game tick completed { posts: 15, events: 3, markets: 5 }
[Cron] Next tick in 60 seconds...Production vs Development
| Environment | Mechanism | Function |
|---|---|---|
| Production | Vercel Cron | /api/cron/game-tick → executeGameTick() |
| Development | Local Cron Simulator | executeGameTick() |
Same function, different triggers!
Features
- Automatic - Runs automatically with
bun run dev - Duplicate Prevention - Skips tick if previous still running
- Error Recovery - Logs errors but doesn’t crash
- Real-Time Stats - Shows posts, events, markets updated
- Same as Production - Uses exact same
executeGameTick()function
Troubleshooting
Tick Takes Too Long
Previous tick still running, skipping...Causes:
- Slow LLM API response
- Database latency
- Complex content generation
Solutions:
- Use Groq instead of OpenAGI (faster)
- Check database performance
- Reduce posts per tick in config
No Content Generated
Tick complete { tick: 1, posts: 0, events: 0 }Causes:
- No active game in database
- Game engine not initialized
- API key missing
Solutions:
# Generate initial game
bun run generate
# Check database
bun run db:status
# Verify API keys
echo $GROQ_API_KEYArchitecture
Production (Vercel)
Vercel Cron (every 60s)
↓
/api/cron/game-tick
↓
executeGameTick()
↓
DatabaseDevelopment (Local)
bun run dev
↓
scripts/local-cron-simulator.ts
↓
executeGameTick()
↓
DatabaseKey Point: Same function (executeGameTick()) in both environments!
Development Workflow
Full Stack Development
# Terminal 1: Next.js + game ticker (automatic)
bun run dev
# Terminal 2: Run specific agent scripts as needed
# Agents run automatically via the autonomous coordinator in productionWeb-Only Mode
If you’re only working on frontend and don’t need content generation:
bun run dev:next-onlyTesting Tick Function
# Just start dev server - tick runs automatically
bun run devAdvanced Usage
Custom Tick Interval
Edit scripts/local-cron-simulator.ts:
// Change from 60000 to 30000 (30 seconds)
const TICK_INTERVAL = 30000;Tick Logging
Add custom logging in src/lib/serverless-game-tick.ts:
export async function executeGameTick() {
const start = Date.now();
// ... tick logic ...
const duration = Date.now() - start;
logger.info('Tick performance', { duration, posts, events });
}Integration Testing
# Run with test database
DATABASE_URL=test_db bun run devNext Steps
Last updated on