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

44 lines
2.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Claude Code 调用方法总结"
type: source
tags: [ClaudeCode, OpenClaw, AI编程]
date: 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 Mode]]Claude Code 非交互单次执行模式,通过 stdin 管道传递任务,适合绝大多数编程任务
- [[TMUX交互模式]]Claude Code 长时间交互模式,通过 tmux session 保持进程,适合超长任务
- [[Skill加载]]Claude Code 通过 `--add-dir` 扫描目录下的 SKILL.md 并在触发条件匹配时自动激活
- [[权限绕过]]bypassPermissions 参数跳过所有交互确认,是自动化调用 Claude Code 的必要条件
## Key Entities
- [[Claude-Code]]Anthropic 官方 CLI 编程工具,支持 skill 扩展
- [[Hermes]]OpenClaw 中调用外部 CLI 工具的组件,通过 terminal 工具触发
## Connections
- [[Claude-Code]] ← 被调用方 ← [[Print Mode]]
- [[Claude-Code]] ← 被调用方 ← [[TMUX交互模式]]
- [[Skill加载]] ← 作用于 ← [[Claude-Code]]
- [[Print Mode]] ← 替代方案 ← [[TMUX交互模式]]
## Contradictions