技能库 / 开发编程 / Claude 非交互自动化技能

Claude 非交互自动化技能

在用户希望用 Claude/Claude Code 完成功能设计、代码审查等时使用;提供免反复确认的非交互模式。

v1.0.0 feiskyer
作者 / 来源

skillhub

在来源站打开

安装方式

CLI 安装(推荐)

claw install shub-claude-skill

需要安装 CLAW CLI

手动下载安装

下载 ZIP 后解压到技能目录即可安装。若在桌面客户端 WebView中直接下载出现异常,本站会改为提示页 + 原始链接,请按页内说明操作。

下载 ZIP (shub-claude-skill-v1.0.0.zip)

触发指令

/claude-skill

使用指南

Claude 非交互自动化技能

围绕 Claude 非交互自动化技能:在用户希望用 Claude/Claude Code 完成功能设计、代码审查等时使用;提供免反复确认的非交互模式。 无需在每次任务前把零散英文说明手工拼进上下文,也 减少 与客户端默认行为脱节的试错;具体命令、钩子与 JSON 参数仍以 ZIP 包内 SKILL.md 为权威。下文结构与站内 MCP CLI 类专题稿相同:何时用、前置、流程、速查与故障。

何时使用

  • 在用户希望用 Claude/Claude Code 完成功能设计、代码审查等时使用
  • 提供免反复确认的非交互模式
  • 已获取本技能 ZIP,并准备在 Claude Code / OpenClaw 中按 SKILL.md 挂载。
  • 希望用中文专题稿快速判断「该不该启用」,再深入英文 SKILL 查参数与边界。
  • 需要与团队对齐同一套触发方式、目录约定或回调格式时。

前置条件

  • 通用:可运行 Claude Code 或文档要求的客户端;有可读写的项目工作区(或 SKILL.md 指定的沙箱目录)。
  • 权威细节:API Key / OAuth、钩子路径、环境变量以 ZIP 内 SKILL.md 为准。

典型流程

  1. 从 ClawHub / 站内分发获取技能 ZIP,校验版本与校验和(若提供)。
  2. 阅读 SKILL.md 的安装段落:目录落点、客户端类型(Claude Code / OpenClaw / 脚本)。
  3. 用文档中的最小示例完成第一次调用(单文件修改、单次查询或单次委派)。
  4. 确认工作目录、权限边界与输出路径后,再处理多文件或长耗时任务。
  5. 需要回调 / Webhook / 通知时,按 SKILL.md 配置端点并在测试环境先验通。

与 ZIP / SKILL.md 的关系

站内专题稿与 MCP CLI 类 oss 稿同样:概括何时用、怎么接、怎么排错命令模板、钩子名、JSON 字段、版本矩阵一律以 ZIP 内 SKILL.md 与 ClawHub 上游为准。

命令示例(摘自包内 SKILL.md)

以下为从上游 SKILL.md(或入库正文)自动抽取的终端/脚本片段;路径、环境变量与参数以当前 ZIP 与官方说明为准。

ClawHub slugclaude-skill(安装命令以 SKILL.md / claw CLI 为准)。

claude --version  # Verify installed
# Install: npm install -g @anthropic-ai/claude-code
tmux -V             # tmux required for full workflow
LOG_FILE="/tmp/claude-quick-${TASK_ID:-$$}.log"

# Via OpenClaw exec — use background=true + pty=true, NO hard timeout
# pty=true ensures claude CLI flushes output properly (no buffering issues)
# (hard timeout kills the process; instead we poll and extend)
# Redirect both stdout and stderr to log file via tee so output is always captured.
# In -p mode (non-interactive), | tee is safe — no TTY detection issues.
exec(command="claude -p 'fix the typo in README.md' --dangerously-skip-permissions --output-format stream-json 2>&1 | tee -a $LOG_FILE",
     workdir="/path/to/project", background=true, pty=true)
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"

# Install dependencies (adapt to your stack)
pnpm install   # or: npm install / go mod tidy / pip install -r requirements.txt
LOG_FILE="/tmp/worktrees/$TASK_ID/claude-output.log"
MAX_LOG_SIZE=$((100 * 1024 * 1024))  # 100 MB safety cap

# 1. Create session with an idle shell first
tmux new-session -d -s "$TASK_ID" -c "$WORKTREE"

# 2. Start pipe-pane BEFORE the command runs — captures ALL output from the start
#    Strip ANSI escape codes so log files are clean and grep-parseable
tmux pipe-pane -t "$TASK_ID" -o "sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' >> $LOG_FILE"

# 3. NOW send the command — all output is captured
tmux send-keys -t "$TASK_ID" "claude --dangerously-skip-permissions \
  'Your detailed prompt here.

When completely finished:
1. Commit all changes with descriptive messages
2. Push the branch: git push -u origin $BRANCH
3. Create PR: gh pr create --fill
4. Notify: openclaw system event --text \"Done: $TASK_ID\" --mode now'" Enter
LOG_SIZE=$(stat -c%s "$LOG_FILE" 2>/dev/null || echo 0)
if [ "$LOG_SIZE" -gt "$MAX_LOG_SIZE" ]; then
  mv "$LOG_FILE" "${LOG_FILE}.old"
  # pipe-pane will create a new file on next write
fi
mkdir -p "$REPO_ROOT/.clawd"
TASKS_FILE="$REPO_ROOT/.clawd/active-tasks.json"

# Initialize if not exists
[ -f "$TASKS_FILE" ] || echo '{"tasks":[]}' > "$TASKS_FILE"

# Get the PID of the claude process inside tmux for reliable status checks
PANE_PID=$(tmux display-message -t "$TASK_ID" -p '#{pane_pid}')

# Register — use flock to prevent concurrent write races
(
  flock -x 200
  jq --arg id "$TASK_ID" --arg branch "$BRANCH" --arg wt "$WORKTREE" \
    --arg pane_pid "$PANE_PID" \
    '.tasks += [{
      "id": $id,
      "agent": "claude",
      "branch": $branch,
      "worktree": $wt,
      "tmuxSession": $id,
      "panePid": ($pane_pid | tonumber),
      "status": "running",
      "startedAt": (now|floor),
      "pr": null,
      "retries": 0,
      "checks": {},
      "lastOutputHash": "",
      "lastCheckedAt": (now|floor),
      "silentRounds": 0,
      "repeatingRounds": 0
    }]' "$TASKS_FILE" > /tmp/tasks.$$.json && mv /tmp/tasks.$$.json "$TASKS_FILE"
) 200>"$TASKS_FILE.lock"
# --- Process status check (reliable — checks actual process, not just tmux session) ---

# Method 1: Check if the claude process inside the pane is alive
PANE_PID=$(tmux display-message -t "$TASK_ID" -p '#{pane_pid}' 2>/dev/null)
if [ -z "$PANE_PID" ]; then
  echo "tmux session gone"
elif pgrep -P "$PANE_PID" > /dev/null 2>&1; then
  echo "running"
else
  echo "process exited (tmux session still open)"
  # Get exit code from the shell inside tmux
  tmux send-keys -t "$TASK_ID" 'echo "EXIT_CODE=$?"' Enter
fi

# Method 2: Use tmux's pane_dead flag (if remain-on-exit is set)
# tmux display-message -t "$TASK_ID" -p '#{pane_dead}'  # 1 = process exited

# --- View output ---

# Full output history from log file (ANSI-stripped, grep-friendly)
tail -100 "/tmp/worktrees/$TASK_ID/claude-output.log"

# Search for errors in clean log
grep -i "error\|fail\|panic" "/tmp/worktrees/$TASK_ID/claude-output.log"

# Live view (raw tmux pane, may contain ANSI codes — use for quick glance only)
tmux capture-pane -t "$TASK_ID" -p -S -50

# --- Mid-task steering (DON'T kill — redirect!) ---

# Agent going the wrong direction?
tmux send-keys -t "$TASK_ID" "Stop. Focus on the API layer first, not the UI." Enter

# Agent missing context?
tmux send-keys -t "$TASK_ID" "The schema is in src/types/template.ts. Use that." Enter

# Agent's context window filling up?
tmux send-keys -t "$TASK_ID" "Focus only on these 3 files: api.ts, handler.ts, types.ts" Enter

# Agent needs test guidance?
tmux send-keys -t "$TASK_ID" "Run 'npm test -- --grep auth' to verify your changes." Enter
PR_NUM=$(gh pr list --head "$BRANCH" --json number -q '.[0].number')
echo "PR: #$PR_NUM"
gh pr checks "$PR_NUM"
gh pr view "$PR_NUM" --json mergeable -q '.mergeable'
DIFF=$(gh pr diff "$PR_NUM")

# Option A: Codex reviews Claude's code (best for edge cases & logic errors)
echo "$DIFF" | codex exec -s read-only \
  "Review this PR diff. Focus on: bugs, edge cases, missing error handling, 
   race conditions, security issues. Be specific — cite file and line numbers.
   Output format: list of issues with severity (critical/warning/info)."

# Option B: Claude reviews with security focus
echo "$DIFF" | claude -p \
  --append-system-prompt "You are a security-focused code reviewer. Flag only critical issues." \
  "Review this diff for security vulnerabilities, injection risks, and logic errors."
gh pr comment "$PR_NUM" --body "## AI Code Review

$REVIEW_OUTPUT"

站内入库时的触发命令(完整语义见 ZIP):

# 使用本技能时可在对话中引用或执行上述指令;完整参数与示例见下载包内 SKILL.md。
/claude-skill

最佳实践

  • SKILL.md 再猜参数;站内专题稿不替代 schema 与必填字段说明。
  • 委派任务时写清验收标准(命令、文件路径、测试命令),减少来回追问。
  • 长任务用文档推荐的回调 / 日志落盘代替高频轮询,省 Token 也省机器负载。
  • 多技能同时启用时,注意钩子加载顺序与重复工具调用(以 SKILL.md 冲突说明为准)。

调试与排错

  • 打开 stderr 与客户端日志;PTY/tmux 场景同时看面板最后几十行输出。
  • 参数错误时对照 SKILL.md 中的 JSON/CLI 示例(引号、转义、工作目录)。
  • 网络类失败:查代理、防火墙、MCP 传输方式(stdio / HTTP / SSE)。

速查

| 动作 | 说明 | |------|------| | 获取技能包 | ClawHub / 站内 ZIP,核对版本 | | 权威步骤 | 优先阅读 ZIP 内 SKILL.md | | 首次试跑 | 使用 SKILL.md 最小示例 | | 验收 | 对照路径、测试命令或回调负载 |

常见故障

  • 无输出或立即退出 → 工作目录错误、依赖未装、或 Claude Code 未登录;按 SKILL.md 自检清单执行。
  • 权限被拒绝 → 检查沙箱路径、--permission-mode 与工具白名单。
  • 与简介不符 → 以英文 SKILL 与上游仓库为准,站内稿仅作结构化导读。