Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Pwsh Filesystem

BSecurity

Filesystem operations in PowerShell and the Unix-command equivalents (head/tail/which/touch/mkdir -p/rm -rf/ln -s/wc -l). Use when you need to list/find/copy/move/delete files, handle paths with spaces, create or remove directories safely, make symlinks, read first/last N lines, or translate a bash file command into PowerShell. Covers safety traps like Remove-Item prompts and New-Item -Force truncation. 5.1 and 7+.

9 stars
0 votes
0 copies
0 views
Added 9/27/2026
ai-agentsshellbash

Works with

cli

Security Analysis

B85/100
highPerforms destructive filesystem operations

Pro shows the line behind each finding and how to fix it

Scanned 9/27/2026

$npx -y skills add Ugbot/ai-grind --skill pwsh-filesystem --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Pwsh Filesystem?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Pwsh Filesystem
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/ugbot-pwsh-filesystem/badge)](https://www.skillsdirectory.com/skills/ugbot-pwsh-filesystem)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
name: pwsh-filesystem
description: >
  Filesystem operations in PowerShell and the Unix-command equivalents
  (head/tail/which/touch/mkdir -p/rm -rf/ln -s/wc -l). Use when you need to
  list/find/copy/move/delete files, handle paths with spaces, create or remove
  directories safely, make symlinks, read first/last N lines, or translate a bash
  file command into PowerShell. Covers safety traps like Remove-Item prompts and
  New-Item -Force truncation. 5.1 and 7+.
---

# PowerShell filesystem operations

Behavior is the same in 5.1 and 7+ unless noted. Quote any path containing spaces
with double quotes; prefer `Join-Path` over string concatenation.

## Unix → PowerShell command map

| Unix | PowerShell |
|---|---|
| `ls` | `Get-ChildItem` (alias `gci`, `ls`, `dir`) |
| `ls -la` | `Get-ChildItem -Force` |
| `find . -name '*.ts'` | `Get-ChildItem -Recurse -Filter *.ts` |
| `head -n 20 f` | `Get-Content f -TotalCount 20` |
| `tail -n 20 f` | `Get-Content f -Tail 20` |
| `tail -f f` | `Get-Content f -Wait -Tail 10` |
| `wc -l f` | `(Get-Content f \| Measure-Object -Line).Lines` |
| `which tool` | `(Get-Command tool).Source` |
| `cat a b > c` | `Get-Content a, b \| Set-Content c` |
| `cp -r a b` | `Copy-Item a b -Recurse` |
| `mv a b` | `Move-Item a b` |
| `rm f` | `Remove-Item f` |
| `rm -rf d` | `Remove-Item d -Recurse -Force` |
| `mkdir -p a/b/c` | `New-Item -ItemType Directory -Force a/b/c` |
| `touch f` | see "touch" below; do NOT use `New-Item -Force` |
| `ln -s tgt lnk` | `New-Item -ItemType SymbolicLink -Path lnk -Target tgt` |
| `pwd` | `Get-Location` (alias `pwd`) |
| `realpath f` | `(Resolve-Path f).Path` |
| `basename f` | `Split-Path f -Leaf` |
| `dirname f` | `Split-Path f -Parent` |

## Safety traps (read these)

### `touch`, and never `New-Item -Force` on an existing file

`New-Item -ItemType File -Force f` **truncates** an existing file. To touch safely:

```powershell
if (-not (Test-Path $f)) { New-Item -ItemType File $f | Out-Null }
else { (Get-Item $f).LastWriteTime = Get-Date }     # update mtime only
```

### `Remove-Item` can prompt and hang automation

Deleting read-only/hidden items or non-empty dirs may prompt. In non-interactive
contexts a prompt = a hang. Be explicit:

```powershell
Remove-Item $path -Recurse -Force -Confirm:$false
```

`-Force` covers read-only/hidden; `-Confirm:$false` suppresses the confirmation.

### `mkdir -p` equivalent

`New-Item -ItemType Directory -Force a/b/c` creates the whole chain and does **not**
error if it already exists. (`-Force` on a directory is safe, unlike on a file.)

## Listing, filtering, finding

```powershell
Get-ChildItem -Recurse -File -Filter *.log              # all .log files, recursive
Get-ChildItem -Recurse -Directory                       # directories only
Get-ChildItem | Where-Object Length -gt 10MB            # files over 10 MB
Get-ChildItem -Recurse -File |
    Sort-Object LastWriteTime -Descending |
    Select-Object -First 5 FullName, LastWriteTime      # 5 most-recent files
```

`-Filter` (provider-level, fast) beats `-Include`/`Where-Object` (post-filter) for
simple name globs. Use `Where-Object` for property predicates.

## Reading & writing

```powershell
$text  = Get-Content $f -Raw                 # whole file as ONE string
$lines = Get-Content $f                       # array of lines
'line' | Add-Content $f -Encoding utf8        # append
$obj | Set-Content $f -Encoding utf8          # overwrite (always set -Encoding; see pwsh-core-idioms)
```

Always pass `-Encoding utf8` when another program reads the file. 5.1 defaults
to UTF-16-with-BOM.

## Paths: build them, don't concatenate

```powershell
$p = Join-Path $root 'src' 'main.ts'          # OS-correct separators (7+ takes multiple parts)
$p = Join-Path (Join-Path $root 'src') 'main.ts'   # 5.1: two args at a time
Test-Path $p                                   # exists?
Test-Path $p -PathType Leaf                    # exists AND is a file
Split-Path $p -Parent                          # dirname
[System.IO.Path]::ChangeExtension($p, '.bak')  # .NET helpers when needed
```

`$PSScriptRoot` is the directory of the running script. Use it to locate files
relative to the script, never the (unpredictable) current directory.

## Copy/move/rename

```powershell
Copy-Item $src $dst -Recurse -Force            # dir or file
Move-Item $src $dst -Force
Rename-Item $f 'newname.txt'
robocopy $srcDir $dstDir /MIR /NFL /NDL        # large/mirrored copies; robocopy exit codes 0-7 = success
```

`robocopy` returns 0 to 7 on success (8 and up is failure), so don't treat its non-zero
"files copied" codes as errors.

## Bulk operations

```powershell
Get-ChildItem -Recurse -Filter *.tmp | Remove-Item -Force          # delete all .tmp
Get-ChildItem *.jpeg | Rename-Item -NewName { $_.Name -replace '\.jpeg$','.jpg' }
Get-ChildItem -Recurse -File | Measure-Object Length -Sum          # total size
```

## Quick reference

| Need | Command |
|---|---|
| first/last N lines | `Get-Content f -TotalCount N` / `-Tail N` |
| recursive find | `Get-ChildItem -Recurse -Filter *.ext` |
| make dir tree | `New-Item -ItemType Directory -Force p` |
| safe delete | `Remove-Item p -Recurse -Force -Confirm:$false` |
| safe touch | `if(-not(Test-Path f)){New-Item -ItemType File f}` |
| which | `(Get-Command tool).Source` |
| symlink | `New-Item -ItemType SymbolicLink -Path l -Target t` |
| script's own dir | `$PSScriptRoot` |

Attribution

UgbotUgbot
View sourceSee grades on GitHubMore from Ugbot →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

Caveman

Terse caveman voice: answer first, fluff gone, every technical fact kept. Use for /caveman, "caveman mode", "talk like caveman", "be brief", "less tokens". Stays on until "stop caveman" or "normal mode".

1100021 votes

Hyperplan

Adversarial multi-agent planning skill. Self-orchestrates 5 hostile category members (unspecified-low, unspecified-high, deep, ultrabrain, artistry) via team-mode for ruthless cross-critique debate, distills only the defensible insights, then MANDATORILY hands the distilled insight bundle to the `plan` agent for executable plan formalization. Use when planning needs maximum rigor and surfacing of weak assumptions, blind spots, and over-engineering. Triggers: 'hyperplan', 'hpp', '/hyperplan', ...

698621 votes

Writing Skills

Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dep...

3931 votes

Mcp Code Execution

Routes multi-tool workflows through MCP servers for large datasets and pipelines. Use when Bash tool overhead is limiting throughput on data-heavy tasks.

3421 votes

catchup

Recovers the conversation and failed tool calls of a previous Codex, Amp, Claude Code, Antigravity, Cline, Copilot CLI, Cursor, DeepSeek Harness, Grok Build, Kimi, OpenCode, Pi Agent, or ZCode session. Use when the user says "catch up", "what did the last session do", "get me up to speed", "I switched agents", asks to recover/summarize a previous session before continuing, or asks to diagnose or report a catchup failure. Do NOT use for the current conversation, git history, or any non-agent log.

741 votes
View all in ai-agents →