Best Practices
Best practices for using Scrapybara
Manage instance usage
Instances are billed per usage. When launching an instance, you can specify its timeout before it is automatically terminated (default is 1 hour).
Python
TypeScript
To save costs, pause the instance to resume it later, or stop the instance once you no longer need to control the desktop environment and access its stored data.
Python
TypeScript
Take actions programmatically
When possible, take actions programmatically rather than relying on the agent to do so. For example, using instance.bash()
provides a faster way to launch apps compared to having the model use mouse/keyboard interactions. If you know the agent’s workflow will happen on a specific application, you can launch it before prompting the agent to take actions. The same applies for browser automation: it is often easier to manipulate the browser programmatically with instance.browser
and Playwright than relying on the agent itself.
Initialize the browser
For agents requiring programmatic browser interaction, initialize and configure the browser immediately after instance creation. This ensures the browser environment is ready before any browser tool calls are made.
Python
TypeScript
Optimize your prompt
We recommend using our provided SYSTEM_PROMPT
for most general-purpose computer tasks.
Python
TypeScript
However, it may be suboptimal for any specific use case. Here are some tips from Anthropic to improve the agent’s performance:
- Specify simple, well-defined tasks and provide explicit instructions for each step.
- Claude sometimes assumes outcomes of its actions without explicitly checking their results. To prevent this you can prompt Claude with
After each step, take a screenshot and carefully evaluate if you have achieved the right outcome. Explicitly show your thinking: "I have evaluated step X..." If not correct, try again. Only when you confirm a step was executed correctly should you move on to the next one.
- Some UI elements (like dropdowns and scrollbars) might be tricky for Claude to manipulate using mouse movements. If you experience this, try prompting the model to use keyboard shortcuts.
- For repeatable tasks or UI interactions, include example screenshots and tool calls of successful outcomes in your prompt.
- If you need the model to log in, provide it with the username and password in your prompt inside xml tags like
<robot_credentials>
. Using computer use within applications that require login increases the risk of bad outcomes as a result of prompt injection.