Shell Skill
Execute cross-platform shell commands safely with user confirmation.
Platform-Specific Commands
This skill uses different shells based on the operating system:
- •Windows: PowerShell
- •Linux/Mac: Bash
Important: You must generate platform-appropriate commands based on the system information provided in the context.
Common Command Differences
| Task | Windows (PowerShell) | Linux/Mac (Bash) |
|---|---|---|
| List files | Get-ChildItem or dir | ls -la |
| Read file | Get-Content file.txt or type file.txt | cat file.txt |
| Copy file | Copy-Item src.txt dst.txt | cp src.txt dst.txt |
| Move file | Move-Item old.txt new.txt | mv old.txt new.txt |
| Delete file | Remove-Item file.txt | rm file.txt |
| Create directory | New-Item -ItemType Directory dirname or mkdir dirname | mkdir dirname |
| Current directory | Get-Location or pwd | pwd |
| Environment vars | $env:PATH | $PATH |
| Echo text | Write-Output "text" or echo "text" | echo "text" |
| Save to file | `"text" | Out-File file.txtorecho "text" > file.txt` |
Capabilities
- •File Operations: copy, move, read, write files (cross-platform)
- •Text Processing: search, filter, transform text
- •Directory Management: list, create, navigate directories
- •Process Management: list processes, check status
Safety Features
- •User confirmation required before execution
- •Dangerous commands blocked (rm -rf, sudo, chmod 777, etc.)
- •Command sandboxing and timeout limits
- •Cross-platform safety checks
Usage Examples
File Operations
Windows PowerShell:
powershell
# Copy file Copy-Item source.txt destination.txt # Move file Move-Item old_name.txt new_name.txt # Create directory New-Item -ItemType Directory my_directory # or simply: mkdir my_directory # List files Get-ChildItem # or: dir # or: ls (alias)
Linux/Mac Bash:
bash
# Copy file cp source.txt destination.txt # Move file mv old_name.txt new_name.txt # Create directory mkdir my_directory # List files ls -la
Text Processing
Windows PowerShell:
powershell
# Search in file
Select-String "pattern" file.txt
# Count lines
(Get-Content file.txt).Count
# Filter and display
Get-Content file.txt | Where-Object { $_ -match "pattern" }
Linux/Mac Bash:
bash
# Search in file grep "pattern" file.txt # Replace text sed 's/old/new/g' file.txt # Count lines wc -l file.txt
Save Content to File
Windows PowerShell:
powershell
# Save text to file @" Your content here Multiple lines "@ | Out-File output.txt # Or using echo echo "New line" > file.txt # Append to file echo "New line" >> file.txt
Linux/Mac Bash:
bash
# Save text to file cat > output.txt << 'EOF' Your content here Multiple lines EOF # Append to file echo "New line" >> file.txt
Restrictions
The following dangerous operations are blocked:
- •
rm -rf- Recursive force delete - •
sudo- Elevated privileges - •
chmod 777- Unsafe permissions - •
mkfs- Format filesystem - •
dd- Disk operations - •
:(){ :|:& };:- Fork bombs - •Commands with
>to system files (/dev/,/etc/,/bin/) - •Pipe to shell execution (
curl ... | bash,wget ... | sh)
Security
- •All commands require user approval
- •Maximum execution timeout: 30 seconds
- •Working directory restricted
- •Platform-specific shell execution (PowerShell on Windows, Bash on Unix)
Notes for LLM
⚠️ 关键规则:
- •只使用真实存在的系统命令,不要编造命令(如
analyze_project、summarize_files等不存在) - •复杂任务要拆分成多个基础命令,不要期望有一个命令能完成所有事情
- •Always check the platform info provided in the context (Windows/Linux/Mac)
- •Generate platform-appropriate commands:
- •For Windows: Use PowerShell cmdlets (Get-ChildItem, Get-Content, Select-String, etc.)
- •For Linux/Mac: Use standard Unix/Bash commands (ls, cat, grep, find, etc.)
常见任务的正确命令
| 用户需求 | Windows (PowerShell) | Linux/Mac (Bash) |
|---|---|---|
| 遍历目录文件 | Get-ChildItem -Recurse | find . -type f 或 ls -laR |
| 查看文件内容 | Get-Content file.txt | cat file.txt |
| 搜索文件内容 | Select-String "pattern" *.py | grep -r "pattern" . |
| 统计文件数量 | (Get-ChildItem -Recurse -File).Count | find . -type f | wc -l |
| 查看目录结构 | tree /F 或 Get-ChildItem -Recurse | tree 或 find . -type d |
Example context you'll receive:
json
{
"platform_info": {
"platform": "win32",
"os_name": "Windows",
"shell_type": "powershell"
}
}