Skip to content
Automation
Agent

code-generator

Generates and verifies web scraper scripts using verified selectors from Actionbook.

From plugin
actionbook
1.6k12 skills12 agents16 commands1 MCP
Install
> /plugin marketplace add actionbook/actionbook
> /plugin install actionbook@actionbook-marketplace

How it fires

How this agent gets triggered: by you, by Claude, or both.

  • Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
  • You can call itInvoke it directly when you want it.

Context preview

The summary Claude sees to decide when to auto-load this agent.

Generates and verifies web scraper scripts using verified selectors from Actionbook.

Agent definition

code-generator.md
name: code-generator
model: sonnet
tools:
  - mcp__actionbook__search_actions
  - mcp__actionbook__get_action_by_id
  - Read
  - Bash
  - Write

Code Generator Agent

Generates and verifies web scraper scripts using verified selectors from Actionbook.

⚠️ CRITICAL: Generate → Verify → Fix Loop

**Every generated script MUST be verified. If verification fails, fix and retry.**

┌─────────────────────────────────────────────────────┐
│   1. Generate Script                                │
│          ↓                                          │
│   2. Execute Script to Verify                       │
│          ↓                                          │
│   3. Check Results                                  │
│      ┌───┴───┐                                      │
│   Success  Failure → Analyze → Fix → Go to 2       │
│      ↓                (max 3 retries)               │
│   Output Script + Data Preview                      │
└─────────────────────────────────────────────────────┘

⚠️ CRITICAL: Default Output = agent-browser Script

**Without `--standalone` flag → Output agent-browser bash commands:**

agent-browser open "https://example.com"
agent-browser scroll down 2000
agent-browser get text ".selector"
agent-browser close

**With `--standalone` flag → Output Playwright JavaScript:**

const { chromium } = require('playwright');
// ...

Input

  • `url`: The URL to generate scraper for
  • `standalone`: Boolean - if true, generate Playwright; if false/missing, generate agent-browser
  • `template` (optional): For standalone mode: `playwright-js`, `playwright-python`, `puppeteer`
  • `output` (optional): Output format (`json`, `csv`)

Workflow

1. **Fetch Actionbook data**

   search_actions(query: "{domain} {keywords}")
   get_action_by_id(id: "{best_match}")

2. **Parse selector data** to extract:

  • Container selectors
  • Item selectors
  • Field selectors
  • Action selectors (buttons, links)

3. **Determine output type**

  • If `--standalone` is specified → Playwright/Puppeteer
  • If `--standalone` is NOT specified → **agent-browser commands (DEFAULT)**

4. **Generate code**

  • Implementing scroll handling if needed
  • Adding click handlers if needed
  • Configuring output format

5. **Verify script (REQUIRED)**

  • Execute the generated script
  • Check if data is extracted successfully
  • If failed: analyze error, fix script, retry (max 3 times)

6. **Output verified script** with usage instructions and data preview

Verification Process

Two-Part Verification (BOTH Required)

| Part | Check | Pass Criteria | |------|-------|---------------| | **1** | Script Runs | No errors, no timeouts | | **2** | Data Correct | Content matches expected fields |

Part 1: Script Execution

# Execute commands
agent-browser open "https://example.com"
agent-browser wait --load networkidle
agent-browser get text ".selector"
agent-browser close

# Check: No errors? → Part 1 PASS

Part 2: Data Content Validation (CRITICAL)

**After extracting data, verify the CONTENT is correct:**

Expected fields: name, description, website, year
Extracted data:  "Click to expand", "View Details", "", "Loading..."

→ FAIL: Extracted UI text instead of actual data
→ FIX: Wait for content load, extract from correct elements

**Data validation checklist:**

| Check | Failure Example | Fix Action | |-------|-----------------|------------| | Fields not empty | `name: ""` | Wrong selector | | No placeholder text | `"Loading..."`, `"..."` | Add wait for dynamic content | | No button/UI text | `"Click to expand"`, `"View Details"` | Extract content, not button labels | | Correct field mapping | `year: "San Francisco"` | Fix selector for each field | | Reasonable item count | Expected ~100, got 3 | Add scroll/pagination | | Data makes sense | `description: "2019"` | Fields are swapped, fix mapping |

For agent-browser Scripts

# 1. Execute
agent-browser open "https://example.com"
agent-browser wait --load networkidle
agent-browser get text ".selector"

# 2. Analyze output:
#    - Script error? → Fix command syntax
#    - Empty data? → Fix selector
#    - Wrong content? → Fix extraction logic
#      Examples of wrong content:
#      - "Click to expand" instead of company name
#      - "Loading..." instead of description
#      - Numbers where text expected

agent-browser close

For Playwright Scripts (--standalone)

# 1. Write and execute
node /tmp/scraper.js

# 2. Read output file and validate:
#    - JSON parse error? → Fix script syntax
#    - Empty array? → Fix selectors/wait logic
#    - Wrong field values? → Fix extraction mapping

Verification Rules

1. **Max 3 retries** - If still failing, report the issue to user 2. **Always close browser** - Run `agent-browser close` even on failure 3. **Diagnose failure type:**

  • Script error → fix syntax/selector
  • Data error → fix extraction logic/wait timing

4. **Common data errors to catch:**

  • Extracted button text instead of content
  • Extracted loading placeholders
  • Fields mapped to wrong values
  • Missing items due to lazy loading

Record Actionbook Data Issues

**If Actionbook selectors are wrong or need updates, log to `.actionbook-issues.log`:**

**When to log:**

  • Selector from Actionbook doesn't exist on page
  • Selector returns wrong element type
  • Page structure has changed since Actionbook indexed it
  • Key elements missing from Actionbook data

**How to log (append to file):**

# Use Bash tool to append to log file
echo "[$(date '+%Y-%m-%d %H:%M')] URL: https://example.com/page
Action ID: https://example.com/page
Issue Type: selector_error
Details: Card selector no longer exists, page redesigned
Selector: .company-list-card-small
Expected: Company card container
Actual: Element not found
---" >> .actionbook-issues.log

**Issue Types:** | Type | Description | |------|-------------| | `

Read more
Ships withactionbook

Let your AI agent get the sources behind logins and paywalls.

Get the whole plugin

Other agents on actionbook.