Skip to main content
Version: Latest

Running the Claude Automator

Build and Runโ€‹

Using Gradleโ€‹

# Clean and build
./gradlew clean build

# Run the application
./gradlew bootRun

Using IDEโ€‹

  1. Open the project in IntelliJ IDEA or Eclipse
  2. Run ClaudeAutomatorApplication.java as a Spring Boot application
  3. Watch the console for log output

Expected Console Outputโ€‹

INFO  c.c.a.ClaudeAutomatorApplication - Starting ClaudeAutomatorApplication
INFO i.g.j.b.startup.AutoStartupVerifier - === Brobot Auto Startup Verification: Phase 1 (Images) ===
INFO i.g.j.b.startup.ApplicationStartupVerifier - Discovered 7 images from 2 states
INFO i.g.j.b.startup.ApplicationStartupVerifier - All 7 required images verified successfully
INFO c.c.a.config.StateRegistrationListener - Application ready - registering states with StateService
INFO c.c.a.config.StateRegistrationListener - States and transitions registered successfully
INFO i.g.j.b.startup.AutoStartupVerifier - === Brobot Auto Startup Verification: Phase 2 (States) ===
INFO i.g.j.b.startup.ApplicationStartupVerifier - Successfully verified expected states. Active states: [PROMPT]
INFO c.c.a.automation.ClaudeMonitoringAutomation - Starting Claude monitoring automation
INFO c.c.a.ClaudeAutomatorApplication - Started ClaudeAutomatorApplication in 3.456 seconds

Testing the Automationโ€‹

1. Initial Stateโ€‹

  • The auto-verifier detects which state is currently visible
  • Open Claude AI in your browser before starting the app
  • The automation will automatically set the correct initial state

2. Trigger Transitionโ€‹

  • The automation will find and click the prompt
  • Type "continue" and press Enter
  • Both Prompt and Working states become active

3. Monitor Working Stateโ€‹

  • The automation checks every 2 seconds for Claude's icon
  • When Claude finishes responding (icon disappears):
    • Working state is removed from active states
    • Working state is reopened to wait for the next response

4. Continuous Operationโ€‹

  • The cycle continues indefinitely
  • Monitor the logs to see the automation in action

Debugging Tipsโ€‹

Enable Debug Loggingโ€‹

Add to application.properties:

logging.level.com.claude.automator=DEBUG
logging.level.io.github.jspinak.brobot=DEBUG

Visual Debuggingโ€‹

Enable Sikuli highlighting:

brobot.sikuli.highlight=true
brobot.sikuli.highlight.duration=2

Common Issues and Solutionsโ€‹

Images Not Foundโ€‹

ERROR - Failed to load required image: prompt/claude-prompt-1.png
ERROR - Suggestion: Check if file exists at: /path/to/images/prompt/claude-prompt-1.png
ERROR - Suggestion: Verify image format is supported (PNG, JPG, JPEG, GIF, BMP)

Solution:

  • The auto-verifier provides specific suggestions
  • Check the exact path shown in the error
  • Verify image format and accessibility
  • Add fallback paths in application.yml if needed

State Not Activatingโ€‹

ERROR - Failed to activate Working state

Solution:

  • Check transition logic
  • Verify state registration
  • Review logs for transition failures

Monitoring Not Workingโ€‹

DEBUG - Working state is not active, skipping check

Solution:

  • Ensure Working state is properly activated
  • Check StateMemory for active states
  • Verify transition completion

Performance Tuningโ€‹

Adjust Monitoring Frequencyโ€‹

// In ClaudeMonitoringAutomation
scheduler.scheduleWithFixedDelay(
this::checkClaudeIconStatus,
5, // Initial delay - increase for slower startup
1, // Check interval - decrease for faster response
TimeUnit.SECONDS
);
// Use search regions to improve performance
PatternFindOptions optimizedFind = new PatternFindOptions.Builder()
.setSearchRegion(new Region(100, 100, 400, 300)) // Limit search area
.setSimilarity(0.9) // Adjust for accuracy vs speed
.build();

Production Considerationsโ€‹

1. Error Recoveryโ€‹

@Component
public class ErrorRecoveryService {
@EventListener
public void handleAutomationError(AutomationErrorEvent event) {
log.error("Automation error: {}", event.getMessage());
// Implement recovery logic
}
}

2. Metrics and Monitoringโ€‹

@Component
public class AutomationMetrics {
private final MeterRegistry meterRegistry;

public void recordTransitionSuccess(String fromState, String toState) {
meterRegistry.counter("transitions.success",
"from", fromState,
"to", toState).increment();
}
}

3. Graceful Shutdownโ€‹

@PreDestroy
public void cleanup() {
log.info("Shutting down Claude Automator");
// Save state, cleanup resources
}

Next Stepsโ€‹

Congratulations! You've built a complete Brobot automation using modern patterns. Consider:

  1. Extending the automation with more states and complex workflows
  2. Adding configuration UI using Brobot's desktop runner
  3. Creating tests using Brobot's mock capabilities
  4. Contributing improvements back to the Brobot library

Summaryโ€‹

This tutorial demonstrated:

  • โœ… Modern state patterns with direct component access
  • โœ… JavaStateTransition for flexible navigation
  • โœ… Fluent API and action chaining
  • โœ… Spring Boot integration
  • โœ… Continuous monitoring patterns
  • โœ… Enhanced developer experience features

The complete source code serves as a template for building robust, maintainable automations with Brobot v1.1.0.