com um clique
debug-scraper
// Debug kent/pdd scrapers using the pdd CLI and database inspection tools. Use when the user reports scraper failures, XPath issues, missing results, or wants to investigate a scraper run database.
// Debug kent/pdd scrapers using the pdd CLI and database inspection tools. Use when the user reports scraper failures, XPath issues, missing results, or wants to investigate a scraper run database.
| name | debug-scraper |
| description | Debug kent/pdd scrapers using the pdd CLI and database inspection tools. Use when the user reports scraper failures, XPath issues, missing results, or wants to investigate a scraper run database. |
| allowed-tools | Bash, Read, Grep, Glob, Write, Edit |
You are debugging a scraper built on the kent framework. You have access to
the pdd (persistent driver debugger) CLI for inspecting scraper run
databases, and the kent CLI for running and inspecting scrapers.
Always use uv run pdd and uv run kent to invoke these tools.
See cli-reference.md for the full CLI reference with all commands, subcommands, and options.
Follow this general approach, adapting to the specific issue:
.db file). Ask the user if not obvious.uv run pdd --db <path> infouv run pdd --db <path> requests summaryuv run pdd --db <path> errors summaryuv run pdd --db <path> results summaryuv run pdd --db <path> errors listuv run pdd --db <path> errors show <id>uv run pdd --db <path> errors diagnose <error-id>uv run pdd --db <path> bulk-xpath <continuation> --sample 20uv run pdd --db <path> step re-evaluate <step_name>--verbose for per-request diffs.--sample N to spot-check a subset.uv run pdd --db <path> requests show <id>uv run pdd --db <path> responses content <request-id>uv run pdd --db <path> responses search --text "pattern"uv run kent inspect <scraper-module> to see the scraper's metadata and
entry points.For investigations that don't map to a built-in subcommand, pdd query may be useful:
uv run pdd --db <path> query listuv run pdd query <name> --help (prints
description, schema_version, required params)uv run pdd --db <path> query <name> --query-params '{"step": "parse"}'uv run pdd --db <path> query --query /tmp/foo.json --query-params '{...}'Queries are JSON files at ~/.config/kent/queries/<name>.json (user override)
or shipped as built-ins. Each file declares:
{
"schema_version": 19,
"description": "...",
"query": "SELECT ... WHERE x = :param ...",
"params": ["param"]
}
The DB is opened read-only. schema_version must match the DB's current
schema; --force overrides with a warning. Use --format json /
--format jsonl for machine-readable output. The name list is reserved.
--db flag can go at any level: pdd --db run.db errors list or
pdd errors --db run.db list or pdd errors list --db run.db.diagnose shows selectors failing, check the response content to see if
the HTML structure has changed.After completing a debugging session, notify the user that you are writing a brief incident report, then write it to:
.claude/debug-incidents/<YYYY-MM-DD>-<short-slug>.md
Use this template:
# <Short title>
- **Date**: <YYYY-MM-DD>
- **Scraper**: <scraper module or name>
- **Symptom**: <what the user reported>
- **Root cause**: <what was actually wrong>
- **pdd tools used**: <which pdd commands helped, briefly>
- **Gaps**: <any steps where pdd didn't have the right tool and you had to
fall back on manual inspection, raw file reading, shell commands, etc.
Write "None" if pdd covered everything.>
- **Suggested improvement**: <one-sentence idea for a pdd feature that would
have helped, or "None">
Keep each report to roughly 10-15 lines. These reports are read in aggregate to iteratively improve pdd's debugging capabilities.