- Node.js: 18+ (recommended: 20+)
- npm: 9+ (comes with Node.js)
- Wrangler CLI:
npm install -g wrangler - Cloudflare Account: For AI bindings and deployment
- GitHub Account: For OAuth (development)
git clone <repository-url>
cd taskmaster-dnd# Install agent dependencies
cd agent
npm install
# Install frontend dependencies
cd ../frontend
npm installCreate agent/.dev.vars:
AUTH_SECRET=your-secret-hereGenerate secret:
openssl rand -base64 32Create frontend/.env.local:
AGENT_URL=http://localhost:8787
NEXTAUTH_SECRET=your-secret-here
NEXTAUTH_URL=http://localhost:3000
GITHUB_CLIENT_ID=your-github-client-id
GITHUB_CLIENT_SECRET=your-github-client-secretNote: AUTH_SECRET and NEXTAUTH_SECRET should be the same value.
- Go to GitHub Settings → Developer settings → OAuth Apps
- Create a new OAuth App
- Set Authorization callback URL:
http://localhost:3000/api/auth/callback/github - Copy Client ID and Client Secret
- Go to Cloudflare Dashboard → Workers & Pages
- Select your account
- Go to Settings → Bindings → AI
- Add AI binding (if not already configured)
cd agent
npm run devAgent runs at http://localhost:8787
In a separate terminal:
cd frontend
npm run devFrontend runs at http://localhost:3000
Agent:
src/agent.ts- Main agent classsrc/handlers/- Request handlerssrc/utils/- Utility functionssrc/types.ts- TypeScript types
Frontend:
src/app/- Next.js pages and API routessrc/components/- React componentssrc/hooks/- Custom hookssrc/lib/- Library utilitiessrc/utils/- Helper functions
- Edit Code: Make your changes
- Test Locally: Both services auto-reload
- Run Tests:
npm test(agent) ornpm run build(frontend) - Commit: Follow conventional commits
- Deploy: See deployment guide
cd agent
# Unit tests
npm test
# Manual tests
npm run test:agent
npm run test:timingcd frontend
# Build check
npm run build
# Type check
npx tsc --noEmit- Check Wrangler logs in terminal
- Use
logger.debug()for detailed logs - Check
.wrangler/directory for local state
- Use browser DevTools
- Check Network tab for API calls
- Use React DevTools for component state
- Check server logs in terminal
- Check
AUTH_SECRETis set in.dev.vars - Verify Cloudflare AI binding is configured
- Check Wrangler version:
wrangler --version
- Verify agent is running on port 8787
- Check
AGENT_URLin.env.local - Check CORS settings (should allow localhost)
- Verify
AUTH_SECRETmatchesNEXTAUTH_SECRET - Check GitHub OAuth callback URL
- Clear browser cookies/session
- Clear
.wranglerdirectory:rm -rf .wrangler - Restart dev server
- Check migrations in
wrangler.jsonc
- Use strict mode
- Prefer interfaces over types
- Use explicit return types for functions
- Avoid
anytype
- Use functional components
- Prefer hooks over class components
- Use
useCallbackanduseMemofor optimization - Keep components small and focused
- Files: camelCase for utilities, PascalCase for components
- Variables: camelCase
- Constants: UPPER_SNAKE_CASE
- Types/Interfaces: PascalCase
- Use JSDoc for functions
- Explain "why" not "what"
- Keep comments up to date
main- Production-ready codedevelop- Development branch (if used)- Feature branches:
feature/description - Bug fixes:
fix/description
Use conventional commits:
feat: add search functionality
fix: resolve task expiration bug
docs: update API documentation
refactor: simplify task operations
test: add timing validation tests
- Clear title and description
- Link related issues
- Request review before merging
- Ensure tests pass
- Lazy Loading: Use for modals and heavy components
- Memoization: Memoize expensive computations
- Debouncing: Debounce search and auto-save
- Caching: Use HTTP caching headers
- Streaming: Stream responses for better UX
- Efficient State: Minimize state updates
- Alarm Scheduling: Efficient task cleanup
- Tool Execution: Keep tools fast
- Never commit secrets: Use
.dev.varsand.env.local - Validate input: Always validate on server
- Sanitize output: Prevent XSS attacks
- Use HTTPS: Always in production
- Rate limiting: Protect against abuse
- Authentication: Validate all requests
- Define tool in
agent/src/tools.ts - Implement function in
agent/src/agent.ts - Update system prompt if needed
- Add tests
- Update documentation
- Create page in
frontend/src/app/ - Add route to navigation (if needed)
- Add skeleton loading state
- Update types if needed
- Test thoroughly
- Add handler in
agent/src/handlers/ - Add route in
agent/src/index.ts - Add frontend proxy route (if needed)
- Add authentication/rate limiting
- Add tests
- Update API documentation
Agent:
cd agent
npm install <package>Frontend:
cd frontend
npm install <package>npm update
npm audit fixnpm uninstall <package># Find process using port
lsof -i :8787 # Agent
lsof -i :3000 # Frontend
# Kill process
kill -9 <PID>- Clear
node_modulesand reinstall - Check
package.jsonversions - Verify import paths
- Run
npx tsc --noEmitto check types - Check
tsconfig.jsonsettings - Verify type definitions are installed
- Clear
.nextdirectory:rm -rf .next - Clear
.wranglerdirectory:rm -rf .wrangler - Reinstall dependencies
- Check Node.js version
- Check existing documentation
- Search GitHub issues
- Check Cloudflare Workers community
- Review code comments
- Ask in team chat (if applicable)
QuestMaster was developed with the assistance of AI coding assistants. Feel free to use AI tools (like Cursor, GitHub Copilot, etc.) when working on this project. The AI Agent Guide provides comprehensive guidance for AI assistants working with this codebase.