System Commander
When to Use
Activate this skill when:
- - User asks for file processing, text manipulation, or data extraction
- Task can be solved with Linux/Python commands
- Goal is to minimize AI inference and maximize efficiency
- Keywords: "system command", "linux", "bash", "one-liner", "file processing"
Core Philosophy: System First, AI Last
Before any AI reasoning, try these in order:
- 1. Pure Linux tools -
awk, sed, grep, cut, tr, sort, INLINECODE6 - Linux + file tools -
find, xargs, parallel, jq, INLINECODE11 - Python one-liners - Quick scripts for complex logic
- AI subordinate - Only when above won't suffice
Command Patterns by Task Type
File Operations
| Task | System Solution | AI Solution |
|---|
| List large files | INLINECODE12 | ❌ Don't delegate |
| Count lines |
wc -l file.txt | ❌ Don't delegate |
| Search text |
grep -r "pattern" . | ❌ Don't delegate |
| Replace text |
sed -i 's/old/new/g' file | ❌ Don't delegate |
| Extract column |
awk -F',' '{print $2}' file.csv | ❌ Don't delegate |
Data Processing
| Task | System Solution | AI Solution |
|---|
| JSON query | INLINECODE17 | ❌ Don't delegate |
| CSV manipulation |
csvcut -c 1,3 file.csv | ❌ Don't delegate |
| Sort & unique |
sort file uniq -c | ❌ Don't delegate |
| Join files |
join -t',' file1 file2 | ❌ Don't delegate |
Text Processing
| Task | System Solution | AI Solution |
|---|
| Line extraction | INLINECODE21 | ❌ Don't delegate |
| Word count |
tr ' ' '\n' sort uniq -c | ❌ Don't delegate |
| Format conversion |
iconv -f UTF-8 -t ASCII | ❌ Don't delegate |
Response Format
When generating commands:
- 1. Provide the command (ready to copy-paste)
- Explain what it does (brief)
- Show expected output (example)
- Note alternatives (if applicable)
Examples
Example 1: Extract Email Addresses
User: "Extract all email addresses from this log file"
System Commander Response:
CODEBLOCK0
Example 2: Count Files by Extension
User: "Count how many files of each type are in this directory"
System Commander Response:
CODEBLOCK1
Example 3: Parse JSON Values
User: "Get all 'status' values from this JSON file"
System Commander Response:
CODEBLOCK2
Example 4: Batch Rename Files
User: "Rename all .txt files to .bak"
System Commander Response:
CODEBLOCK3
Advanced Patterns
Parallel Processing
CODEBLOCK4
Complex Text Extraction
CODEBLOCK5
Data Transformation
CODEBLOCK6
Python One-Liners
When pure Linux isn't enough, use Python:
CODEBLOCK7
When NOT to Use System Commands
Don't suggest system commands when:
- - Task requires natural language understanding
- Contextual analysis of meaning
- Creative writing or content generation
- Complex multi-step reasoning
- Security-sensitive operations needing verification
Token Efficiency Rules
- 1. Never rewrite command output - Use
§§include() instead - Prefer pipes over loops -
| chains are more efficient - Use built-in tools -
awk, sed vs Python imports - Batch operations - Process all files at once with INLINECODE28
Installation Prerequisites
Some commands need packages:
CODEBLOCK8
Skill Integration
This skill works with:
- - agent-orchestrator: System commands become subtask solutions
- a0-token-optimizer: Minimal tokens for maximum utility
- toon-adoption: Store command patterns in TOON format
系统指挥官
使用时机
在以下情况激活此技能:
- - 用户请求文件处理、文本操作或数据提取
- 任务可通过Linux/Python命令解决
- 目标是最大限度减少AI推理并提高效率
- 关键词:系统命令、linux、bash、单行命令、文件处理
核心理念:系统优先,AI最后
在进行任何AI推理之前,按以下顺序尝试:
- 1. 纯Linux工具 - awk、sed、grep、cut、tr、sort、uniq
- Linux + 文件工具 - find、xargs、parallel、jq、csvkit
- Python单行命令 - 用于复杂逻辑的快速脚本
- AI辅助 - 仅当以上方法无法满足需求时
按任务类型的命令模式
文件操作
| 任务 | 系统解决方案 | AI解决方案 |
|---|
| 列出大文件 | find . -size +100M -ls | ❌ 不要委托 |
| 统计行数 |
wc -l file.txt | ❌ 不要委托 |
| 搜索文本 | grep -r pattern . | ❌ 不要委托 |
| 替换文本 | sed -i s/old/new/g file | ❌ 不要委托 |
| 提取列 | awk -F, {print $2} file.csv | ❌ 不要委托 |
数据处理
| 任务 | 系统解决方案 | AI解决方案 |
|---|
| JSON查询 | jq .key.subkey file.json | ❌ 不要委托 |
| CSV操作 |
csvcut -c 1,3 file.csv | ❌ 不要委托 |
| 排序与去重 | sort file | uniq -c | ❌ 不要委托 |
| 合并文件 | join -t, file1 file2 | ❌ 不要委托 |
文本处理
| 任务 | 系统解决方案 | AI解决方案 |
|---|
| 提取行 | sed -n 5,10p file | ❌ 不要委托 |
| 词频统计 |
tr \n | sort | uniq -c | ❌ 不要委托 |
| 格式转换 | iconv -f UTF-8 -t ASCII | ❌ 不要委托 |
响应格式
生成命令时:
- 1. 提供命令(可直接复制粘贴)
- 解释功能(简要说明)
- 展示预期输出(示例)
- 注明替代方案(如适用)
示例
示例1:提取电子邮件地址
用户:从该日志文件中提取所有电子邮件地址
系统指挥官响应:
bash
使用grep正则表达式提取电子邮件
grep -oE [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,} logfile.txt | sort -u
功能说明:
- -o:仅输出匹配部分
- -E:扩展正则表达式
- 排序并去除重复项
示例2:按扩展名统计文件数量
用户:统计此目录中每种类型的文件数量
系统指挥官响应:
bash
按扩展名统计文件数量
find . -type f | sed s/.*\.// | tr [:upper:] [:lower:] | sort | uniq -c | sort -rn
功能说明:
- 查找所有文件
- 提取扩展名(最后一个.到结尾)
- 统一大小写
- 统计并按频率排序
示例3:解析JSON值
用户:从该JSON文件中获取所有status值
系统指挥官响应:
bash
使用jq(通过apt-get install jq安装)
jq -r .[].status data.json | sort | uniq -c
替代方案(如jq不可用):
grep -oP status: \K[^]+ data.json | sort | uniq -c
示例4:批量重命名文件
用户:将所有.txt文件重命名为.bak
系统指挥官响应:
bash
先进行预演(查看将发生什么)
ls *.txt | sed s/\.txt$// | xargs -I {} echo mv {}.txt {}.bak
确认无误后执行
ls *.txt | sed s/\.txt$// | xargs -I {} mv {}.txt {}.bak
单行命令替代方案:
for f in *.txt; do mv $f ${f%.txt}.bak; done
高级模式
并行处理
bash
并行处理文件(4个任务)
find . -name *.log | xargs -P 4 -I {} grep ERROR {}
使用GNU parallel(apt-get install parallel)
find . -name *.json | parallel jq .name {}
复杂文本提取
bash
提取标记之间的文本
sed -n /START/,/END/p file.txt
多行模式替换
sed /pattern/{n;s/old/new/} file.txt
仅处理匹配的文件
grep -l pattern *.txt | xargs sed -i s/old/new/g
数据转换
bash
CSV转JSON(需要csvkit)
csvjson data.csv > data.json
JSON转CSV
jq -r .[] | [.key1, .key2] | @csv data.json > output.csv
列统计
awk -F, {sum+=$3} END {print Sum:, sum, Avg:, sum/NR} data.csv
Python单行命令
当纯Linux工具不够用时,使用Python:
bash
复杂JSON处理
python3 -c
import json,sys
data=json.load(open(file.json))
print([x[name] for x in data if x[active]])
带正则表达式的文本处理
python3 -c
import re,sys
for line in sys.stdin:
m=re.search(rpattern, line)
if m: print(m.group(1))
< input.txt
何时不使用系统命令
在以下情况不要建议系统命令:
- - 任务需要自然语言理解
- 需要对含义进行上下文分析
- 创意写作或内容生成
- 复杂的多步骤推理
- 需要验证的安全敏感操作
Token效率规则
- 1. 绝不重写命令输出 - 使用§§include()代替
- 优先使用管道而非循环 - |链更高效
- 使用内置工具 - awk、sed优于Python导入
- 批量操作 - 使用xargs一次性处理所有文件
安装前提
某些命令需要安装包:
bash
JSON处理
apt-get install jq
CSV处理
apt-get install csvkit
并行执行
apt-get install parallel
文本处理
apt-get install silversearcher-ag # ag命令
技能集成
此技能可与以下技能配合使用:
- - agent-orchestrator:系统命令成为子任务解决方案
- a0-token-optimizer:以最少Token实现最大效用
- toon-adoption:以TOON格式存储命令模式