Files
nexus/wiki/sources/Claude-Code调用方法总结.md

2.2 KiB
Raw Blame History

title, type, tags, date
title type tags date
Claude Code 调用方法总结 source
ClaudeCode
OpenClaw
AI编程
2026-03-29

Source File

  • raw/Agent/claude-code调用方法总结.md

Summary

  • 核心主题OpenClaw/Hermes 系统中 terminal 工具调用 Claude Code 的两种核心模式
  • 问题域:如何可靠地将复杂编程任务委托给 Claude Code 执行,避免权限阻塞和超时问题
  • 方法/机制Print Modestdin 管道非交互模式)与 TMUX 交互模式对比,关键参数 bypassPermissions/max-turns
  • 结论/价值terminal 调用 claude -p 是调用 Claude Code 技能的唯一正确方式delegate_task 无法激活外部 CLI

Key Claims

  • Print Mode 通过 stdin 管道传递任务文本,避免特殊字符 shell 转义问题
  • --permission-mode bypassPermissions 跳过所有交互确认,比 --dangerously-skip-permissions 更可靠
  • --add-dir <路径> 自动扫描目标目录下的 SKILL.md 并在匹配条件时自动激活
  • --max-turns 25-30 是复杂任务的合理阈值,过小会导致任务未完成就超时
  • delegate_task 只能调用 Hermes 子 agent无法建立外部 Claude Code CLI 通道

Key Quotes

"当任务需要调用 Claude Code 的 skill如 fireworks-tech-graph应使用 terminal 调用 claude -p而非 delegate_task。" — 核心结论

Key Concepts

  • Print ModeClaude Code 非交互单次执行模式,通过 stdin 管道传递任务,适合绝大多数编程任务
  • TMUX交互模式Claude Code 长时间交互模式,通过 tmux session 保持进程,适合超长任务
  • Skill加载Claude Code 通过 --add-dir 扫描目录下的 SKILL.md 并在触发条件匹配时自动激活
  • 权限绕过bypassPermissions 参数跳过所有交互确认,是自动化调用 Claude Code 的必要条件

Key Entities

  • Claude-CodeAnthropic 官方 CLI 编程工具,支持 skill 扩展
  • HermesOpenClaw 中调用外部 CLI 工具的组件,通过 terminal 工具触发

Connections

Contradictions