Utility scripts directory configuration (/scripts) for MetaSaver monorepos including setup automation, environment management, and cross-platform support. Includes 4 critical standards (setup scripts, cross-platform support, error handling, documentation). Use when creating or auditing /scripts directory with Node.js and shell utility scripts.
Provides templates and validation for MetaSaver monorepo /scripts directories, enforcing 4 critical standards for setup automation, cross-platform compatibility, and error handling. Used when creating or auditing scripts directories with Node.js and shell utility scripts.
/plugin marketplace add metasaver/claude-marketplace/plugin install core-claude-plugin@metasaver-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
templates/setup.sh.templateThis skill provides templates and validation logic for /scripts directory configuration in MetaSaver monorepos.
Manage /scripts directory to:
This skill is invoked by the scripts-agent when:
Standard script templates are located at:
templates/setup.sh.template
Required scripts for all repositories:
| Script | Purpose | Repository Type |
|---|---|---|
| setup-env.js | Generate .env from .env.example files | All repos |
| setup-npmrc.js | Generate .npmrc from .npmrc.template with token replacement | All repos |
| clean-and-build.sh | Clean and rebuild monorepo | All repos |
Additional scripts for consumer repositories:
| Script | Purpose |
|---|---|
| back-to-prod.sh | Switch to GitHub Packages registry |
| use-local-packages.sh | Switch to local Verdaccio registry |
| killport.sh | Cross-platform port management |
Validation:
# Check required scripts exist
[ -f "scripts/setup-env.js" ] || echo "VIOLATION: Missing setup-env.js"
[ -f "scripts/setup-npmrc.js" ] || echo "VIOLATION: Missing setup-npmrc.js"
[ -f "scripts/clean-and-build.sh" ] || echo "VIOLATION: Missing clean-and-build.sh"
# Consumer repos only
if [ "$REPO_TYPE" = "consumer" ]; then
[ -f "scripts/back-to-prod.sh" ] || echo "VIOLATION: Missing back-to-prod.sh"
[ -f "scripts/use-local-packages.sh" ] || echo "VIOLATION: Missing use-local-packages.sh"
[ -f "scripts/killport.sh" ] || echo "VIOLATION: Missing killport.sh"
fi
Requirements for Node.js scripts:
path module for all file paths (do not hardcode slashes)process.platform for OS-specific logic#!/usr/bin/env nodeExample:
const path = require("path");
const envPath = path.join(__dirname, "..", ".env"); // CORRECT - uses path module
// const envPath = '../.env'; // INCORRECT - avoid hardcoded paths
Validation:
# Verify path module usage
grep -q "require.*path" scripts/*.js || echo "VIOLATION: path module must be used"
# Check for hardcoded paths (should not exist)
grep -E "\.\.\/|\.\.\\\\|\.\/" scripts/*.js && echo "WARNING: Hardcoded paths detected - use path module instead"
Required error handling patterns:
try-catch blocks for async operationsconsole.log feedback for success/failureprocess.exit(1) on errorsExample:
try {
// Operation
console.log("Success: Operation completed");
} catch (error) {
console.error("Error: Operation failed -", error.message);
process.exit(1);
}
Validation:
# Check for error handling
grep -q "try.*catch" scripts/*.js || echo "WARNING: No try-catch blocks found"
grep -q "process.exit" scripts/*.js || echo "WARNING: No process.exit calls found"
Required documentation elements:
#!/usr/bin/env node or #!/usr/bin/env bash)README.md structure:
# Scripts Directory
Utility scripts for [repository name].
## Available Scripts
### setup-env.js
Description of what it does and when to use it.
### setup-npmrc.js
Description of what it does and when to use it.
...
Validation:
# Check for shebang
head -n1 scripts/*.js | grep -q "#!/usr/bin/env node" || echo "VIOLATION: Missing shebang"
# Check for README
[ -f "scripts/README.md" ] || echo "VIOLATION: Missing scripts/README.md"
To validate /scripts directory:
# Check directory exists at root
[ -d "scripts" ] || echo "VIOLATION: /scripts directory not found at root"
# Validate against 4 standards (see rules above)
# Report only violations
@metasaver/multi-mono): Core setup scripts only/scripts directory only/scripts (use subdirectories for monorepo workspaces only)chmod +x instructions for shell scriptspath module consistently (avoid hardcoded paths)This skill integrates with:
scope parameter. If not provided, use /skill scope-check/skill audit-workflow - Bi-directional comparison workflow/skill remediation-options - Conform/Update/Ignore choicespackage-scripts-agent - For npm scripts that invoke /scripts utilities