powershell-safe-chain

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

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "powershell-safe-chain" with this command: npx skills add powershell-safe-chain

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.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Web3

Stock Trader

Trade stocks, options, and crypto on brokerages, including Robinhood, ETrade, Charles Schwab, Webull, Public, Tastytrade, Coinbase, and Kraken, via the Trade...

Registry SourceRecently Updated
Web3

Skill Creator

Create, update, evaluate, and manage skills across agents by defining intent, drafting, testing, benchmarking, iterating, and distributing them within a 2-la...

Registry SourceRecently Updated
Web3

Social Brand Voice

Brand voice guide creator for social media. Define your brand's tone, vocabulary, writing rules, and examples across platforms — so every post sounds consist...

Registry SourceRecently Updated
1290Profile unavailable
Web3

Social Content Pillars

Content pillar strategy builder for brands and creators. Define 5 core content pillars, generate 50+ post ideas, and build a repeatable content system that b...

Registry SourceRecently Updated
1170Profile unavailable