PowerShell Safe Chain
name: powershell-safe-chain
by dalomeve · published 2026-03-22
$ claw add gh:dalomeve/dalomeve-powershell-safe-chain---
name: powershell-safe-chain
description: Chain PowerShell commands safely without &&. Use try/catch, ErrorAction, and proper sequencing for reliable Windows execution.
---
# PowerShell Safe Chain
Chain commands reliably on Windows PowerShell. No `&&` anti-patterns.
Problem
PowerShell differs from bash:
Workflow
1. Safe Chaining Pattern
**Wrong**:
mkdir test && cd test && echo done**Right**:
$ErrorActionPreference = 'Stop'
try {
New-Item -ItemType Directory -Path test -Force
Set-Location test
Write-Host 'done'
} catch {
Write-Error "Failed at step: $_"
exit 1
}2. Conditional Chaining
# If-then pattern
if (Test-Path $file) {
Remove-Item $file
Write-Host "Deleted"
} else {
Write-Warning "File not found"
}
# Pipeline with error handling
Get-Process | Where-Object CPU -GT 100 | Stop-Process -WhatIf3. Splatting for Complex Commands
$params = @{
Path = $filePath
Encoding = 'UTF8'
Force = $true
}
Set-Content @paramsExecutable Completion Criteria
| Criteria | Verification |
|----------|-------------|
| No `&&` in scripts | `Select-String '&&' *.ps1` returns nothing |
| ErrorAction set | `Select-String 'ErrorAction' *.ps1` matches |
| try/catch present | `Select-String 'try|catch' *.ps1` matches |
| Paths use Join-Path | `Select-String 'Join-Path' *.ps1` matches |
Privacy/Safety
Self-Use Trigger
Use when:
---
**Chain safely. Fail explicitly.**
More tools from the same signal band
Order food/drinks (点餐) on an Android device paired as an OpenClaw node. Uses in-app menu and cart; add goods, view cart, submit order (demo, no real payment).
Sign plugins, rotate agent credentials without losing identity, and publicly attest to plugin behavior with verifiable claims and authenticated transfers.
The philosophical layer for AI agents. Maps behavior to Spinoza's 48 affects, calculates persistence scores, and generates geometric self-reports. Give your...