| name | windows-rg-safe |
| description | Use on Windows before running ripgrep, rg --files, recursive text search, or file discovery when WindowsApps permission-denied noise may block or pollute results. Provides a safe rg workflow that resolves the real rg.exe and excludes WindowsApps, node_modules, .git, and other noisy paths. |
Windows rg Safe
Use for Windows search tasks, especially under C:\Users\sun, repo roots, Codex config, or broad home-directory scans.
Rule
Before any broad rg or rg --files on Windows:
- Prefer bundled real
rg.exe from Get-Command rg -All, but reject paths containing \WindowsApps\.
- Always pass
--glob '!**/WindowsApps/**'.
- For broad home scans, also exclude
AppData/Local/Packages, node_modules, .git, .venv, dist, build, .next, .cache.
- If
rg still errors on access denied, narrow the search root before retrying.
- If no valid
rg.exe exists, fallback to PowerShell Get-ChildItem + Select-String with -ErrorAction SilentlyContinue.
Helper
Run bundled helper when command construction is annoying:
& "$env:USERPROFILE\.codex\skills\windows-rg-safe\scripts\safe-rg.ps1" -Pattern "gpt-5\.4|gpt5\.4" -Path "$env:USERPROFILE\.codex"
File listing:
& "$env:USERPROFILE\.codex\skills\windows-rg-safe\scripts\safe-rg.ps1" -Files -Path "E:\JPsub2api"
Extra rg args:
& "$env:USERPROFILE\.codex\skills\windows-rg-safe\scripts\safe-rg.ps1" -Pattern "TODO" -Path "." -RgArgs @("-n", "--hidden")
Direct Pattern
If writing command manually:
$rg = Get-Command rg -All -ErrorAction SilentlyContinue |
Where-Object { $_.Path -and $_.Path -notlike '*\WindowsApps\*' } |
Select-Object -First 1 -ExpandProperty Path
& $rg --hidden --glob '!**/WindowsApps/**' --glob '!**/.git/**' --glob '!**/node_modules/**' "pattern" "path"