/shub-workflow-toolkit:shub-workflow-crawl-managersfrom shub-workflow-toolkit
Builds, updates, fixes, or understands shub-workflow crawl managers that schedule Scrapy Cloud spider jobs and react to outcomes.
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 crawl manager is a workflow-manager script that schedules spider jobs on Scrapy Cloud and
reacts to how they finish. The classes live in
shub_workflow/crawl.py
on top of WorkFlowManager → BaseLoopScript. Full reference:
Appendix D: Crawl Manager Classes
(and Appendix C: Workflow Manager
for the inherited layer);
gentler intro: the Crawl Managers
tutorial. This skill builds on the shub-workflow-scripts skill (the base-class layer).
| Base class | Use when | Template |
|---|---|---|
GeneratorCrawlManager | schedule a stream of jobs from a generator of params (the usual case) | examples/generator_crawl_manager.py |
AsyncSchedulerCrawlManagerMixin (+ GeneratorCrawlManager) | the cycle schedules many jobs and you want them dispatched concurrently | examples/async_generator_crawl_manager.py |
HCFSeedsCrawlManager (shub_workflow.utils.hcf, a GeneratorCrawlManager) | feed one spider with seeds read from its crawl-frontier slot (per-spider config, split slots) | the shub-workflow-hcf skill |
PeriodicCrawlManager | keep one spider job running, rescheduling it after each finish | examples/periodic_crawl_manager.py |
CrawlManager | schedule a single spider job once (rare on its own; it's the base of the others) | — |
Retries / outcome hooks / throttling: examples/retries_and_hooks.py. API tables: references/api-cheatsheet.md.
GeneratorCrawlManager.name and loop_mode (both effectively required — see footguns), plus spider and
default_max_jobs, and a description.set_parameters_gen() — yield one dict per job. Flat keys become spider args; the keys
spider, units, tags, job_settings, project_id are handled specially.MAX_RETRIES + get_retry_override (or a custom bad_outcome_hook),
finished_ok_hook, can_schedule_job_with_params for throttling.__main__ boilerplate — CrawlManager().run(), or asyncio.run(CrawlManager().run())
for the async mixin.setup.py; deploy via the scrapy-cloud-deployment skill.If the project already has a base crawl-manager mixin (shared options/helpers), subclass it:
class CrawlManager(ProjectMixin, GeneratorCrawlManager) — mixin first (find existing ones with
grep -rl GeneratorCrawlManager <project>/).
WorkFlowManager mandates name (and flow_id_required = True). Set the
name class attribute, or pass it as the first positional CLI arg. No name → the script errors
at startup. Distinct managers in one workflow must have distinct names.name and the same flow id, and a flow id
only survives across jobs when it is given explicitly (--flow-id) or inherited from the job's own
tags (i.e. a clone). A manager started fresh by a scheduler gets an autogenerated one, so it begins
with an empty view and will schedule children alongside any a previous instance left running.
Set acquire_all_jobs = True so it adopts them instead: owned children are then matched by
PARENT_NAME=<name> alone. If several instances of the manager share a name but target different
spiders, also override get_owned_jobs() to filter by the target spider, or one instance will
adopt another's children.loop_mode (class attr or --loop-mode) for periodic/generator managers. With
loop_mode = 0 the manager runs one cycle and exits — a generator manager would schedule only the
first batch and quit.spider attribute vs positional. If spider is unset, a positional spider CLI arg is
required; if set, that arg disappears. A yielded "spider" key overrides the target per job (set
spider = "" to force every yielded dict to name its spider).(spider, spider_args) was already scheduled is
skipped (bloom filter). Don't expect re-yielding identical params to reschedule; vary the args,
or override create_dupe_filter() to change capacity/error rate.MAX_RETRIES (0 = off; cancelled is never retried). Tune per retry with
get_retry_override (raise StopRetry to abort), or override bad_outcome_hook entirely.
add_job() is GeneratorCrawlManager-only — don't call it on CrawlManager/PeriodicCrawlManager.AsyncSchedulerCrawlManagerMixin: mixin first in the
bases, and launch with asyncio.run(script.run()). set_parameters_gen() stays a synchronous
generator — only scheduling is async.super().add_argparser_options() before adding args, or you lose name/spider/
--spider-args/etc.get_running_spiders() and
spider_running_count() only see spider names. Use get_running_jobs() and look at
job_args_override["spider_args"], checked in the generator before claiming an input. Two
traps. A cycle generates all its params before scheduling any, so a job yielded earlier in the same
cycle isn't running yet: add a flag set at yield time and reset it in workflow_loop(). And
can_schedule_job_with_params() runs after the yield, so deferring there leaves an input that the
generator already claimed (moved, marked) waiting in memory, and stranded if the manager stops.default_max_jobs defaults to 1000 (not infinite); override the attr or pass --max-running-jobs.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())
CrawlManager().run() # ... or asyncio.run(CrawlManager().run()) for the async mixin
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-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)./shub-workflow-hcfUse when working with a ScrapyCloud Hubstorage Crawl Frontier (HCF) from a shub-workflow project — running or extending the standalone frontier tool `shub_workflow.utils.hcf.FrontierTool` (list slots, count, dump, add seeds, delete batches or slots, move a slot into another), installing the `with-hcf-backend` extra, building a seeds crawl manager on the ready-made `shub_workflow.utils.hcf.HCFSeedsCrawlManager` (ENABLED_SPIDERS config, split slots, hooks), or writing crawl-manager / consumer code that reads seeds from a frontier slot or writes new seeds into it through `hcf_backend`'s `HCFManager`. Covers the HCF semantics that bite (per-slot fingerprint memory, single writer per slot, read does not remove), the tool's commands and extension points, and the read → delete → schedule and add → flush seed patterns.Other plugins' skills for the same job