Practical Tutorials#16
OpenClaw Local Development Workflow Best Practices
Best practices for OpenClaw project development, debugging, and testing.
9 min read•2026-02-10
developmentdebuggingtesting
Development Environment Setup
Recommended Structure
openclaw-project/
├── .env.development # Dev environment vars
├── .env.production # Prod environment vars
├── config/
│ ├── development.js
│ └── production.js
├── workspace/
│ ├── AGENTS.md
│ ├── SOUL.md
│ └── TOOLS.md
├── tests/
│ ├── unit/
│ └── integration/
└── logs/
Environment Configuration
# .env.development
NODE_ENV=development
LOG_LEVEL=debug
LLM_MODEL=gpt-4-turbo-preview
DRY_RUN=true # Don't execute real actions
# Mock services for development
MOCK_EMAIL=true
MOCK_CALENDAR=true
Debugging Techniques
Verbose Logging
// Enable detailed logging
{
logging: {
level: 'debug',
includeContext: true,
includeToolCalls: true,
includeResponses: true
}
}
Conversation Replay
// Save conversations for replay
await agent.saveConversation('./debug/session.json');
// Replay later
await agent.replayConversation('./debug/session.json');
Testing Strategies
Unit Tests
describe('Email Tool', () => {
it('should format email correctly', async () => {
const result = await emailTool.execute({
to: '[email protected]',
subject: 'Test',
body: 'Hello'
});
expect(result.formatted).toContain('To: [email protected]');
});
});
Integration Tests
describe('Full Workflow', () => {
it('should complete email workflow', async () => {
const agent = createTestAgent();
const result = await agent.run('Send a test email');
expect(result.toolsUsed).toContain('email_send');
});
});
Hot Reloading
// Watch for bootstrap file changes
npm run dev -- --watch-bootstrap
// Changes to AGENTS.md, SOUL.md reload automatically
Conclusion
Good development practices make building and debugging OpenClaw agents much more efficient.