|
| 1 | +--- |
| 2 | +name: webcli |
| 3 | +description: Browse the web, scrape pages, fill forms, click buttons, and take screenshots using the webcli headless browser. Use when the user asks to visit a website, gather information from a web page, interact with a web app, log into a site, or take a screenshot. |
| 4 | +allowed-tools: Bash(webcli *) |
| 5 | +--- |
| 6 | + |
| 7 | +# webcli — Headless Browser CLI |
| 8 | + |
| 9 | +You have access to a headless browser via the `webcli` command. Use it to navigate websites, read content, interact with elements, and take screenshots. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +Install webcli globally before using this skill: |
| 14 | +```bash |
| 15 | +npm install -g @erdinccurebal/webcli |
| 16 | +npx playwright install chromium |
| 17 | +``` |
| 18 | + |
| 19 | +## Architecture |
| 20 | + |
| 21 | +webcli runs a background daemon that keeps a real Chromium browser open. Commands are instant — no browser startup overhead. The daemon auto-starts on the first command and shuts down after 5 minutes of inactivity. |
| 22 | + |
| 23 | +## Commands Reference |
| 24 | + |
| 25 | +### Navigation |
| 26 | +```bash |
| 27 | +webcli go <url> # Navigate to URL (auto-starts daemon) |
| 28 | +webcli go <url> -w networkidle # Wait for network to settle |
| 29 | +webcli go <url> -t mytab # Open in named tab |
| 30 | +webcli back # Go back in history |
| 31 | +webcli forward # Go forward |
| 32 | +webcli reload # Reload current page |
| 33 | +``` |
| 34 | + |
| 35 | +### Reading Page Content |
| 36 | +```bash |
| 37 | +webcli source # Get full visible text of the page |
| 38 | +webcli links # List all links (text + href) |
| 39 | +webcli forms # List all forms with their inputs |
| 40 | +webcli html <selector> # Get innerHTML of element |
| 41 | +webcli attr <selector> <attribute> # Get element attribute value |
| 42 | +webcli eval <js> # Execute JavaScript, return result |
| 43 | +``` |
| 44 | + |
| 45 | +### Interaction |
| 46 | +```bash |
| 47 | +webcli click "<visible text>" # Click element by visible text |
| 48 | +webcli clicksel "<css selector>" # Click element by CSS selector |
| 49 | +webcli fill "<selector>" "<value>" # Fill an input field (preferred for forms) |
| 50 | +webcli type "<text>" # Type with keyboard (for focused element) |
| 51 | +webcli select "<selector>" "<val>" # Select dropdown option |
| 52 | +webcli press Enter # Press keyboard key (Enter, Tab, Escape...) |
| 53 | +webcli focus "<selector>" # Focus an element |
| 54 | +``` |
| 55 | +
|
| 56 | +### Waiting |
| 57 | +```bash |
| 58 | +webcli wait "<selector>" # Wait for CSS selector to be visible |
| 59 | +webcli waitfor "<text>" # Wait for text to appear on page |
| 60 | +webcli sleep 2000 # Sleep for N milliseconds |
| 61 | +``` |
| 62 | +
|
| 63 | +### Screenshots |
| 64 | +```bash |
| 65 | +webcli screenshot # Take screenshot (returns path) |
| 66 | +webcli screenshot -o page.png # Save to specific file |
| 67 | +``` |
| 68 | +
|
| 69 | +### Cookies & Browser |
| 70 | +```bash |
| 71 | +webcli cookie export # Export cookies as JSON |
| 72 | +webcli cookie import <file> # Import cookies from JSON file |
| 73 | +webcli viewport 1920 1080 # Change viewport size |
| 74 | +webcli useragent "<string>" # Change user agent |
| 75 | +webcli network on # Enable network request logging |
| 76 | +webcli network off # Disable network logging |
| 77 | +webcli network # Show captured network logs |
| 78 | +``` |
| 79 | +
|
| 80 | +### Tab & Daemon Management |
| 81 | +```bash |
| 82 | +webcli tabs # List open tabs |
| 83 | +webcli quit # Close current tab |
| 84 | +webcli quit -t mytab # Close specific tab |
| 85 | +webcli status # Show daemon info (PID, uptime, tabs) |
| 86 | +webcli stop # Stop daemon and close browser |
| 87 | +``` |
| 88 | +
|
| 89 | +### Global Options |
| 90 | +All commands support: |
| 91 | +- `-t, --tab <name>` — target a specific tab (default: "default") |
| 92 | +- `--json` — output as structured JSON |
| 93 | +- `--timeout <ms>` — command timeout (default: 30000) |
| 94 | +
|
| 95 | +## Best Practices |
| 96 | +
|
| 97 | +### General workflow |
| 98 | +1. `webcli go <url>` to navigate |
| 99 | +2. `webcli source` to read the page content |
| 100 | +3. Use `webcli click`, `webcli fill`, `webcli press` to interact |
| 101 | +4. `webcli source` again to see the result |
| 102 | +5. `webcli screenshot` if user wants visual confirmation |
| 103 | +
|
| 104 | +### Form filling |
| 105 | +- Always use `webcli fill` for input fields — it properly sets React/Vue controlled inputs |
| 106 | +- Use `webcli click` or `webcli clicksel` for buttons |
| 107 | +- Use `webcli press Enter` to submit forms |
| 108 | +- After submitting, use `webcli sleep 1000` then `webcli source` to check the result |
| 109 | +
|
| 110 | +### Multi-tab browsing |
| 111 | +```bash |
| 112 | +webcli go https://site-a.com -t research |
| 113 | +webcli go https://site-b.com -t reference |
| 114 | +webcli source -t research # Read from specific tab |
| 115 | +webcli source -t reference |
| 116 | +``` |
| 117 | +
|
| 118 | +### Handling bot-protected sites |
| 119 | +If a site blocks the headless browser, the user should set headed mode in `~/.webcli/config.json`: |
| 120 | +```json |
| 121 | +{ |
| 122 | + "headless": false, |
| 123 | + "userDataDir": "~/.webcli/browser-data" |
| 124 | +} |
| 125 | +``` |
| 126 | +
|
| 127 | +### Debugging page issues |
| 128 | +```bash |
| 129 | +webcli forms # See available form fields |
| 130 | +webcli links # See all clickable links |
| 131 | +webcli eval "document.title" # Run JS to inspect the page |
| 132 | +webcli html "body" # Get raw HTML of an element |
| 133 | +webcli network on # Monitor network requests |
| 134 | +``` |
| 135 | +
|
| 136 | +### Error recovery |
| 137 | +- If a command times out, try `webcli sleep 2000` then retry |
| 138 | +- If an element is not found, use `webcli source` to check what's on the page |
| 139 | +- If the daemon seems stuck, use `webcli stop` then retry the command |
| 140 | +- Use `webcli wait "<selector>"` before interacting with dynamically loaded content |
| 141 | +
|
| 142 | +## Important Notes |
| 143 | +- Always read the page with `webcli source` before trying to interact — understand what's on the page first |
| 144 | +- Prefer `webcli fill` over `webcli type` for form inputs |
| 145 | +- Prefer `webcli click` (by text) over `webcli clicksel` (by selector) when possible — it's more robust |
| 146 | +- Use `webcli sleep` between rapid interactions to let pages update |
| 147 | +- The daemon persists between commands — no need to re-navigate unless the page changes |
0 commit comments