/shub-workflow-toolkit:shub-workflow-fshelperfrom shub-workflow-toolkit
Documents shub-workflow's cloud-agnostic filesystem layer (FSHelper) for reading, writing, listing, copying, moving, or deleting files across S3, GCS, and local paths with a unified API. Covers credential/role handling, listing variants, and module vs. class usage.
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.
futils / FSHelper)shub_workflow/utils/futils.py
is a cloud-agnostic filesystem layer. Every operation is one function that dispatches on the
path prefix: s3://… → S3 (via s3fs + boto3), gs://… → Google Cloud Storage (via
shub_workflow.utils.gcstorage), anything else → the local filesystem. So the same call works
across backends — you write download_file(path) and it does the right thing whether path is an
S3 key, a GCS object, or a local file.
FSHelper (not S3Helper)FSHelper is the recommended class — it's the general one (works for local, S3 and GCS, with
credentials defaulting to the ambient environment) and it's what shub_workflow.script uses. Prefer
it everywhere.
S3Helper is its base class, kept only for backward compatibility in some older projects.
Constructing it directly now emits a DeprecationWarning; FSHelper (and any other subclass)
does not. New or updated code should always use FSHelper.
futils.list_folder("s3://bucket/prefix/", aws_key=..., aws_secret=...).FSHelper instance — construct once with credentials, then call the same names as methods
with no creds needed: helper.list_folder("s3://bucket/prefix/"). This is the normal path in
scripts. Every module function listed in S3Helper.__annotations__ is auto-bound as a method that
injects the stored credentials (and refreshes them if a role is in play).from shub_workflow.utils.futils import FSHelper
# Ambient/env or local-fs credentials:
helper = FSHelper()
# Explicit key/secret:
helper = FSHelper(aws_key=KEY, aws_secret=SECRET)
# Role-assumed temporary credentials (STS), auto-refreshed before expiry:
helper = FSHelper(aws_key=KEY, aws_secret=SECRET, aws_role=ROLE_ARN, aws_external_id=EXT_ID)
for path in helper.list_folder("s3://my-bucket/some/folder/"):
print(path)
helper.download_file("s3://my-bucket/some/folder/file.json", "file.json")
BaseScript, a ready-made helper is already available as self.fshelper — prefer it
rather than constructing your own. Override the init_fshelper() hook to customize how it's
built (e.g. a GCS project, default ACLs).⚠️ You cannot discover the helper's API by introspection. The methods are bound dynamically from the annotations, so
dir(FSHelper)returns[]and editor autocomplete shows nothing — which makes the class look empty and invites guessing (helper.open(...),helper.read(...): there are no such methods). The operation list below and references/function-reference.md are the only listing; read one of them before calling anything.
This is the most common mistake. They are not interchangeable:
| Function | Semantics | Use when |
|---|---|---|
list_folder(path) | one level only — like ls. Returns immediate children, excludes the folder marker itself. Returns a list. | You want the direct contents of a single folder. |
list_path(path) | prefix-based, efficient paginated boto3 scan. Returns a generator over every key under the prefix (effectively recursive). | You want all objects under a prefix, cheaply, or you only have a key prefix (not a clean folder). |
list_folder_files_recursive(folder) | recurses by repeatedly calling list_folder. Generator. | You need a full recursive walk and want folder-by-folder descent semantics. |
Also: list_folder_in_ts_order(folder) yields list_folder's results sorted by last-modified
time (oldest→newest) — handy for "process the earliest delivered file first".
Footgun:
list_folderis not recursive. On a nested delivery tree it returns subfolders, not the files inside them. For "every file under here", uselist_path(cheapest) orlist_folder_files_recursive.
get_file (open a file handle like open()), download_file, upload_file, upload_file_obj,
cp_file, mv_file, rm_file, exists, touch, get_glob, empty_folder, s3_folder_size.
Full signatures, return types, and cross-backend behavior:
references/function-reference.md.
FSHelper, not S3Helper. S3Helper is the deprecated backward-compat base; direct use
warns. FSHelper is the general, recommended class.upload_file, cp_file, mv_file treat a dest ending
in / as a folder and append the source's basename. Omit the slash to control the final name.op_kwargs carries S3 ExtraArgs / ACL. Pass per-call S3 options via op_kwargs, e.g.
op_kwargs={"ACL": "bucket-owner-full-control"} on uploads/copies — essential when writing into a
bucket owned by another account (a customer's). get_file lowercases ACL→acl for s3fs; the
upload path passes ACL straight through as boto3 ExtraArgs. With a helper, set defaults
per-method via op_kwargs_by_method_name={"upload_file": {"ACL": "bucket-owner-full-control"}}.s3_credentials prefers AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY
from the environment over the aws_key/aws_secret you pass. AWS_REGION is honored too.GOOGLE_APPLICATION_CREDENTIALS_JSON. GOOGLE_APPLICATION_CREDENTIALS
must hold the key file's path. To pass the key itself (JSON, raw or base64), e.g. as a ScrapyCloud
secret, use GOOGLE_APPLICATION_CREDENTIALS_JSON: the client is built from it with no file written,
and it wins over a path. Never put the key in GOOGLE_APPLICATION_CREDENTIALS: google-auth repeats
that value in its errors and debug log, so the private key gets printed. (shub-workflow's own GCS client
tolerates a key there for backward compatibility; other code doesn't.) Bad keys raise
gcstorage.InvalidCredentialsError, whose message never includes the value.aws_role and aws_external_id
and it builds an S3SessionFactory that calls STS assume_role and refreshes the temporary
credentials before they expire (expiration_margin_minutes, default 10) on every wrapped call.pip install shub-workflow[with-s3-tools]
(s3fs+boto3); GCS needs shub-workflow[with-gcs-tools]. Hitting an s3:///gs:// path
without the extra raises ModuleNotFoundError from check_s3_path/check_gcs_path.Callable
in S3Helper's class annotations; a new module function isn't a helper method until it's annotated
there.get_object, upload_file_obj) are S3-only or
GCS-only — check the reference before assuming a function is fully cross-backend.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-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