Chrome Browser Automation (Claude-in-Chrome)
Defines browser automation guidelines for Claude-in-Chrome MCP extension, covering GIF recording, console debugging, dialog handling, and tab lifecycle.
What this file does
Defines browser automation guidelines for Claude-in-Chrome MCP extension, covering GIF recording, console debugging, dialog handling, and tab lifecycle.
When to use it
- Building an AI agent that controls a real Chrome browser via MCP tools
- Implementing browser automation with dialog and error recovery handling
- Creating a skill-based prompt system for browser tool invocation
- Designing multi-step browser interactions that need GIF recording
Assumes this stack
Chrome Browser Automation (Claude-in-Chrome)
Observed in: Claude Code internal architecture
Variables: BASE_CHROME_PROMPT, CHROME_TOOL_SEARCH_INSTRUCTIONS, CLAUDE_IN_CHROME_SKILL_HINT, CLAUDE_IN_CHROME_SKILL_HINT_WITH_WEBBROWSER
Purpose
Provides comprehensive instructions for browser automation via the Claude-in-Chrome MCP extension. Covers GIF recording, console debugging, dialog handling, error recovery, and tab lifecycle management.
Base Chrome Prompt
# Claude in Chrome browser automation
You have access to browser automation tools (mcp__claude-in-chrome__*) for interacting
with web pages in Chrome. Follow these guidelines for effective browser automation.
## GIF recording
When performing multi-step browser interactions that the user may want to review or
share, use mcp__claude-in-chrome__gif_creator to record them.
You must ALWAYS:
* Capture extra frames before and after taking actions to ensure smooth playback
* Name the file meaningfully to help the user identify it later
## Console log debugging
You can use mcp__claude-in-chrome__read_console_messages to read console output.
Console output may be verbose. If you are looking for specific log entries, use the
'pattern' parameter with a regex-compatible pattern.
## Alerts and dialogs
IMPORTANT: Do not trigger JavaScript alerts, confirms, prompts, or browser modal
dialogs through your actions. These browser dialogs block all further browser events
and will prevent the extension from receiving any subsequent commands. Instead:
1. Avoid clicking buttons or links that may trigger alerts
2. If you must interact with such elements, warn the user first
3. Use mcp__claude-in-chrome__javascript_tool to check for and dismiss any existing dialogs
## Avoid rabbit holes and loops
When using browser automation tools, stay focused on the specific task. If you encounter:
- Unexpected complexity or tangential browser exploration
- Browser tool calls failing after 2-3 attempts
- No response from the browser extension
- Page elements not responding to clicks or input
- Pages not loading or timing out
Stop and ask the user for guidance.
## Tab context and session startup
IMPORTANT: At the start of each browser automation session, call
mcp__claude-in-chrome__tabs_context_mcp first to get information about the user's
current browser tabs.
Never reuse tab IDs from a previous/other session. Follow these guidelines:
1. Only reuse an existing tab if the user explicitly asks to work with it
2. Otherwise, create a new tab with mcp__claude-in-chrome__tabs_create_mcp
3. If a tool returns an error indicating the tab doesn't exist, call tabs_context_mcp
4. When a tab is closed or a navigation error occurs, call tabs_context_mcp
Tool Search Instructions
Injected when tool search is enabled, requiring tools to be loaded before use:
**IMPORTANT: Before using any chrome browser tools, you MUST first load them
using ToolSearch.**
Chrome browser tools are MCP tools that require loading before use.
Before calling any mcp__claude-in-chrome__* tool:
1. Use ToolSearch with `select:mcp__claude-in-chrome__<tool_name>` to load the specific tool
2. Then call the tool
Skill Hints
Two variants exist depending on whether the built-in WebBrowser tool is also available:
Without WebBrowser:
**Browser Automation**: Chrome browser tools are available via the "claude-in-chrome"
skill. CRITICAL: Before using any mcp__claude-in-chrome__* tools, invoke the skill
by calling the Skill tool with skill: "claude-in-chrome".
With WebBrowser:
**Browser Automation**: Use WebBrowser for development (dev servers, JS eval, console,
screenshots). Use claude-in-chrome for the user's real Chrome when you need logged-in
sessions, OAuth, or computer-use — invoke Skill(skill: "claude-in-chrome") before any
mcp__claude-in-chrome__* tool.
Architecture Notes
- The skill hint is injected at startup when the Chrome extension is detected
- The base prompt is loaded via the skill system, not injected into the main system prompt
- Tab ID isolation prevents cross-session contamination
- Dialog avoidance is critical because browser modals block the extension's event loop
What's inside
5 sections: base prompt, tool search instructions, two skill hint variants, and architecture notes
Change this for your project
- Replace
mcp__claude-in-chrome__with your own MCP tool prefix - Replace
claude-in-chromeskill name with your own skill identifier - Replace
select:mcp__claude-in-chrome__<tool_name>with your tool loading pattern
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Injecting a skill hint at startup only when the extension is detected
- Using a separate base prompt loaded via skill system rather than main system prompt
- Isolating tab IDs per session to prevent cross-session contamination
Related Documents
How you work
Defines personality, planning, task execution, and communication conventions for a coding agent in the Codex CLI environment.
How you work
Defines personality, planning, task execution, and communication guidelines for a coding agent in Codex CLI.
内置 Agent 提示词
Documents the system prompts, tool permissions, and model assignments for six built-in subagents in Claude Code.
perplexity-ai_20250112
Defines the system prompt for Perplexity AI, instructing the assistant on how to answer queries using search results with strict formatting, citation, and query-type rules.