/shub-workflow-toolkit:shub-workflow-monitorsfrom shub-workflow-toolkit
Builds, updates, and debugs cross-job monitoring scripts for shub-workflow. Aggregates spider/script stats from a time window, computes ratios, emits reports, and sends Slack/Sentry threshold alerts.
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.
A monitor aggregates stats across the spider and script jobs that ran in a time window, derives
ratios, optionally emits a report, and raises alerts when thresholds are breached. BaseMonitor
(shub_workflow/utils/monitor.py)
is a BaseScript (see the shub-workflow-scripts skill), not a loop/workflow manager. Full
reference: Appendix F: Monitor Classes;
intro: the Monitors tutorial.
Use a monitor for the broad view (project-wide error rates, totals, drops) where Spidermon — which watches a single spider job — can't help.
BaseMonitor. To deliver alerts, mix an alert backend in front:
class Monitor(SlackMixin, BaseMonitor) (or SentryMixin).target_spider_classes, target_spider_stats, target_script_stats, target_script_logs,
stats_ratios, stats_hooks, default_subject.stats_hooks method per alert condition (signature
(self, start_limit, end_limit, value, *regex_groups) → self.append_message(...)); and/or
override stats_postprocessing(start, end) for derived stats.check_<name>(self, start, end) method — it's
auto-discovered and run. For reports, set report_table and run with --generate-report
(examples/custom_check_and_report.py).__main__ boilerplate (Monitor().run()).setup.py; deploy via the scrapy-cloud-deployment skill. Schedule it
periodically (e.g. a daily and a monthly periodic job with distinct tags, or a small
monitor_scheduler.py) — it runs once per invocation.API tables: references/api-cheatsheet.md.
BaseMonitor is a BaseScript: it runs its checks once and exits.
There is no loop_mode / workflow_loop; recurring monitoring = scheduling it periodically.check_* methods are auto-run. Any method whose name starts with check_ is discovered and
called with (start_limit, end_limit). Name unrelated helpers differently, or they'll run as checks.SlackMixin/SentryMixin before BaseMonitor. Without a
backend mixin, append_message() just queues text that's never sent. Backends need their
SPIDERMON_SLACK_* / SPIDERMON_SENTRY_* settings (and the matching spidermon[...] extra); both
honour a *_FAKE setting that logs instead of sending.stats_hooks method signature is (self, start_limit, end_limit, value, *regex_groups) — one
extra positional per capturing group in the stat regex. Mismatched arity raises at runtime.target_spider_classes is first-match by issubclass, order matters. Each spider job's prefix
is the first entry whose class it subclasses. To give a subclass its own group, list it before
its parent — listed after, the parent wins and it folds into the parent's prefix. Conversely, adding
a base class that's already a parent of a targeted class changes nothing (it's already matched).additional_projects covers script scans too. It feeds get_jobs_in_window ((project_id,) + additional_projects), which backs the spider scan and target_script_stats/target_script_logs.
So a script's regex set runs against that script's jobs in every scanned project — entries just
don't match where a stat is absent, letting you rename a per-project stat variant to a common name.--flow-id scoping. With no flow id the monitor aggregates all jobs in the window; with
--flow-id (or when scheduled by a graph manager, inheriting its flow id) it scopes to that
workflow. Pick deliberately.item_scraped_count,
downloader/response_count, downloader/response_status_count/*, spider_exceptions/*,
scrapy-zyte-api/429, zyte_api_proxy/response/status/429. Set stats_only_total = True to drop
per-spider entries. (Note: per-spider job counts are not aggregated by default.)--collection-name <name> saves the whole stats dict to a Scrapy
Cloud collection (one record per window, _key = the date, or <start> to <end>) — the built-in
way to keep monitor history. It only saves when the window is midnight-aligned (both ends at
00:00), else it's skipped with an error; so schedule day-aligned runs (e.g. -e "today at 0:00").-s the stat, --plot) —
see the scanjobs-programs skill. A lightweight complement to --collection-name, often
predefined as scanjobs programs.super().add_argparser_options() before adding CLI args.if __name__ == "__main__":
import logging
from shub_workflow.utils import get_kumo_loglevel
logging.basicConfig(format="%(asctime)s %(name)s [%(levelname)s]: %(message)s", level=get_kumo_loglevel())
Monitor().run()
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub scrapinghub/shub-workflow --plugin shub-workflow-toolkit10 skills in this plugin
/scanjobs-programsUse for help using shub_workflow's scanjobs tool — scanning ScrapyCloud jobs to extract and plot data from stats, logs, items, spider args or job metadata. Also reach for it, instead of a hand-rolled job-listing script, to take a census of a spider's jobs over a time window: how many ended with each close_reason (e.g. memusage_exceeded / killed by oom), on which deployed version, with which units, alongside per-job stats such as memusage/max. Covers building a scanjobs command line (the stat/log/item/spider-arg/meta patterns, the postscript post-processor -c, the --plot mini-language, time windows, and output modes) and the predefined "programs" shortcut: the PROGRAMS dict in a project's scripts/scanjobs.py (a subclass of shub_workflow.utils.scanjobs.ScanJobs), invoked as `scanjobs.py -g <program> -v key:val`, including {var} placeholders and {{ }} escaping. Applies to any project whose scripts/scanjobs.py subclasses shub_workflow's ScanJobs./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)./shub-workflow-diagramsUse when asked to build, update or restyle an architecture diagram for a shub-workflow based project — a workflow/pipeline diagram (the spiders, crawl managers, consumers, issuers, deduplicators, balancers, downloaders, delivery and the storages between them) or a class hierarchy / UML diagram of its script classes. Covers the house style shared by these projects (banded "swimlane" stages with a Role box, one warm palette, left-to-right flow), the plain-data model you write, the ready-made rendering engine to copy, and the Graphviz constraints that make the result stable instead of reshuffling on every run. Reach for it for "draw the workflow", "diagram the architecture", "update the workflow diagram", "class diagram of the scripts", or when a README's architecture PNG has gone stale./shub-workflow-fshelperUse when reading, writing, listing, copying, moving, or deleting files through shub-workflow's cloud-agnostic filesystem layer — the `shub_workflow.utils.futils` module and its `FSHelper` class (the recommended one; `S3Helper` is its deprecated backward-compatibility base) — i.e. any code that touches `s3://`, `gs://`, or local paths the same way, needs AWS role-assumed (STS) credentials, or must list/download deliveries in a bucket. Covers the prefix-based dispatch, module functions vs. the helper class, credential/role handling, the three listing variants (`list_folder` vs `list_path` vs recursive), `op_kwargs`/ACLs, and the install extras. Reach for it whenever you see `from shub_workflow.utils.futils import ...`, an `FSHelper`, or any project-local factory that returns one (a `build_fshelper()`-style wrapper, `self.fshelper`) — its API is NOT guessable and not discoverable by `dir()`, so check here before calling anything on it./shub-workflow-graph-managersUse when building, updating, fixing, or understanding a shub-workflow graph manager — a script that runs an arbitrary DAG of tasks (spiders and scripts, including crawl managers and deliver scripts) on Scrapy Cloud with dependencies, built on shub_workflow.graph (GraphManager + Task / SpiderTask) and WorkFlowManager. Covers configure_workflow(), Task vs SpiderTask, dependency linking (add_next_task / add_wait_for), the on_finish/retry routing, resources, parallelization, and the start directives. Use for any graph-manager / flow-manager script that subclasses GraphManager (directly or via a project base mixin).Other plugins' skills for the same job