/filesystem-pipeline:optimize-filesystem-performance [pipeline-name] [symptom]from filesystem-pipeline
Optimizes dlt filesystem pipelines by diagnosing slow reads from local/S3/GCS/Azure/SFTP and applying targeted fixes: faster readers, parallelization, glob narrowing, chunked streaming, or file-level incremental loading.
Ships in filesystem-pipeline. 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.
None: SKILL.md is the whole skill.
Source-specific tuning for filesystem pipelines. Work the loop — diagnose → pick the fix → apply → measure → repeat, one change at a time. Combine these with the source-agnostic stage levers in the performance toolkit's optimize-performance skill.
Essential reading: https://dlthub.com/docs/dlt-ecosystem/verified-sources/filesystem
Parse $ARGUMENTS:
pipeline-name (optional): the dlt pipeline. If omitted, infer from session context; if ambiguous, ask and stop.symptom (optional): e.g. "reading thousands of CSVs is slow", "OOM on a big file", "scanning the whole bucket".pipeline.last_trace (or progress="log"); confirm reading files is the slow stage (if normalize/load dominates, that's the performance toolkit).modification_date) first — see add-incremental-loading. Reading fewer files beats reading them faster.Match the symptom to a lever. They compose — apply every one that fits; just don't tune what isn't the bottleneck.
| Symptom | Fix (see Apply) |
|---|---|
| CSV parsing is slow / you control the source format | Prefer Parquet; use a faster reader |
| OOM — whole file loaded into memory | Stream in chunks |
| Many files read sequentially | .parallelize() reads |
| Lists/scans the whole bucket | Narrow the glob |
| Listing a bucket with very many files | Raise files_per_page |
| You only need to move files, not parse them | Skip the reader — copy via fsspec |
Faster format / reader — read speed by format is Parquet > JSONL > CSV; land Parquet if you control the source. Pipe the filesystem resource to a reader:
read_parquet() — streams row groups; use_pyarrow=True for zero-copy Arrow.read_csv_duckdb() (duckdb-backed — faster and lower-memory than the pandas read_csv(); use_pyarrow=True yields Arrow), or read_csv() (pandas, forwards **pandas_kwargs).read_jsonl().from dlt.sources.filesystem import filesystem, read_csv_duckdb
reader = (filesystem(bucket_url="<url>", file_glob="<pattern>") | read_csv_duckdb(use_pyarrow=True))
Stream in chunks — all readers batch: read_csv(chunksize=...) (pandas, default 10000), read_csv_duckdb(chunk_size=...) (default 5000), read_parquet(chunksize=...) / read_jsonl(chunksize=...) (default 1000). Lower it to cut memory on wide files; raise it to reduce overhead on narrow files. For files too big for even a chunked built-in reader — or a format they don't cover — write a custom transformer that streams and yields chunks:
@dlt.transformer
def read_big_csv(items, chunksize=10000, **kwargs):
import pandas as pd
for f in items: # f is a FileItemDict
for df in pd.read_csv(f.open(), chunksize=chunksize, **kwargs):
yield df.to_dict(orient="records")
reader = filesystem(bucket_url="<url>", file_glob="<pattern>") | read_big_csv
Read files concurrently — only worth it for remote/object-store reads (local files are CPU/GIL-bound — use Parquet / read_csv_duckdb / more [normalize] workers there). .parallelize() splits reads across pages, so it needs several pages: set files_per_page well below your file count and call .parallelize(). At the default files_per_page=100, .parallelize() does nothing until you have >100 files (and under-uses workers otherwise).
reader = (filesystem(bucket_url="<url>", file_glob="<pattern>", files_per_page=10) | read_csv()).parallelize()
Concurrency is capped by [extract] workers — pick files_per_page for a few pages per worker, not 1 file per page. (Instead raise files_per_page if listing a huge bucket is the bottleneck, not reading.)
Narrow the glob — the cheapest win is reading fewer files. Make file_glob as specific as possible (path prefixes, date partitions, extensions) so dlt never lists or fetches irrelevant objects — important on object stores where listing is slow.
Just moving files? skip parsing — if you don't need the contents (e.g. copying files to another bucket), don't pipe to a reader at all. Use fsspec directly to avoid parse + memory entirely:
from dlt.sources.filesystem import filesystem
from dlt.sources.filesystem.helpers import fsspec_from_resource
files = filesystem(bucket_url="<url>", file_glob="<pattern>")
fs = fsspec_from_resource(files) # authenticated fsspec client for bulk ops
# per item: item.open() / item.read_bytes()
pipeline.last_trace against step 1.create-filesystem-pipeline "Debug — first run" (it escalates to troubleshoot-pipeline-run for anything it doesn't cover).optimize-performance (install if not present: uv run dlthub --non-interactive ai toolkit install performance).uv run dlthub --non-interactive ai toolkit install dlthub-platform).What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub dlt-hub/dlthub-ai-harness --plugin filesystem-pipeline3 skills in this plugin
/add-incremental-loadingAdd incremental loading to a dlt filesystem pipeline — filter files by modification date, optionally filter records by a timestamp column, and switch to merge with a primary key to deduplicate updated records, so each run only reads new or modified files. Use after create-filesystem-pipeline produces a working replace-mode pipeline, or when the user wants to set up merge/dedup or move a pipeline from replace to incremental. For speed/memory tuning (faster reader, chunked streaming, parallel reads, glob narrowing) use optimize-filesystem-performance instead./create-filesystem-pipelineCreate a dlt filesystem pipeline that reads files (CSV, Parquet, JSONL, or custom) from local disk, S3, GCS, Azure, or SFTP into a destination. Use for the filesystem core source. Not for REST APIs (rest_api) or databases (sql_database).Other plugins' skills for the same job