This document contains precise instructions for Claude on how to use the screenshot automation tool for fully automated frontend UI development.
-
Install dependencies:
cd /home/rodrigo/agentic/_debug npm install -
Make screenshot script executable:
chmod +x /home/rodrigo/agentic/_debug/screenshot.js
Before making ANY changes to the UI, ALWAYS take a screenshot first to understand the current state:
node /home/rodrigo/agentic/_debug/screenshot.js http://localhost:3000/agents/MainConversationThen READ the screenshot using the Read tool to analyze the current UI state.
After understanding the current state:
- Use Edit tool to make changes to React components
- The dev server (running on localhost:3000) will auto-reload
- Wait 2-3 seconds for the changes to take effect
After making changes, ALWAYS take a new screenshot to verify:
node /home/rodrigo/agentic/_debug/screenshot.js http://localhost:3000/agents/MainConversation /home/rodrigo/agentic/_debug/screenshots/after-change-$(date +%s).png 3000Then READ the new screenshot to verify your changes worked as expected.
Compare the before/after screenshots:
- If changes look correct: proceed to next task
- If issues found: make corrections and repeat Phase 2-3
node screenshot.js [URL] [OUTPUT_PATH] [WAIT_TIME_MS]URL: Target URL (default: http://localhost:3000)OUTPUT_PATH: Where to save screenshot (default: screenshots/screenshot-{timestamp}.png)WAIT_TIME_MS: Wait time in milliseconds for dynamic content (default: 1000)
Screenshot main page:
node /home/rodrigo/agentic/_debug/screenshot.js http://localhost:3000Screenshot specific route with custom wait:
node /home/rodrigo/agentic/_debug/screenshot.js http://localhost:3000/agents/MainConversation /home/rodrigo/agentic/_debug/screenshots/main-conversation.png 2000Screenshot after making changes (longer wait for re-render):
node /home/rodrigo/agentic/_debug/screenshot.js http://localhost:3000/agents/MainConversation /home/rodrigo/agentic/_debug/screenshots/after-refactor.png 3000Never make UI changes without visual verification. This prevents:
- Breaking existing layouts
- Introducing visual regressions
- Missing CSS/styling issues
# Good
/home/rodrigo/agentic/_debug/screenshots/before-refactor-agent-dashboard.png
/home/rodrigo/agentic/_debug/screenshots/after-refactor-agent-dashboard.png
# Bad
/home/rodrigo/agentic/_debug/screenshots/screenshot1.png- Initial page load: 1000-2000ms
- After code changes (hot reload): 2000-3000ms
- Complex animations/transitions: 3000-5000ms
After taking a screenshot, ALWAYS use the Read tool to analyze it before proceeding.
Task: Refactor the AgentDashboard component
# Step 1: Take "before" screenshot
node /home/rodrigo/agentic/_debug/screenshot.js http://localhost:3000/agents/MainConversation /home/rodrigo/agentic/_debug/screenshots/before-dashboard-refactor.png 2000Step 2: Read the screenshot
Read tool: /home/rodrigo/agentic/_debug/screenshots/before-dashboard-refactor.png
Step 3: Make code changes
Edit tool: /home/rodrigo/agentic/frontend/src/components/AgentDashboard.js
(make refactoring changes)
Step 4: Wait for hot reload (3 seconds for safety)
sleep 3Step 5: Take "after" screenshot
node /home/rodrigo/agentic/_debug/screenshot.js http://localhost:3000/agents/MainConversation /home/rodrigo/agentic/_debug/screenshots/after-dashboard-refactor.png 3000Step 6: Read and compare
Read tool: /home/rodrigo/agentic/_debug/screenshots/after-dashboard-refactor.png
Step 7: Verify changes
- Compare before/after screenshots
- Check that layout is preserved
- Verify no visual regressions
- Confirm refactoring goals achieved
- Increase wait time (try 5000ms)
- Check that the dev server is running on the correct port
- Verify the URL is correct
- Increase wait time to allow hot reload to complete
- Check for console errors in the frontend
- Verify the file was actually saved
- Install required dependencies:
sudo apt-get install -y chromium-browser - Or use bundled Chromium that comes with Puppeteer
When working on UI tasks, structure todos like this:
- "Take before screenshot of current UI" (status: pending)
- "Refactor AgentDashboard component" (status: pending)
- "Take after screenshot to verify changes" (status: pending)
- "Compare screenshots and verify no regressions" (status: pending)
Mark each as in_progress → completed as you go through the workflow.
- Screenshot script:
/home/rodrigo/agentic/_debug/screenshot.js - Screenshots directory:
/home/rodrigo/agentic/_debug/screenshots/ - This guide:
/home/rodrigo/agentic/_debug/AUTOMATED_UI_DEVELOPMENT.md
- Always use absolute paths in commands
- Name screenshots descriptively with context about what changed
- Keep screenshots for the duration of the refactoring session
- Clean up old screenshots periodically to save space
- Take screenshots at key stages not just before/after
- Use consistent wait times for the same page (predictable results)
- Read screenshots immediately after taking them to provide context
- You have the Read tool that can analyze images/screenshots
- After taking a screenshot with Bash, immediately Read it
- Use the visual information to guide your next edits
- If something looks wrong in the screenshot, fix it before proceeding
- Keep the user informed about what you see in each screenshot
- This enables truly autonomous frontend development without user intervention