/shub-workflow-toolkit:scanjobs-programsfrom shub-workflow-toolkit
Helps build and use scanjobs commands for ScrapyCloud: extract/plot data from stats, logs, items, spider args, or job metadata. Covers command-line patterns, postscript post-processor, plot mini-language, time windows, and PROGRAMS shortcuts in shub_workflow-based projects.
Ships in shub-workflow-toolkit. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
scanjobs.py scans ScrapyCloud jobs for a spider/script, extracts data from stats, log
lines, items, or spider args via regex, optionally post-processes the extracted numbers
(-c), and optionally plots them (--plot). A project subclasses
shub_workflow.utils.scanjobs.ScanJobs and defines a PROGRAMS dict so long, frequently-used
command lines get a short alias.
from shub_workflow.utils.scanjobs import ScanJobs as ShubScanJobs
class ScanJobs(ShubScanJobs):
PROGRAMS = {
"response_profile": {
"description": "Response profile for a spider. Use with -v spider:<spider>",
"command_line": [
"--project-id=<PROJECT_ID>", "{spider}",
"-s", "downloader/(response_count)",
"--data-headers=auto",
"--plot", "title={spider} response profile,no_tiles",
],
},
}
Invoke: scanjobs.py -g response_profile -v spider:myspider.
Common use — plotting a monitor's stats over time. A periodically-scheduled
BaseMonitorrun carries its aggregated stats in its job stats, so a frequent program scans the monitor script's jobs (e.g.py:monitor.py, filtered by its run tag like--has-tag=DAILY), selects a stat with-s, and--plots its evolution over--period— a lightweight way to watch monitor-stat trends.
Common use — a census of a spider's jobs (e.g. "since when, and from which deploy, do jobs die from memory?"). Combine
-mwith the stats you care about and write one record per job:scanjobs.py --project-id=<PROJECT_ID> myspider -p "3 days" -z UTC \ -m close_reason: -m "version:^([0-9a-f]+)" -s "^memusage/max$" \ --data-headers=close_reason,commit,memusage -w census.jlThen group
census.jlbyclose_reason×commit. Jobs killed before saving stats still appear, with only their metadata. Scrapy samplesmemusage/maxonly every 60 s, so a job OOM-killed sooner than that reports just its startup memory: trust the close reason, not that stat.
Human-readable docs. The shub-workflow wiki has a full prose guide to this tool at https://github.com/scrapinghub/shub-workflow/wiki/ScanJobs. If the user wants a walkthrough, a shareable reference, or asks where the documentation is, point them there.
-g / -v work (read this before editing PROGRAMS)PROGRAMS is consumed by ArgumentParserScript.parse_args in shub_workflow.script. The mechanics
that bite people:
command_line is a list of separate argv tokens, NOT a shell string. A flag and its value
are two list items: "-s", "downloader/(response_count)" — never "-s downloader/...".str.format(**vars) applied, where vars comes from -v k1:v1,k2:v2.
So "spider:{spider}" becomes "spider:myspider"..format() runs on every token, any real {/}
in a regex or a postscript repeat block must be escaped as {{/}}. E.g. a log regex
"total": (\d+)} is written "total\": (\\d+)}}", and a repeat block is "{{ add }}".
Forgetting this raises KeyError/ValueError at format time. See
examples/annotated-programs.md for worked cases.-g response_profile -p "5 days" runs the
program but with --period replaced. Anything left at argparse default in the program is
overridden by a value you pass explicitly — so a program can hard-code --project-id yet still be
re-pointed at another project on the CLI.To list a project's programs: read the PROGRAMS dict in its scripts/scanjobs.py, or run with a
bogus -g (e.g. -g ?) — the parser prints * <name>: <description> for each.
-s <regex> (matched against stat keys; regex groups + the stat value are emitted)-l <regex> (regex groups emitted; add --count to emit 1 per match for counting)-i <jmespath>:<regex>-a <arg>:<regex> for spiders; for scripts (py:) a bare -a <regex> matched against the job command line-m <field>:<regex> (close_reason, version, units, …): filters jobs and
prepends one captured value per pattern to the job's datapoints--project-id (jobs are read outside ScrapyCloud): a numeric SC project id, or a
configured alias if the project defines one.{var} and document them in the
description ("Use with -v spider:").-c expression — see
references/postscript.md. Remember to escape repeat braces as {{ }}.--data-headers (required by --plot) and the --plot string — see
references/plot-dsl.md. title= is required.-z UTC and
--period conventions). Run the project's linter after editing.Run from the project's scripts/ dir as python scanjobs.py -g <program> [-v ...] [overrides].
It must run inside the project's environment (it imports scrapinghub, and for plotting needs
pandas/seaborn/matplotlib) — invoke through whatever the project uses (pipenv, poetry, a venv,
etc.), not a bare system python. Plots are shown interactively or, when no display is available,
saved as <uuid>.png in the cwd. A project often keeps a small shell script cataloging its common
invocations — a useful place to copy real examples from.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
10 skills in this plugin
/shub-workflow-architecturesUse when a developer wants help designing (or redesigning) the architecture of a shub-workflow based Scrapy Cloud project — "help me design the architecture for this project", "how should I structure the crawl managers / consumers / delivery", "which components do I need", "how do I feed my spiders from a frontier", "how do I scale this crawl", "should I use a graph manager", or when migrating a project away from a central graph manager or from spiders that read/write the frontier (Frontera). Runs an INTERACTIVE design session: interviews the developer in short rounds to uncover the requirements they haven't stated yet, maps them to the independent-agents + role-separation architecture (or to a graph manager where a short ordered sequence fits), writes a design document with roles, storage contracts, scheduling and scale knobs, checks it against known pitfalls, and then scaffolds the script skeletons for the chosen roles. Covers seeds vs url frontiers, the post-crawl data chain, downloads, keep-alive scheduling, back-pressure and recrawling./shub-workflow-crawl-managersUse when building, updating, fixing, or understanding a shub-workflow crawl manager — a script that schedules spider jobs on Scrapy Cloud and reacts to their outcomes, built on shub_workflow.crawl (CrawlManager / PeriodicCrawlManager / GeneratorCrawlManager / AsyncSchedulerCrawlManagerMixin) and WorkFlowManager. Covers choosing the base class, the set_parameters_gen() generator pattern, the outcome/retry/throttling hooks, async concurrent scheduling, and the name/flow-id/loop-mode rules. Use for any crawl-manager script in any project that subclasses these classes (directly or via a project base mixin).npx claudepluginhub scrapinghub/shub-workflow --plugin shub-workflow-toolkitOther plugins' skills for the same job