You’re likely using AI to write code, and there’s a right and wrong way to do it. This page is a collection of rules, configs, and copy‑paste snippets to allow your AI agents/assistants to write performant, Stagehand code as fast as possible.

Quickstart

Add MCP servers

Configure Browserbase (Stagehand), Context7, DeepWiki, and Stagehand Docs in your MCP client.

Pin editor rules

Drop in cursorrules and claude.md so AI agents/assistants always emit Stagehand patterns.

Using MCP Servers

MCP (Model Context Protocol) servers act as intermediaries that connect AI systems to external data sources and tools. These servers enable your coding assistant to access real-time information, execute tasks, and retrieve structured data to enhance code generation accuracy. The following MCP servers provide specialized access to Stagehand documentation and related resources:
How MCP Servers Enhance Your Development:
  • Real-time Documentation Access: AI assistants can query the latest Stagehand docs, examples, and best practices
  • Context-Aware Code Generation: Servers provide relevant code patterns and configurations based on your specific use case
  • Reduced Integration Overhead: Standardized protocol eliminates the need for custom integrations with each documentation source
  • Enhanced Accuracy: AI agents receive structured, up-to-date information rather than relying on potentially outdated training data
Prompting tip: Explicitly ask your coding agent/assistant to use these MCP servers to fetch relevant information from the docs so they have better context and know how to write proper Stagehand code.ie. “Use the stagehand-docs MCP to fetch the act/observe guidelines, then generate code that follows them. Prefer cached observe results.”

Editor rule files (copy‑paste)

Drop these in .cursorrules, windsurfrules, claude.md, or any agent rule framework:

Security notes

  • Do not embed secrets in docs or rule files; use env vars in MCP configs.
  • Avoid broad actions that may trigger unintended navigation; prefer observe first.

Resources/references