| name | dpla-script-workflow |
| description | Follow the project workflow when adding or modifying shell or Python scripts. Use when the user asks to add a script, create a new script, modify a script, or write a script for a task. Ensures POSIX bash, common.sh, documentation in SCRIPTS.md, and tests are created or updated and run. |
DPLA Script Workflow
Purpose
When adding or modifying scripts in this repo, follow the project's conventions so scripts are documented, portable, and tested.
When to Use
- "Add a script for..."
- "New script to..."
- "Modify script X"
- "Create a script that..."
- "Script for [task]"
Environment: When running the test suite or any script that depends on project env, run source .env from repo root first.
Project Rules (apply to all new/changed scripts)
- Python: Use the virtualenv at
./venv/ (e.g. ./venv/bin/python or source ./venv/bin/activate). Never assume system Python.
- AWS CLI: Use
--profile dpla for any AWS commands.
- Shell scripts: Write POSIX-compliant bash. Avoid macOS- or Linux-specific flags (e.g.
sed -i, readlink -f). Use helpers from scripts/common.sh: sed_i, get_script_dir, get_common_dir, log_info, die, etc.
Workflow Checklist
For new scripts
For modified scripts
Key References
| Resource | Path |
|---|
| Script docs | scripts/SCRIPTS.md |
| Updating docs | SCRIPTS.md section "Updating This Documentation" |
| Shared helpers | scripts/common.sh |
| Test suite | scripts/tests/test-scripts.sh |
Quick Commands
./scripts/tests/test-scripts.sh
./scripts/tests/test-scripts.sh --quick
./scripts/tests/test-scripts.sh --verbose
Example: Adding a new bash script
- Create script under
scripts/ with shebang #!/usr/bin/env bash, set -euo pipefail, and source "$(get_script_dir)/common.sh" (or equivalent via get_common_dir).
- Use
sed_i, get_script_dir, log_info, die instead of raw sed -i or readlink -f.
- Add row to Quick Reference in SCRIPTS.md.
- Add a test in
scripts/tests/test-scripts.sh (e.g. syntax check, help output, or sourcing common.sh).
- Run
./scripts/tests/test-scripts.sh and fix any failures.