闲社服务运行正常AI智能体自动化平台
c

Claude技能

技能标识:claude-skill

Use when user asks to leverage claude or claude code to do something (e.g. implement a feature design or review codes, etc). Provides non-interactive automation mode for hands-off task execution without approval prompts.

作者:admin | 来源记录:ClawHub
登记来源
ClawHub
版本
V 0.1.0
检测标记
后台标记通过
免费
免费获取
1
收藏
来源与检测标记为平台登记信息,并不代表已展示可复核的检测报告。使用前请核对版本、依赖和所需权限,建议先在隔离环境中运行。
概述
安装方式
版本历史

Claude技能

Claude Code 代理技能

将 Claude Code 作为托管编码代理进行操作——从工作树设置到 PR 合并。

前置条件

bash
claude --version # 验证是否已安装

安装:npm install -g @anthropic-ai/claude-code


tmux -V # 完整工作流程需要 tmux

CLI 快速参考

标志效果
-p 提示非交互式一次性执行,完成后退出
--dangerously-skip-permissions
跳过所有权限提示(在容器/虚拟机中安全) | | --permission-mode acceptEdits | 自动接受文件编辑,仍提示 shell 命令 | | --permission-mode plan | 只读分析,不进行修改 | | --model <模型> | 模型选择(例如 claude-sonnet-4-6) | | --allowedTools Bash,Read,Write,Edit | 限制可用工具 | | --disallowedTools Bash,Write | 阻止特定工具 | | --append-system-prompt ... | 向系统提示添加自定义指令 | | --output-format json | 结构化 JSON 输出,包含成本/持续时间元数据 | | --output-format stream-json | 流式 JSON(每条消息到达时输出) | | --continue / -c | 继续最近的对话 | | --resume / -r | 按 ID 恢复特定会话 | | --mcp-config <文件> | 加载 MCP 服务器配置 | | --verbose | 启用详细调试日志 |

执行模式

快速模式 — 小任务

适用于琐碎修复、单文件更改或分析。使用 -p(非交互式)。

输出捕获: 始终将输出重定向到日志文件,以便无论 PTY 是否可用都可读。使用 --output-format stream-json 获取结构化、可解析的进度事件(每条消息作为单独的 JSON 行到达)。

bash
LOGFILE=/tmp/claude-quick-${TASKID:-$$}.log

通过 OpenClaw exec — 使用 background=true + pty=true,无硬超时

pty=true 确保 claude CLI 正确刷新输出(无缓冲问题)

(硬超时会杀死进程;我们改用轮询并延长)

通过 tee 将 stdout 和 stderr 都重定向到日志文件,确保输出始终被捕获。

在 -p 模式(非交互式)下,| tee 是安全的 — 无 TTY 检测问题。

exec(command=claude -p 修复 README.md 中的拼写错误 --dangerously-skip-permissions --output-format stream-json 2>&1 | tee -a $LOG_FILE, workdir=/path/to/project, background=true, pty=true)

PTY 回退: 如果 pty=true 不可用(某些容器、CI 运行器),命令仍然有效,因为 -p 模式是非交互式的 — 它不依赖 isatty(stdout)。2>&1 | tee 确保无论 PTY 状态如何,stdout 和 stderr 都被捕获到日志文件。没有 PTY,会丢失颜色输出,但所有内容都保留。

自适应超时(轮询并延长)

不要对 claude 任务使用 timeout=。 相反,使用带定期轮询的后台执行。这可以防止长时间运行的任务被过早终止:

  1. 1. 使用 background=true 启动(无 timeout)
  2. 每约 5 分钟使用 process(action=poll, sessionId=, timeout=300000) 轮询一次
  3. 如果进程仍在运行 → 检查日志文件是否有新输出
  4. 如果进程已退出 → 检查退出代码和日志文件,完成
  5. 安全网:如果 12 小时内没有新输出,询问用户后再终止
  6. 安全网:如果输出重复(循环检测),询问用户

持久轮询状态: 将轮询元数据存储在任务注册表中,以便重启的编排代理可以恢复监控而不会丢失状态:

快速模式任务的注册表字段:
lastOutputHash: <最后20行的sha256>,
lastCheckedAt: ,
silentRounds: <整数>,
repeatingRounds: <整数>

轮询循环(代理行为,非脚本):

poll_interval = 5 分钟 (300000 毫秒)
maxsilentrounds = 144 (= 12 小时无新输出 → 询问用户)
maxrepeatingrounds = 12 (= 1 小时相同输出 → 可能卡住)

# 如果代理重启后恢复,从注册表恢复状态
silentrounds = registry[taskid].silentRounds ?? 0
repeatingrounds = registry[taskid].repeatingRounds ?? 0
lastoutputhash = registry[task_id].lastOutputHash ??

重复:
result = process(action=poll, sessionId=, timeout=300000)
if result.completed:
→ 检查退出代码,读取 $LOG_FILE,报告结果
→ 跳出循环
else:
# 直接从日志文件读取最新输出
newoutput = tail -20 $LOGFILE
newhash = sha256(newoutput)

if newhash != lastoutputhash and newoutput != :
if lastoutputhash != and outputlookssimilar(newoutput, lastoutput):
repeating_rounds += 1 # 输出在变化但重复(循环)
silent_rounds = 0
else:
silent_rounds = 0 # 真正的新输出,继续
repeating_rounds = 0
lastoutputhash = new_hash
else:
silent_rounds += 1

# 将状态持久化到注册表(在代理重启后仍存在)
updateregistry(taskid, {
lastOutputHash: new_hash,
lastCheckedAt: now(),
silentRounds: silent_rounds,
repeatingRounds: repeating_rounds
})

if silentrounds >= maxsilent_rounds:
→ 通知用户:Claude 已静默 12 小时,终止还是继续等待?
→ 等待用户决定
if repeatingrounds >= maxrepeating_rounds:
→ 通知用户:Claude 似乎陷入循环(重复输出 1 小时),终止还是继续等待?
→ 等待用户决定

这样,需要 5 分钟或几小时的任务都能正常工作,不会过早终止。

完整模式 — 功能、错误修复、重构

对于非平凡任务,使用下面的完整工作流程。这提供了:

  • - 隔离的工作树 — 与其他工作无冲突
  • tmux 会话 — 无需终止代理即可中途引导
  • 任务跟踪 — 随时了解正在运行的内容
  • 质量门 — 完成定义检查清单
  • 智能重试 — 不在重复失败上浪费令牌



完整工作流程:任务 → 合并的 PR

步骤 1:创建工作树

将每个任务隔离在自己的工作树和分支中:

bash
TASK_ID=feat-custom-templates
BRANCH=feat/$TASK_ID
REPO_ROOT=$(git rev-parse --show-toplevel)
WORKTREE=/tmp/worktrees/$TASK_ID

git worktree add -b $BRANCH $WORKTREE origin/main
cd $WORKTREE

安装依赖(根据你的技术栈调整)

pnpm install # 或:npm install / go mod tidy / pip install -r requirements.txt

步骤 2:在 tmux 中启动代理

在交互模式(无 -p)下启动 Claude Code,以便中途引导。
重要: 使用 tmux pipe-pane 记录输出 — 不要使用 | tee,因为它会将 stdout 变成管道,这会破坏交互模式(claude 检测到 !isatty(stdout) 并可能禁用交互功能,破坏 send-keys 引导)。

关键: 在发送命令之前设置 pipe-pane。否则会丢失早期输出(启动消息、快速崩溃)。

bash
LOGFILE=/tmp/worktrees/$TASKID/claude-output.log
MAXLOGSIZE=$((100 1024 1024)) # 100 MB 安全上限

1. 先创建一个带空闲 shell 的会话

tmux new-session -d -s $TASK_ID -c $WORKTREE

2. 在命令运行前启动 pipe-pane — 从一开始就捕获所有输出

去除 ANSI 转

标签

skill ai

通过对话安装

以下为平台配置的接入选项,并非逐项实测通过。能否安装取决于客户端支持、技能来源和运行环境:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 claude-skill-1776284752 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 claude-skill-1776284752 技能

通过命令行安装

skillhub install claude-skill-1776284752

下载

⬇ 下载 claude-skill v0.1.0(免费)

文件大小: 9.72 KB | 发布时间: 2026-4-16 15:57

v0.1.0 最新 2026-4-16 15:57
- Initial release of claude-skill.
- Provides a managed automation layer for running Claude Code as a coding agent, including worktree setup and PR merging.
- Supports non-interactive ("quick mode") and full interactive workflows, with robust logging and adaptive polling for long-running tasks.
- Offers CLI flags to control permissions, select models, restrict tools, and customize output.
- Includes resilience against CI/container PTY issues, output logging strategies, and polling-based timeout management to prevent premature termination of tasks.
返回顶部