ClawKit Logo
ClawKitReliability Toolkit
Back to Registry
Official Verified

powershell-safe-chain

Chain PowerShell commands safely without &&. Use try/catch, ErrorAction, and proper sequencing for reliable Windows execution.

skill-install — Terminal

Install via CLI (Recommended)

clawhub install openclaw/skills/skills/dalomeve/powershell-safe-chain
Or

PowerShell Safe Chain

Chain commands reliably on Windows PowerShell. No && anti-patterns.

Problem

PowerShell differs from bash:

  • && does NOT work for command chaining
  • Parameter parsing is case-insensitive but strict
  • Errors continue by default (no fail-fast)
  • Path separators vary (\ vs /)

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 -WhatIf

3. Splatting for Complex Commands

$params = @{
    Path = $filePath
    Encoding = 'UTF8'
    Force = $true
}
Set-Content @params

Executable Completion Criteria

CriteriaVerification
No && in scriptsSelect-String '&&' *.ps1 returns nothing
ErrorAction setSelect-String 'ErrorAction' *.ps1 matches
try/catch present`Select-String 'try
Paths use Join-PathSelect-String 'Join-Path' *.ps1 matches

Privacy/Safety

  • No hardcoded credentials
  • Use [SecureString] for passwords
  • Environment variables via $env:VAR

Self-Use Trigger

Use when:

  • Writing any PowerShell script
  • Chaining 2+ commands
  • Executing file operations

Chain safely. Fail explicitly.

Metadata

Author@dalomeve
Stars3376
Views1
Updated2026-03-24
View Author Profile
AI Skill Finder

Not sure this is the right skill?

Describe what you want to build — we'll match you to the best skill from 16,000+ options.

Find the right skill
Add to Configuration

Paste this into your clawhub.json to enable this plugin.

{
  "plugins": {
    "official-dalomeve-powershell-safe-chain": {
      "enabled": true,
      "auto_update": true
    }
  }
}
Safety NoteClawKit audits metadata but not runtime behavior. Use with caution.