AgentSkillsCN

shell

执行跨平台Shell命令(Windows上的PowerShell,Unix/Linux/Mac上的Bash),用于文件操作、文本处理以及系统任务。提供安全的命令执行功能,并需用户确认。

SKILL.md
--- frontmatter
name: shell
description: Execute cross-platform shell commands (PowerShell on Windows, Bash on Unix/Linux/Mac) for file operations, text processing, and system tasks. Provides safe command execution with user confirmation.
license: MIT

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

TaskWindows (PowerShell)Linux/Mac (Bash)
List filesGet-ChildItem or dirls -la
Read fileGet-Content file.txt or type file.txtcat file.txt
Copy fileCopy-Item src.txt dst.txtcp src.txt dst.txt
Move fileMove-Item old.txt new.txtmv old.txt new.txt
Delete fileRemove-Item file.txtrm file.txt
Create directoryNew-Item -ItemType Directory dirname or mkdir dirnamemkdir dirname
Current directoryGet-Location or pwdpwd
Environment vars$env:PATH$PATH
Echo textWrite-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

⚠️ 关键规则

  1. 只使用真实存在的系统命令,不要编造命令(如 analyze_projectsummarize_files 等不存在)
  2. 复杂任务要拆分成多个基础命令,不要期望有一个命令能完成所有事情
  3. Always check the platform info provided in the context (Windows/Linux/Mac)
  4. 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 -Recursefind . -type fls -laR
查看文件内容Get-Content file.txtcat file.txt
搜索文件内容Select-String "pattern" *.pygrep -r "pattern" .
统计文件数量(Get-ChildItem -Recurse -File).Countfind . -type f | wc -l
查看目录结构tree /FGet-ChildItem -Recursetreefind . -type d

Example context you'll receive:

json
{
  "platform_info": {
    "platform": "win32",
    "os_name": "Windows",
    "shell_type": "powershell"
  }
}