Pegasus Wrapper Script Generator

VerifiedSafe

Generates a standardized wrapper script for a single step in a Pegasus pipeline. It automates the creation of Python or shell scripts following predefined templates, handling arguments, inputs/outputs, logging, and exit code propagation. Useful when building Pegasus workflows to ensure consistency and reduce manual errors.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude Code
#pegasus#wrapper-script#pipeline#code-generation

Recommended for

Automated summary

Generates a custom wrapper script for a single Pegasus pipeline step.

Strengths

  • Automates generation of consistent wrappers following Pegasus best practices
  • Selects an appropriate template based on tool type (CLI, API, Python, shell)
  • Ensures argument alignment between the wrapper and the workflow generator

Limitations

  • Requires the user to have detailed knowledge of the tool being wrapped
  • Does not handle complex multi-step dependencies
  • Generation relies on a limited set of predefined templates
When to use it

To quickly create a reliable wrapper for a new Pegasus pipeline step.

When not to use it

When the step involves advanced control flow not covered by the templates.

Security analysis

Safe
Quality score92/100

The skill only generates wrapper scripts; it does not execute code, access external resources, or perform any destructive actions. The allowed tools (Read, Glob, Grep, Write, Edit) are used for code generation, not for system modification or data exfiltration.

No concerns found

How this analysis is made

Examples

Samtools sort wrapper
Create a Python wrapper for samtools sort that takes a BAM file as input and outputs a sorted BAM file.
BWA mem wrapper
Generate a shell wrapper for bwa mem with output flattening, accepting a reference and a read pair.
API fetch wrapper
Create a Python wrapper that fetches earthquake data from USGS API and saves to a JSON file.

name: pegasus-wrapper description: Generate a wrapper script for a single Pegasus pipeline step allowed-tools:

  • Read
  • Glob
  • Grep
  • Write
  • Edit

Pegasus Wrapper Script Generator

You are a Pegasus wrapper script generator. The user has invoked /pegasus-wrapper to create a wrapper for a single pipeline step.

Step 1: Read Reference Materials

  1. Read Pegasus.md from the repository root — especially the "Writing Wrapper Scripts" and "Shell Wrapper Scripts" sections.
  2. Read pegasus-templates/wrapper_template.py and pegasus-templates/wrapper_template.sh as starting points.

Step 2: Gather Requirements

Ask the user (skip questions they've already answered):

  1. Tool name: What tool does this wrapper invoke? (e.g., samtools sort, bwa mem, a Python library, an API)
  2. Inputs and outputs: What files does it read and write? Include filenames or patterns.
  3. Does the tool produce nested output? If yes (e.g., MEGAHIT, QUAST, Prokka, GTDB-Tk), a shell wrapper with output flattening is better.
  4. Python or shell?
    • Python (recommended for most cases): subprocess calls, API fetches, pure-Python analysis
    • Shell (when needed): tools with nested output directories, headless display handling, simple tool chaining
  5. Does this wrapper need to accept multiple input files? (For fan-in/merge jobs, use action="append" or nargs="+")
  6. Does this wrapper call support files? (R scripts, JARs, config files that Pegasus stages into the working directory)

Step 3: Select Reference Pattern

Based on user answers, read the closest existing example:

| Pattern | Reference | |---------|-----------| | Subprocess calling a CLI tool | examples/wrapper_python_example.py | | API fetch (requests) | examples/workflow_generator_earthquake.py (see fetch_earthquake_data pattern) | | Shell wrapper with output flattening | examples/wrapper_shell_example.sh | | ML training wrapper | examples/workflow_generator_soilmoisture.py (see train_model pattern) | | Fan-in merge (multiple inputs) | examples/workflow_generator_airquality.py (see merge pattern) |

Read the selected reference before generating code.

Step 4: Generate the Wrapper

For Python wrappers:

Start from pegasus-templates/wrapper_template.py and customize:

  1. Docstring: Describe what this step does
  2. argparse arguments: Must match what the workflow_generator.py will pass via add_args()
  3. os.makedirs: Create output subdirectories before writing (any path with /)
  4. Tool invocation: Use subprocess.run() for CLI tools, or call Python libraries directly
  5. Exit code propagation: sys.exit(result.returncode) after subprocess
  6. Structured logging: Use logging module with logger.info() for inputs, commands, and results
  7. Output verification: Check the output file exists before exiting

For shell wrappers:

Start from pegasus-templates/wrapper_template.sh and customize:

  1. set -euo pipefail: Always include
  2. Argument parsing: case statement to extract named arguments
  3. Tool execution: Call the tool with parsed arguments
  4. Output flattening: Copy expected output files from nested directories to the working directory root
  5. Headless handling (if needed): unset DISPLAY, xvfb-run fallback

Critical Rules

  1. Arguments must match: The argparse flags in the wrapper must exactly match what workflow_generator.py passes in add_args(). Show the user both sides.
  2. No directory scanning: Never use glob(), os.listdir(), list.files(), or find to discover input files. Accept them explicitly via arguments.
  3. Support files via os.getcwd(): If the wrapper needs a support file (R script, JAR), find it with os.path.join(os.getcwd(), "filename") — NOT relative to __file__.
  4. Create subdirectories: Any output path containing / needs os.makedirs(os.path.dirname(output), exist_ok=True).
  5. Print the command: Always log the command being run — this is essential for debugging via pegasus-analyzer.

Step 5: Show Integration

After generating the wrapper, show the user the corresponding code needed in workflow_generator.py:

  1. Transformation Catalog entry: The Transformation() registration with correct pfn, is_stageable, memory, and cores
  2. Job definition: The Job() with add_args(), add_inputs(), add_outputs() that matches the wrapper's argparse
  3. Replica Catalog entry (if the wrapper uses support files): rc.add_replica() for R scripts, JARs, etc.

This ensures the wrapper and workflow generator stay in sync.

Full Workflow Repositories

For complete wrapper scripts beyond the examples:

  • https://github.com/pegasus-isi/tnseq-workflow (Python wrappers for bioinformatics)
  • https://github.com/pegasus-isi/earthquake-workflow (API fetch wrappers)
  • https://github.com/pegasus-isi/mag-workflow (shell wrappers with output flattening)

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/pegasus-wrapper-script-generator-mm5t8bgg/download' --output '.skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg/SKILL.md.part' && mv '.skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg/SKILL.md.part' '.skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg/SKILL.md' && test -s '.skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/pegasus-wrapper' && cp -R '.skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg' '.claude/skills/pegasus-wrapper'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg'

openskills read 'pegasus-wrapper-script-generator-mm5t8bgg'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/pegasus-wrapper-script-generator-mm5t8bgg/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills