feat(browser): add site memory for persistent cross-session knowledge#69
feat(browser): add site memory for persistent cross-session knowledge#69
Conversation
…owledge
Adds a site memory protocol to the browser skill that maintains persistent
knowledge files at ${CLAUDE_SKILL_DIR}/memory/<domain>.md. On repeat visits,
Claude reads cached selectors and uses them directly instead of snapshotting,
significantly reducing latency and token usage.
Key changes:
- allowed-tools: added Read, Write, Edit, Glob for memory file access
- Step 1 (setup): combined CLI check + memory read into single init block
- Step 3 (save): mandatory memory write after every browsing task
- Workflow restructured as Step 1/2/3 to enforce memory read/write protocol
- Best practices updated to prioritize memory over snapshot
- Troubleshooting: added cached selector failure recovery
Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Memory feature uses CSS selectors with ref-only click command
- Updated the browser skill memory guidance and example so cached CSS selectors are used only with selector-based commands while
browse clickexplicitly requires snapshot refs.
- Updated the browser skill memory guidance and example so cached CSS selectors are used only with selector-based commands while
Or push these changes by commenting:
@cursor push d75a9f3a40
Preview (d75a9f3a40)
diff --git a/skills/browser/SKILL.md b/skills/browser/SKILL.md
--- a/skills/browser/SKILL.md
+++ b/skills/browser/SKILL.md
@@ -33,15 +33,15 @@
Replace MEMORY_FILE with the domain, using dashes for dots/colons/slashes (e.g., `news-ycombinator-com`, `github-com`, `localhost-3000`).
-**If site memory exists**: You have selectors from previous visits. After `browse open`, use them IMMEDIATELY. Do NOT run `browse snapshot`. Example:
+**If site memory exists**: You have selectors from previous visits. After `browse open`, use them IMMEDIATELY for selector-based commands. If you need to click, run `browse snapshot` first to get refs. Example:
```bash
# Memory says story titles use ".titleline > a" — use it directly:
browse open https://news.ycombinator.com
-browse click ".titleline > a" # ← use cached selector, NO snapshot
+browse get text ".titleline > a" # ← use cached selector, NO snapshot-Only run browse snapshot if a cached selector FAILS (returns an error). Trust the memory.
+Run browse snapshot when you need click refs or if a cached selector fails (returns an error). Trust the memory.
If no memory exists: After browse open, use browse snapshot to discover the page.
@@ -151,7 +151,7 @@
Rules for memory files:
-- Record **stable selectors**: `input[name="email"]`, `[data-testid="..."]`, `button[type="submit"]` — NOT just snapshot refs like `@0-5`
+- Record **stable selectors** for selector-based commands (`get`, `fill`, `is`, `highlight`): `input[name="email"]`, `[data-testid="..."]`, `button[type="submit"]` — NOT just snapshot refs like `@0-5`
- Use **URL patterns**: `/users/:id` not `/users/123` when pages share structure
- Note **async behavior**: "table loads after ~2s", "button disabled until form valid"
- Be **generous**: record all interactive elements, not just the ones you used
@@ -163,8 +163,8 @@
1. **Read site memory** (MANDATORY): `cat ${CLAUDE_SKILL_DIR}/memory/<domain>.md`
2. `browse open <url>` — navigate to the page
-3. If memory had selectors, use them directly. Otherwise: `browse snapshot`
-4. Interact: `browse click` / `browse type` / `browse fill`
+3. If memory had selectors, use them directly for selector-based commands. If you need to click (or have no memory): `browse snapshot`
+4. Interact: `browse click` (ref from snapshot) / `browse type` / `browse fill`
5. `browse snapshot` to confirm (if needed)
6. Repeat 3-5
7. **Write site memory** (MANDATORY): update `${CLAUDE_SKILL_DIR}/memory/<domain>.md`
@@ -208,7 +208,7 @@
1. **ALWAYS read site memory before browsing** — this is not optional
2. **ALWAYS write site memory after browsing** — this is not optional
3. **Choose the local strategy deliberately**: `browse env local` for clean state, `--auto-connect` for existing credentials, `remote` for protected sites
-4. **Use `browse snapshot`** only when no memory exists or cached selectors fail
+4. **Use `browse snapshot`** when no memory exists, when cached selectors fail, or when you need refs for `browse click`
5. **Only screenshot when visual context is needed** (layout checks, images, debugging)
6. **Use refs from snapshot** to click/interact — e.g., `browse click @0-5`
7. **`browse stop`** when done to clean up the browser session and clear the env override
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.
Reviewed by Cursor Bugbot for commit efee8bf. Configure here.
| ```bash | ||
| # Memory says story titles use ".titleline > a" — use it directly: | ||
| browse open https://news.ycombinator.com | ||
| browse click ".titleline > a" # ← use cached selector, NO snapshot |
There was a problem hiding this comment.
Memory feature uses CSS selectors with ref-only click command
High Severity
The memory feature's core optimization — caching CSS selectors and using them directly to skip snapshots — is built on the assumption that browse click accepts CSS selectors. However, per the REFERENCE.md and every example in EXAMPLES.md, browse click only accepts snapshot refs (e.g., @0-5), not CSS selectors. The example browse click ".titleline > a" will fail. The memory system instructs recording "stable selectors" like input[name="email"] and [data-testid="..."], but these cannot be used with the primary interaction command.
Additional Locations (2)
Reviewed by Cursor Bugbot for commit efee8bf. Configure here.



Summary
${CLAUDE_SKILL_DIR}/memory/<domain>.mdand uses them directly — skipping thebrowse snapshotstep entirely~/.claude/skills/browser/memory/), making them global across projects with no permission issuesHow it works
browse click ".titleline > a") without snapshottingbrowse snapshotas usualKey changes to SKILL.md
allowed-tools:Bash→Bash Read Write Edit Glob(needed for memory file I/O)Why this matters
Every
browse snapshotcall costs ~200ms CDP + 2-5s LLM reasoning about the page tree. With site memory, repeat visits can skip both — Claude already knows the selectors. This is especially impactful for:Test plan
~/.claude/skills/browser/memory/<domain>.md🤖 Generated with Claude Code
Note
Medium Risk
Primarily updates the browser skill documentation/workflow, but it also expands
allowed-toolsto include filesystem read/write/edit/glob access, which increases the blast radius if misused.Overview
Adds a site memory workflow to the
browserskill instructions: a mandatory pre-flight step to check${CLAUDE_SKILL_DIR}/memory/<domain>.md, preferentially use cached selectors to avoidbrowse snapshot, and a mandatory post-task step to write/update per-domain memory files with stable selectors and interaction patterns.Updates the recommended browsing workflow/examples and troubleshooting to reflect the new memory-first behavior, and expands
allowed-toolsfromBashtoBash Read Write Edit Globto support maintaining these memory files.Reviewed by Cursor Bugbot for commit efee8bf. Bugbot is set up for automated code reviews on this repo. Configure here.