Agent搜索
- 作者仓库星标 435
- 作者更新于 实时读取
- 作者仓库 nvim
- 领域
- 工程开发
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @benbrastmckie · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 仅限本地
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: skill-refresh
description: Manage OpenCode resources - terminate orphaned processes and clean up ~/.opencode/ directory Dir…
category: 工程开发
runtime: 无特殊运行时
---
# skill-refresh 输出预览
## PART A: 任务判断
- 适用问题:代码实现、重构、调试或代码审查。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Execution / Step 1: Parse Arguments / Step 2: Run Process Cleanup”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于代码实现、重构、调试或代码审查,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Execution / Step 1: Parse Arguments / Step 2: Run Process Cleanup”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、主要在本地完成、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/refresh` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“Execution / Step 1: Parse Arguments / Step 2: Run Process Cleanup”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: skill-refresh
description: Manage OpenCode resources - terminate orphaned processes and clean up ~/.opencode/ directory Dir…
category: 工程开发
source: benbrastmckie/nvim
---
# skill-refresh
## 什么时候使用
- 把工程方向的常用动作沉淀成 Agent 可调用的技能 适合处理工程开发场景下的代码实现、调试、重构、测试或代码审查,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代…
- 面向代码实现、重构、调试或代码审查,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Execution / Step 1: Parse Arguments / Step 2: Run Process Cleanup」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;主要在本地完成;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "skill-refresh" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Execution / Step 1: Parse Arguments / Step 2: Run Process Cleanup
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件、执行终端命令 | 主要在本地完成
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Refresh Skill (Direct Execution)
Direct execution skill for managing OpenCode resources. Performs two operations:
- Process cleanup: Identify and terminate orphaned OpenCode processes
- Directory cleanup: Clean up accumulated files in ~/.opencode/
This skill executes inline without spawning a subagent.
Execution
Step 1: Parse Arguments
Extract flags from command input:
--dry-run: Preview mode--force: Skip confirmation, use 8-hour default
# Parse from command input
dry_run=false
force=false
if [[ "$*" == *"--dry-run"* ]]; then
dry_run=true
fi
if [[ "$*" == *"--force"* ]]; then
force=true
fi
Step 2: Run Process Cleanup
Execute process cleanup script:
.opencode/scripts/claude-refresh.sh $( [ "$force" = true ] && echo "--force" )
Store process cleanup output for display.
Step 3: Clean Orphaned Postflight Markers
Clean any orphaned postflight coordination files from the specs directory. These files should normally be cleaned up by skills after postflight completes, but may be left behind if a process is interrupted.
echo ""
echo "=== Cleaning Orphaned Postflight Markers ==="
echo ""
# Find orphaned postflight markers (older than 1 hour)
orphaned_pending=$(find specs -maxdepth 3 -name ".postflight-pending" -mmin +60 -type f 2>/dev/null)
orphaned_guard=$(find specs -maxdepth 3 -name ".postflight-loop-guard" -mmin +60 -type f 2>/dev/null)
# Also check for legacy global markers
legacy_pending=""
legacy_guard=""
if [ -f "specs/.postflight-pending" ]; then
legacy_pending="specs/.postflight-pending"
fi
if [ -f "specs/.postflight-loop-guard" ]; then
legacy_guard="specs/.postflight-loop-guard"
fi
if [ -n "$orphaned_pending" ] || [ -n "$orphaned_guard" ] || [ -n "$legacy_pending" ] || [ -n "$legacy_guard" ]; then
if [ "$dry_run" = true ]; then
echo "Would delete the following orphaned markers:"
[ -n "$orphaned_pending" ] && echo "$orphaned_pending"
[ -n "$orphaned_guard" ] && echo "$orphaned_guard"
[ -n "$legacy_pending" ] && echo "$legacy_pending"
[ -n "$legacy_guard" ] && echo "$legacy_guard"
else
# Delete orphaned task-scoped markers
find specs -maxdepth 3 -name ".postflight-pending" -mmin +60 -delete 2>/dev/null
find specs -maxdepth 3 -name ".postflight-loop-guard" -mmin +60 -delete 2>/dev/null
# Delete legacy global markers
rm -f specs/.postflight-pending 2>/dev/null
rm -f specs/.postflight-loop-guard 2>/dev/null
echo "Cleaned orphaned postflight markers."
fi
else
echo "No orphaned postflight markers found."
fi
Step 4: Clean Stale Backup Files
Scan for and remove any .backup files left over from the deprecated backup mechanism in .opencode/:
echo ""
echo "=== Cleaning Stale Backup Files ==="
echo ""
# Find .backup files in .opencode/ directory
backup_files=$(find .opencode/ -name "*.backup" -type f 2>/dev/null)
if [ -n "$backup_files" ]; then
backup_count=$(echo "$backup_files" | wc -l)
if [ "$dry_run" = true ]; then
echo "Would delete $backup_count .backup file(s):"
echo "$backup_files"
else
echo "$backup_files" | xargs rm -f
echo "Deleted $backup_count stale .backup file(s)."
fi
else
echo "No stale .backup files found."
fi
Step 5: Run Directory Survey
Show current directory status without cleaning yet:
.opencode/scripts/claude-cleanup.sh
This displays:
- Current ~/.opencode/ directory size
- Breakdown by directory
- Space that can be reclaimed
Step 6: Execute Based on Mode
Dry-Run Mode
If --dry-run is set:
echo ""
echo "=== DRY RUN MODE ==="
echo "Showing 8-hour cleanup preview..."
echo ""
.opencode/scripts/claude-cleanup.sh --dry-run --age 8
Exit after showing preview.
Force Mode
If --force is set:
echo ""
echo "=== EXECUTING CLEANUP (8-hour default) ==="
echo ""
.opencode/scripts/claude-cleanup.sh --force --age 8
Show results and exit.
Interactive Mode (Default)
If neither flag is set:
Check if cleanup candidates exist (claude-cleanup.sh exits with code 1 if candidates found)
If no candidates, display message and exit:
No cleanup candidates found within default thresholds.
All files are either protected or recently modified.
- If candidates exist, prompt user for age selection:
{
"question": "Select cleanup age threshold:",
"header": "Age Threshold",
"multiSelect": false,
"options": [
{
"label": "8 hours (default)",
"description": "Remove files older than 8 hours - aggressive cleanup"
},
{
"label": "2 days",
"description": "Remove files older than 2 days - conservative cleanup"
},
{
"label": "Clean slate",
"description": "Remove everything except safety margin (1 hour)"
}
]
}
Map user selection to age parameter:
- "8 hours (default)" →
--age 8 - "2 days" →
--age 48 - "Clean slate" →
--age 0
- "8 hours (default)" →
Execute cleanup with selected age:
case "$selection" in
"8 hours (default)")
.opencode/scripts/claude-cleanup.sh --force --age 8
;;
"2 days")
.opencode/scripts/claude-cleanup.sh --force --age 48
;;
"Clean slate")
.opencode/scripts/claude-cleanup.sh --force --age 0
;;
esac
- Display cleanup results
Example Execution Flows
Interactive Flow
# User runs: /refresh
# Output:
OpenCode Refresh
===================
No orphaned processes found.
All 3 Claude processes are active sessions.
---
OpenCode Directory Cleanup
=============================
Target: ~/.opencode/
Current total size: 7.3 GB
Scanning directories...
Directory Total Cleanable Files
---------- ------- ---------- -----
projects/ 7.0 GB 6.5 GB 980
debug/ 151.0 MB 140.0 MB 650
...
TOTAL 7.3 GB 6.7 GB 5577
Space that can be reclaimed: 6.7 GB
# Prompt appears:
[Age Threshold]
Select cleanup age threshold:
1. 8 hours (default) - Remove files older than 8 hours
2. 2 days - Remove files older than 2 days
3. Clean slate - Remove everything except safety margin
# User selects option 1
# Cleanup executes:
Cleanup Complete
================
Deleted: 5577 files
Failed: 0 files
Space reclaimed: 6.7 GB
New total size: 600.0 MB
Dry-Run Flow
# User runs: /refresh --dry-run
# Shows survey, then:
=== DRY RUN MODE ===
Showing 8-hour cleanup preview...
Would delete: 5577 files
Would reclaim: 6.7 GB
Dry Run Summary
===============
No changes made.
Force Flow
# User runs: /refresh --force
# Shows survey, then immediately:
=== EXECUTING CLEANUP (8-hour default) ===
Cleanup Complete
================
Deleted: 5577 files
Space reclaimed: 6.7 GB
Safety Measures
Protected Files (Never Deleted)
sessions-index.json(in each project directory)settings.json.credentials.jsonhistory.jsonl
Safety Margin
Files modified within the last hour are never deleted, regardless of age threshold.
Process Safety
- Only targets orphaned processes (TTY = "?")
- Never kills active sessions
- Excludes current process tree
Error Handling
Scripts Not Found
If scripts don't exist:
Error: Cleanup scripts not found at .opencode/scripts/
Please ensure claude-refresh.sh and claude-cleanup.sh are installed.
Permission Denied
If kill/delete fails due to permissions:
Warning: Some operations failed due to insufficient permissions.
Failed files: 5
Successfully deleted: 5572 files
No ~/.opencode/ Directory
If directory doesn't exist:
Error: ~/.opencode/ directory not found.
Nothing to clean up.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核