Core Principle
LLMs are expensive, slow, and probabilistic. Scripts are free, fast, and deterministic.
Every time you do something twice that could be scripted, you're wasting:
- - Tokens — money burned on solved problems
- Time — seconds/minutes vs milliseconds
- Reliability — LLMs fail randomly, scripts fail predictably
Check signals.md for detection patterns. Check templates.md for common script patterns.
The Automation Test
Before doing any task, ask:
- 1. Is this deterministic? Same input → same output every time?
- Is this repetitive? Will this happen again?
- Is this rule-based? Can I write down the exact steps?
If yes to all three → script it, don't LLM it.
Script vs LLM Decision Matrix
| Task type | Script | LLM |
|---|
| Format conversion (JSON↔YAML) | ✅ | ❌ |
| Text transformation (regex) |
✅ | ❌ |
| File operations (rename, move) | ✅ | ❌ |
| Data validation | ✅ | ❌ |
| API calls with fixed logic | ✅ | ❌ |
| Git workflows | ✅ | ❌ |
| Judgement calls | ❌ | ✅ |
| Creative content | ❌ | ✅ |
| Ambiguous inputs | ❌ | ✅ |
| One-time unique tasks | ❌ | ✅ |
Automation Triggers
When you notice yourself:
- - Doing the same task twice → script it
- Writing similar prompts repeatedly → script the pattern
- Formatting output the same way → script the formatter
- Validating data with same rules → script the validator
- Calling APIs with predictable logic → script the integration
Automation Proposal Format
When you spot an opportunity:
CODEBLOCK0
Script Standards
When writing automation:
- 1. Single purpose — one script, one job
- Idempotent — safe to run multiple times
- Documented — usage in comments at top
- Logged — output what you're doing
- Fail loud — exit codes, error messages
- No secrets hardcoded — env vars or keychain
Tracking Automations
Document what you've built:
CODEBLOCK1
The 3x Rule
If you do something 3 times, it must become a script.
- - 1st time: Do it, note that it might repeat
- 2nd time: Do it, flag as automation candidate
- 3rd time: Stop. Write the script first, then run it.
Anti-Patterns
| Don't | Do instead |
|---|
| Re-prompt for same transformation | Write a script once |
| Use LLM for data validation |
Write validation rules |
| Burn tokens on formatting | Use formatters (prettier, jq, etc.) |
| Ask LLM to remember procedures | Document in scripts |
| Solve same problem differently each time | Standardize with automation |
Every script written = permanent token savings. Compound your efficiency.
核心原则
大语言模型昂贵、缓慢且具有概率性。脚本免费、快速且确定。
每次你重复做一件本可以脚本化的事情,你都在浪费:
- - Token — 为已解决的问题烧钱
- 时间 — 秒/分钟 vs 毫秒
- 可靠性 — 大语言模型随机失败,脚本可预测失败
查看 signals.md 了解检测模式。查看 templates.md 了解常见脚本模式。
自动化测试
在执行任何任务前,请问:
- 1. 这是确定性的吗? 相同输入 → 每次相同输出?
- 这是重复性的吗? 还会再次发生吗?
- 这是基于规则的吗? 我能写下确切的步骤吗?
如果三个答案都是肯定的 → 写脚本,别用大语言模型。
脚本 vs 大语言模型决策矩阵
| 任务类型 | 脚本 | 大语言模型 |
|---|
| 格式转换(JSON↔YAML) | ✅ | ❌ |
| 文本转换(正则表达式) |
✅ | ❌ |
| 文件操作(重命名、移动) | ✅ | ❌ |
| 数据验证 | ✅ | ❌ |
| 固定逻辑的API调用 | ✅ | ❌ |
| Git工作流 | ✅ | ❌ |
| 判断性决策 | ❌ | ✅ |
| 创意内容 | ❌ | ✅ |
| 模糊输入 | ❌ | ✅ |
| 一次性独特任务 | ❌ | ✅ |
自动化触发条件
当你注意到自己:
- - 重复做同一任务 → 写脚本
- 反复写类似提示词 → 将模式脚本化
- 以相同方式格式化输出 → 将格式化器脚本化
- 用相同规则验证数据 → 将验证器脚本化
- 用可预测逻辑调用API → 将集成脚本化
自动化提案格式
当你发现机会时:
🔧 自动化机会
任务:[你一直在做的事]
频率:[多久一次]
当前成本:[每次运行的token/时间]
建议脚本:
- - 语言:[bash/python/node]
- 输入:[需要什么]
- 输出:[产生什么]
- 位置:[保存到哪里]
预计节省:[每月节省的token/时间]
要我写吗?
脚本标准
编写自动化时:
- 1. 单一用途 — 一个脚本,一个任务
- 幂等性 — 多次运行安全
- 有文档 — 顶部注释说明用法
- 有日志 — 输出正在执行的操作
- 失败时明确 — 退出码、错误信息
- 不硬编码密钥 — 使用环境变量或钥匙串
自动化追踪
记录你构建的内容:
活跃脚本
- - scripts/format-json.sh — JSON美化器 [每周节省约2k token]
- scripts/deploy-staging.sh — 一键部署 [每次部署节省5分钟]
- scripts/sync-env.sh — 环境文件同步 [消除手动错误]
候选脚本
- - 周报生成 — 重复的格式化工作
- 日志解析 — 每次相同的grep模式
3次规则
如果你做某件事 3次,它必须变成一个脚本。
- - 第1次:做,并注意它可能重复
- 第2次:做,标记为自动化候选
- 第3次:停下。先写脚本,再运行它。
反模式
| 不要做 | 改为 |
|---|
| 为相同转换重复提示 | 一次性写脚本 |
| 用大语言模型做数据验证 |
写验证规则 |
| 在格式化上烧token | 使用格式化工具(prettier、jq等) |
| 让大语言模型记住流程 | 在脚本中记录 |
| 每次以不同方式解决相同问题 | 用自动化标准化 |
每写一个脚本 = 永久节省token。让你的效率复利增长。