Overview
This skill provides a systematic approach to managing the lifecycle of automation scripts (scripts/*.sh, scripts/*.ps1, scripts/*.ts) in accordance with workspace standards. It ensures scripts are properly registered in SCRIPTS.md, have strict version bumps, handle dependencies, and follow deprecation protocols (90-day notice).
When to Use This Skill
Create New Script:
- Trigger: "Create a new script for X"
- Action: Generate
.tsor paired.sh/.ps1files, add execution permissions, and register inSCRIPTS.mdasactiveversion1.0.0.
Update Existing Script:
- Trigger: "Update the build script"
- Action: Modify the script, bump the version in
SCRIPTS.md, and updateREADME.mdviagenerate-scripts-readme.ts.
Deprecate Script:
- Trigger: "Deprecate the old sync script"
- Action: Set
status: deprecatedandremoval-date(current date + 90 days) inSCRIPTS.md.
Lifecycle Management Rules
- Ownership Layers:
- L0 (SSOT):
scripts/(workspace root). All development and registry (SCRIPTS.md) live here. - L1 (Template snapshot):
templates/common/scripts/. Publish explicitly:bun run propagate:apply. - L2 (Project):
<project>/scripts/. Snapshot of L1 atnew-projectcreation time. - Never edit L1 directly; edit L0 and publish.
- State Management:
active: In production use, bump version on change.deprecated: Scheduled for removal, requiresremoval-date.experimental: Unstable, not auto-propagated.
- Dependency Tracking:
- Must explicitly list dependencies in the
depends_oncolumn ofSCRIPTS.md.
- Encoding & Compatibility:
- All
.ps1files must include UTF-8 encoding safeguard:$OutputEncoding = [Console]::OutputEncoding = [System.Text.Encoding]::UTF8; - This assignment must be placed after the
param()block. PowerShell rejects any executable statement beforeparam()withUnexpectedAttribute, aborting the entire script.
- PS5.1 Error Propagation:
- When a
.ps1script invokes another script with the&operator,ErrorActionPreference=Stopis inherited by the child. Git writes informational output to stderr even on success, which triggersNativeCommandErrorunderStop. Allgitcalls (clone,pull,add,commit,rev-parse, etc.) must use:
```powershell
try { git <command> 2>&1 | Out-Null } catch { }
```
Step-by-Step Execution
Step 1: Script Implementation
Implement the requested logic in the appropriate script file. If adding a new script, ensure both .sh and .ps1 pairs are created (or use .ts for cross-platform). Apply the UTF-8 safeguard to .ps1 files.
Step 2: Update Registry
Update the scripts/SCRIPTS.md registry (L0 SSOT) with the new version, status, and any dependencies. After making changes, run bun run propagate:apply to propagate to L1.
Step 3: Auto-generate Documentation
Run the generate-scripts-readme.ts script to ensure README.md is synchronized with SCRIPTS.md.
Step 4: Verification
Run bun scripts/verify-scripts.ts (if available) to ensure dependencies are valid and no circular dependencies exist.
L3 Projects: When registering a new script in an L3 project's
scripts/SCRIPTS.md, usesource: L2(the script's origin layer — the L2 variant template it was scaffolded from) andlayer: L0+L1(notL0). Scripts placed inscripts/<variant>/subdirectories should be registered in the sub-registry atscripts/<variant>/SCRIPTS.md, not the main registry. See §6.5 Script Lifecycle Management for Tier 3 filtering details.