From psake
PowerShell build automation tool for creating task-based build scripts. Use when Claude needs to create, modify, or troubleshoot psake build scripts (psakefile.ps1), automate builds for .NET/Node.js/Docker projects, set up CI/CD pipelines with psake (GitHub Actions, Azure Pipelines, GitLab CI), or work with PowerShell-based build automation. Triggers include mentions of psake, psakefile, PowerShell build scripts, Invoke-psake, build task dependencies, psake caching, PsakeBuildResult, or Get-PsakeBuildPlan.
How this skill is triggered — by the user, by Claude, or both
Slash command
/psake:psakeThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
psake is a PowerShell build automation tool using a DSL for task-based builds with dependencies. psake v5 introduces a two-phase compile/run model, declarative syntax, file-based caching, and structured output.
psake is a PowerShell build automation tool using a DSL for task-based builds with dependencies. psake v5 introduces a two-phase compile/run model, declarative syntax, file-based caching, and structured output.
What kind of build are you creating?
Build complexity?
# Install
Install-Module -Name psake -Scope CurrentUser -Force
# Run
Invoke-psake # Run 'Default' task
Invoke-psake -taskList Build, Test # Run specific tasks
Invoke-psake -docs # Show task documentation
Invoke-psake -OutputFormat JSON # JSON output for CI
Version 5
Properties {
$BuildDir = Join-Path $PSScriptRoot 'build'
}
Task Default -depends Build
Task Clean {
if (Test-Path $BuildDir) { Remove-Item $BuildDir -Recurse -Force }
New-Item -ItemType Directory -Path $BuildDir -Force | Out-Null
}
Task Build -depends Clean {
exec { dotnet build -o $BuildDir }
}
Task Test -depends Build {
exec { dotnet test }
}
Two equivalent syntaxes — use whichever reads better for your build:
# Classic syntax (works in v4 and v5)
Task Build -depends Clean -description "Compile project" {
exec { dotnet build }
}
# Declarative syntax (v5 — hashtable with validated keys)
Task 'Build' @{
DependsOn = 'Clean'
Description = 'Compile project'
Action = { exec { dotnet build } }
}
The declarative syntax validates keys at parse time — typos like DependOn throw immediately. Valid keys: Action, DependsOn, Inputs, Outputs, PreAction, PostAction, PreCondition, PostCondition, ContinueOnError, Description, Alias, RequiredVariables.
Tasks with Inputs and Outputs are content-addressed cached in .psake/cache/. If input file hashes haven't changed and output files exist, the task is skipped.
Task 'Build' @{
DependsOn = 'Clean'
Inputs = 'src/**/*.cs', 'src/**/*.csproj'
Outputs = 'bin/**/*.dll'
Action = { exec { dotnet build -c $Configuration } }
}
Inputs/Outputs also accept scriptblocks for dynamic file resolution:
Task 'Build' @{
Inputs = { Get-ChildItem src -Recurse -Include *.cs }
Outputs = { Get-ChildItem bin -Recurse -Include *.dll -ErrorAction SilentlyContinue }
Action = { exec { dotnet build } }
}
Use Clear-PsakeCache to force a full rebuild, or Invoke-psake -NoCache for a single run.
Task Deploy -precondition { $env:CI -eq 'true' } -description "Deploy to prod" {
exec { ./deploy.ps1 }
}
Variables available to all tasks. Can be overridden via -properties parameter.
# Scriptblock syntax
Properties {
$Configuration = 'Release'
$Version = '1.0.0'
}
# Hashtable syntax (v5)
Properties @{
Configuration = 'Release'
Version = '1.0.0'
}
Override: Invoke-psake -properties @{ Configuration = 'Debug' }
Pin your build script to a psake major version. The compile phase rejects version mismatches.
Version 5
Runs external commands, fails build on non-zero exit:
exec { dotnet build } # Basic
exec { npm install } "npm install failed" # Custom error
exec { nuget restore } -maxRetries 3 # Retry flaky ops
exec { npm test } -workingDirectory './frontend' # Different directory
exec { ./slow-build.ps1 } -TimeoutSeconds 600 # Timeout (v5)
Assert (Test-Path $SrcDir) "Source directory not found"
Assert (-not [string]::IsNullOrEmpty($ApiKey)) "API key required"
Include "./shared/common-tasks.ps1"
FormatTaskName "▶ {0}"
# Or with scriptblock:
FormatTaskName { param($taskName) Write-Host "[$taskName]" -ForegroundColor Cyan }
TaskSetup { Write-Host "Starting: $($psake.context.currentTaskName)" }
TaskTearDown { Write-Host "Finished: $($psake.context.currentTaskName)" }
Invoke-psake returns a PsakeBuildResult object:
$result = Invoke-psake -Quiet
$result.Success # $true / $false
$result.Duration # TimeSpan
$result.Tasks # PsakeTaskResult[] with Name, Status, Duration, Cached
$result.ErrorMessage # Error details if failed
The $psake.build_success variable is still set after each build for backward compatibility.
For CI pipelines, use JSON output:
Invoke-psake -OutputFormat JSON
| Parameter | Description |
|---|---|
-buildFile | Path to build script (default: psakefile.ps1) |
-taskList | Tasks to execute (default: 'Default') |
-parameters | Hashtable passed to build script (set before Properties) |
-properties | Hashtable to override Properties block (set after Properties) |
-docs | Display task documentation |
-nologo | Suppress banner |
-OutputFormat | Default, JSON, or GitHubActions (v5) |
-NoCache | Bypass task caching for this run (v5) |
-CompileOnly | Return build plan without executing (v5) |
-Quiet | Suppress console output; still returns PsakeBuildResult (v5) |
$plan = Get-PsakeBuildPlan -BuildFile './psakefile.ps1'
$plan.ExecutionOrder # ['Clean', 'Build', 'Test', 'Default']
$plan.TaskMap['build'].DependsOn # ['Clean']
$plan.IsValid # $true
$plan.ValidationErrors # @()
The plan can also be piped into Invoke-psake:
Get-PsakeBuildPlan | Invoke-psake
$result = Test-PsakeTask -BuildFile './psakefile.ps1' -TaskName 'Build' -Variables @{
Configuration = 'Debug'
}
$result.Status # 'Executed'
$result.Duration # TimeSpan
Properties {
$Env = if ($env:ENVIRONMENT) { $env:ENVIRONMENT } else { 'Development' }
}
Task Deploy {
switch ($Env) {
'Production' { exec { ./deploy-prod.ps1 } }
default { Write-Host "Skipping deploy for $Env" }
}
}
Task BuildAll -depends BuildBackend, BuildFrontend
Task BuildBackend {
Push-Location ./backend
try { exec { dotnet build } }
finally { Pop-Location }
}
Task BuildFrontend {
Push-Location ./frontend
try { exec { npm run build } }
finally { Pop-Location }
}
Tasks don't share local variables. Use $script: scope to pass data between dependent tasks:
Task GetFiles {
$script:Files = Get-ChildItem -Path $SrcDir -Filter *.ps1
}
Task ProcessFiles -depends GetFiles {
foreach ($file in $script:Files) {
# Process each file
}
}
Note: psake tasks don't have return values.
$script:scoped variables are the recommended approach for task-to-task data sharing.
The compile phase catches circular dependencies, missing tasks, and version mismatches before any task runs:
$plan = Get-PsakeBuildPlan -BuildFile './psakefile.ps1'
if (-not $plan.IsValid) {
$plan.ValidationErrors | ForEach-Object { Write-Error $_ }
} else {
Write-Host "✓ Build plan valid — execution order: $($plan.ExecutionOrder -join ' → ')"
}
$errors = $null
$null = [System.Management.Automation.Language.Parser]::ParseFile(
(Resolve-Path 'psakefile.ps1'), [ref]$null, [ref]$errors
)
if ($errors) { $errors | ForEach-Object { Write-Error $_.ToString() } }
else { Write-Host "✓ Syntax valid" -ForegroundColor Green }
| Problem | Solution |
|---|---|
| Build fails but CI shows success | Use exec { } for all external commands |
| Cross-platform path issues | Use Join-Path instead of \ or / |
| Module not found in CI | Install-Module -Name psake -Scope CurrentUser -Force |
| Properties not overriding | Use -properties (not -parameters) to override Properties block |
| Variable undefined in dependent task | Use $script:VarName to share data between tasks |
| Circular dependency error | Check Get-PsakeBuildPlan output for ValidationErrors |
| Task skipped unexpectedly | May be cached — run with -NoCache or Clear-PsakeCache |
default.ps1 not found | v5 removed default.ps1 fallback — rename to psakefile.ps1 |
npx claudepluginhub psake/psake-llm-tools --plugin psakeProvides PowerShell 7+ expertise for cross-platform scripting, CI/CD automation (GitHub Actions/Azure DevOps), module management (PSGallery), and cloud tasks (Azure/AWS/M365).
Authoring MSBuild targets, props, or conditions. Custom targets, incrementality, Build patterns.
Generates Makefiles for C/C++, Python, Go, Java projects with .PHONY targets, GNU standards, standard targets, security hardening, and CI/CD integration.