关于 ask-claude
此技能通过本地 `claude` 命令行的非交互模式回答问题并辅助编码,支持选择模型、设置输出格式和继续最近的对话。
主要功能
- 01使用 `claude -p` 执行查询
- 02选择模型
- 03选择 text、JSON 或 stream-JSON 输出
- 04继续最近的对话
- 05使用当前工作目录
适用场景
- 01询问编码问题
- 02请求代码审查
- 03获取结构化 JSON 结果
- 04继续先前的查询
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ hiroro-work/ claude-plugins --skill ask-claude安装后在 Claude Code 中输入/ask-claude确认已加载。
详细介绍
询问 Claude
执行本地 claude CLI,获取编码帮助。
注意: 此技能要求系统已安装 claude CLI,且该命令位于系统的 PATH 中。
快速开始
使用 -p(打印模式)运行单条查询:
claude -p "Your question or task here"
常用选项
| 选项 | 说明 |
|---|---|
-p | 非交互式打印模式(脚本必需) |
--model MODEL | 指定模型(例如,sonnet、opus、haiku) |
--output-format FORMAT | 输出格式:text、json、stream-json |
-c, --continue | 继续最近的一次对话 |
如需查看所有可用选项,请运行
claude --help
示例
提出编码问题:
claude -p "How do I implement a binary search in Python?"
使用指定模型:
claude -p --model opus "Review this code for potential issues"
获取 JSON 输出:
claude -p --output-format json "List the main functions in this file"
继续之前的对话:
claude -p -c "Now add error handling to that function"
注意事项
-p标志会以非交互方式运行 Claude,并将结果输出到 stdout- 如果未指定
--model,则使用默认模型 stream-json会在生成响应时逐步输出- 警告:
-p标志会跳过工作区信任对话框。仅在你信任的目录中使用。 - 该命令会继承当前工作目录
评论
支持 Markdown