/shub-workflow-toolkit:shub-workflow-graph-managersfrom shub-workflow-toolkit
Builds and manages directed acyclic graph (DAG) workflows on Scrapy Cloud using shub_workflow's GraphManager. Covers task creation, dependency linking, parallelization, and retry routing for spider and script tasks.
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 graph manager orchestrates a directed graph of tasks — spiders and scripts (often crawl
managers + a deliver script) — on Scrapy Cloud, scheduling each as its dependencies are satisfied.
GraphManager is a WorkFlowManager (inherits name / flow-id / owned-jobs / resume); tasks are
Task (a script) or SpiderTask (a spider). Source:
shub_workflow/graph/.
Full reference:
Appendix E: Graph Manager Classes
(+ Appendix C: Workflow Manager
for the inherited layer); intro:
Graph Managers. Builds on the
shub-workflow-scripts and shub-workflow-crawl-managers skills.
When you need more than one job with dependencies — e.g. "run a crawl manager, then a deliver
script once it finishes", fan-out/fan-in, or branching by outcome. For scheduling a single spider or
a stream of one spider's jobs, a crawl manager is simpler (see shub-workflow-crawl-managers).
GraphManager; set loop_mode (and name, or pass it positionally).configure_workflow(): create tasks, link them, and return the root task(s).
Task(task_id, command, init_args=[...]) for a script (command = py:foo.py or a Jinja
template); SpiderTask(task_id, spider, **spider_args) for a spider.a.add_next_task(b) → b runs after a; a.add_wait_for(b) → a waits for b (pure dependency).retries, on_finish routing by outcome, add_required_resources(...),
parallelization (multi-line Task command), and a bad_outcome_hook override.__main__ boilerplate (MyGraphManager().run()).setup.py; deploy via the scrapy-cloud-deployment skill.
The scripts/spiders the graph schedules are separate deployables.Templates: examples/graph_manager.py (basic), examples/parallel_and_resources.py (parallel + resources + on_finish + bad_outcome_hook). API tables: references/api-cheatsheet.md.
configure_workflow() and return the ROOT tasks (a tuple). Returning the wrong tasks
(or forgetting to link successors) silently changes the graph. Only root tasks should be returned;
successors are reached via the edges.--root-jobs (start from the returned
roots) or --starting-job <id> (repeatable). Neither → the manager errors on start. They're
mutually exclusive.loop_mode (it's a loop manager) and a name (WorkFlowManager — class attr or first
positional arg). No name → error at startup.retries defaults to 1, and on_finish["failed"] defaults to ["retry"] — so a failed
task is retried once by default, then routed to bad_outcome_hook. Set retries=0 to disable.Task parallelization comes from a multi-line rendered command (Jinja {% for %}): N
lines → N parallel subtasks task_id.0..N-1; successors wait for all. SpiderTask never
parallelizes.task_id rules: must be unique, can't be "retry", and a Task id can't contain . (used
for parallel subtask ids).on_finish routing order: exact outcome → "failed" (for failed outcomes) → "default" (the
add_next_task targets). Use a custom on_finish={...} to branch on specific close reasons; still
add_next_task any task referenced there so it's registered in the graph.--max-running-jobs (named semaphores via
add_required_resources). Don't conflate the two limits.super().add_argparser_options() if you add 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())
MyGraphManager().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-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