Credentials. The persisted browser-data folder holds live session cookies; store it like a password and keep it out of version control.
Who it is forSomeone automating a dull task inside a web app they log into, like downloading monthly invoices.
The problemLetting an AI agent type your password means the credentials pass through the model.
The outcomeA script that signs in once, keeps the session in ./browser-data and repeats the task on later runs.
What you need first
- Node with pnpm, Python, or Go
- Chrome installed for local runs
- A model API key such as OPENAI_API_KEY, or a Browserbase API key to use the Model Gateway
Steps
- Install Stagehand and make sure Chrome is installed locally
- Launch the local browser with a userDataDir such as ./browser-data so cookies persist between runs
- Call Stagehand.observe to find the email and password inputs, then fill them from environment variables with page.locator; observe returns real selectors, so credentials never reach the model
- Use Stagehand.act for steps like click the sign in button and open the billing page
- Run it again later: the next run starts already signed in
Prompt for your agent
Build a browserbase/stagehand script for <web app> that signs in using observe plus locator fill with credentials from environment variables, keeps the session in ./browser-data, then uses act to <task steps> and extract to save <data>. Never pass the password to the model.
Caveat. Automating a site you log into may break its terms of service, so check before running it on a schedule.
Use this in your AI agent
Ask your agent
Using the Deduped MCP, get the setup steps for browserbase/stagehand and "Automate a logged-in workflow without giving the model your password"
Add Deduped to Claude Code once
claude mcp add --transport http deduped https://dedupedai.com/mcp
Every Monday: the 5 hottest repos and exactly how to use them. Free, one email a week, unsubscribe anytime.
Get them freeShare: X LinkedIn Hacker News Email Copy link
Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer