mcpField
C
claude-code

claude-code

github.com/hw10181913Agent 工作流377 次安装37 周前更新
代码仓库

关于 claude-code

claude-code 是面向 OpenClaw 的 Claude Code 技能,提供文档查询与编码工作流支持。它还涵盖编码子 Agent 任务及 Spec-Kit 规格驱动开发指导。

主要功能

  1. 01查询 Claude Code 文档
  2. 02创建并执行编码子 Agent 任务
  3. 03查看配置和服务状态
  4. 04指导 Spec-Kit 规格工作流

适用场景

  1. 01查找 Claude Code 设置或故障排查信息
  2. 02委派复杂编码任务
  3. 03使用 Spec-Kit 规划并实现功能
  4. 04梳理代码或 PR 审查流程

MCP 相关

该技能可查询涵盖 MCP 的 Claude Code 主题,info 命令也会显示已配置的 MCP 服务状态。文档没有说明它会向客户端暴露 MCP 服务。

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/hw10181913/openclaw-skill-claude-code --skill claude-code

安装后在 Claude Code 中输入/claude-code确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

install.sh
README.md
claude-code.py

详细介绍

Claude Code 集成

此技能将 Claude Code 的功能集成到 OpenClaw 中,提供 AI 辅助编码工作流、文档和最佳实践。

你可以做什么

📚 文档查询
  • 查询 Claude Code 文档
  • 获取最佳实践和工作流
  • 了解设置和自定义选项
  • 排查常见问题
🤖 子 Agent 管理
  • 创建编码子 Agent
  • 管理 Agent 团队
  • 执行复杂开发任务
  • 自动化代码审查和 PR 工作流
🛠️ 开发工作流
  • AI 辅助编码最佳实践
  • 常见工作流和模式
  • 设置和配置
  • 故障排除指南

使用示例

查询文档
# Get documentation about a specific topic
claude-code query "subagents"
claude-code query "best practices"
claude-code query "settings"
执行编码任务
# Create a coding subagent for a complex task
claude-code task --description "Fix the login bug" --priority high
claude-code task --description "Refactor the database layer" --model claude-3-5-sonnet
列出可用命令
# Show all available commands
claude-code --help

可用命令

query

查询 Claude Code 文档中的指定主题。

用法:

claude-code query <topic>

示例:

claude-code query "subagents"
claude-code query "agent-teams"
claude-code query "best practices"
claude-code query "common workflows"
claude-code query "settings"
claude-code query "troubleshooting"

主题包括:

  • 子 Agent 和 Agent 团队
  • 最佳实践和工作流
  • 设置和自定义选项
  • 故障排除指南
  • 插件和扩展
  • MCP(模型上下文协议)
  • 无头/编程式用法
task

创建并执行编码子 Agent 任务。

用法:

claude-code task --description "<task description>" [--priority <level>] [--model <model-name>]

选项:

  • --description, -d:任务描述(必填)
  • --priority, -p:任务优先级(low/medium/high,默认:medium)
  • --model, -m:要使用的模型(可选;未指定时使用默认模型)

示例:

claude-code task --description "Implement user authentication module"
claude-code task --description "Refactor database queries" --priority high
claude-code task --description "Write unit tests for the API" --model claude-3-5-sonnet
docs

获取 Claude Code 文档各部分的概览。

用法:

claude-code docs [section]

部分:

  • quickstart - 入门指南
  • best-practices - AI 编码最佳实践
  • common-workflows - 常见开发工作流
  • settings - 自定义选项
  • troubleshooting - 常见问题和解决方案
  • all - 完整文档概览(默认)

示例:

claude-code docs
claude-code docs quickstart
claude-code docs best-practices
claude-code docs troubleshooting
info

显示 Claude Code 配置和状态。

用法:

claude-code info

输出包括:

  • 版本信息
  • 可用子 Agent
  • 已配置的模型
  • MCP 服务状态

与 OpenClaw 集成

此技能可与 OpenClaw 的原生功能无缝协作:

  • 子 Agent:Claude Code 子 Agent 可补充 OpenClaw 的子 Agent 系统
  • 代码执行:配合 OpenClaw 的 exec 工具使用,完成完整的开发工作流
  • 文件管理:结合 OpenClaw 的读取/写入工具,全面管理代码库
  • 会话:Claude Code 任务可集成到 OpenClaw 的会话管理中

工作流示例

修复复杂 Bug
# 1. Query best practices for debugging
claude-code query "debugging best practices"

# 2. Create a subagent to investigate and fix
claude-code task --description "Find and fix the null pointer exception in userService.js" --priority high

# 3. Review the changes
claude-code query "code review best practices"
开发新功能
# 1. Get best practices for the feature type
claude-code query "API design best practices"

# 2. Create development task
claude-code task --description "Implement REST API for user management" --priority medium

# 3. Check settings for code style
claude-code query "code style settings"
自动化代码审查
# 1. Query PR review best practices
claude-code query "PR review workflows"

# 2. Set up automated review task
claude-code task --description "Review all PRs in the last week" --priority low

配置

环境变量

基本用法无需配置。Claude Code 集成使用 OpenClaw 的原生功能。

模型

使用 OpenClaw 配置的默认模型。可通过 --model 选项为每项任务指定其他模型。

子 Agent 限制

由 OpenClaw 的子 Agent 配置管理(默认:最多同时运行 8 个子 Agent)。

说明

  • 此技能提供 Claude Code 文档和工作流的封装
  • 复杂编码任务通过 OpenClaw 的原生子 Agent 系统执行
  • 如需直接使用 Claude Code CLI,请从 https://claude.com/code 单独安装 Claude Code
  • 所有任务均通过 OpenClaw 的安全 Agent 基础设施执行

另请参阅

  • Claude Code 官方文档:https://code.claude.com/docs
  • OpenClaw 子 Agent:使用 OpenClaw 的原生子 Agent 功能
  • 最佳实践:整合自 Claude Code 指南

🚀 使用 Spec-Kit 进行规范驱动开发

什么是规范驱动开发?

规范驱动开发颠覆了传统软件开发的做法。它不再先编写代码、再把规范当作脚手架,而是让规范变得可执行——直接生成可运行的实现,而不只是为实现提供指导。

Spec-Kit 核心理念

  • 意图驱动:先通过规范定义“做什么”,再定义“怎么做”
  • 丰富的规范:护栏和组织原则
  • 多步细化:不采用一次性代码生成
  • AI 原生:充分利用先进 AI 模型的能力

Spec-Kit 工作流(7 个步骤)

步骤 1:安装 Spec-Kit CLI
# Install via uv (recommended)
uv tool install specify-cli --from git+https://github.com/github/spec-kit.git

# Verify installation
specify check

# Initialize project with Claude Code
specify init <PROJECT_NAME> --ai claude
步骤 2:确立项目原则

使用 /speckit.constitution 命令创建指导原则:

/speckit.constitution Create principles focused on:
- Code quality standards
- Testing requirements
- User experience consistency
- Performance requirements
- Design system guidelines

创建 .specify/memory/constitution.md,作为项目的基本准则。

步骤 3:创建规范

使用 /speckit.specify 描述要构建的内容:

/speckit.specify Build an application that [describe your product vision]
Focus on:
- What the application does
- User stories and scenarios
- Core features and functionality
- User experience goals
NOT the tech stack!
步骤 4:明确需求(可选但建议)

使用 /speckit.clarify 进行结构化提问:

/speckit.clarify 

按顺序进行基于覆盖范围的提问,并将答案记录在 Clarifications 部分。

步骤 5:创建技术计划

使用 /speckit.plan 定义技术栈:

/speckit.plan The application uses:
- Frontend: [React/Vue/Vanilla HTML+CSS+JS]
- Backend: [Node.js/Python/Go]
- Database: [PostgreSQL/MongoDB/LocalStorage]
- Key libraries: [list dependencies]
步骤 6:生成任务

使用 /speckit.tasks 拆解实施工作:

/speckit.tasks

创建包含以下内容的 tasks.md:

  • 按用户故事拆解任务
  • 依赖项管理
  • 并行执行标记([P])
  • 文件路径规范
  • TDD 结构
步骤 7:执行实施

使用 /speckit.implement 进行构建:

/speckit.implement

按正确顺序执行任务,遵循 TDD 方法,并提供进度更新。

可用的斜杠命令

核心命令(必需)
命令描述
/speckit.constitution创建/更新项目原则
/speckit.specify定义要构建的内容(需求)
/speckit.plan创建技术实施计划
/speckit.tasks生成可执行的任务列表
/speckit.implement执行所有任务
可选命令(提升质量)
命令描述
/speckit.clarify结构化需求澄清
/speckit.analyze跨产物一致性分析
/speckit.checklist质量验证清单

项目结构(运行 specify init 后)

PROJECT_NAME/
├── .specify/
│   ├── memory/
│   │   └── constitution.md      # Project principles
│   ├── scripts/
│   │   ├── check-prerequisites.sh
│   │   ├── common.sh
│   │   ├── create-new-feature.sh
│   │   ├── setup-plan.sh
│   │   └── update-claude-md.sh
│   └── specs/
│       └── 001-feature-name/
│           ├── spec.md           # Functional specs
│           ├── plan.md          # Technical plan
│           ├── tasks.md         # Implementation tasks
│           └── quickstart.md    # Run instructions
├── CLAUDE.md                     # AI assistant guidance
└── templates/
    ├── CLAUDE-template.md
    ├── plan-template.md
    ├── spec-template.md
    └── tasks-template.md

真实示例:拟物风格待办应用

步骤 1:初始化项目
specify init todo-app-spec-kit --ai claude
cd todo-app-spec-kit
步骤 2:创建章程
/speckit.constitution Create principles:
- Design Excellence: Skeuomorphic first, tactile feedback
- Code Quality: Clean architecture, progressive enhancement
- Testing: Visual testing, interaction testing
- User Experience: Intuitive, rewarding, calm design
步骤 3:指定需求
/speckit.specify Build a beautiful todo list app with:
- Tasks as index cards on a corkboard or notebook
- Add/edit/delete task functionality
- Mark complete with stamp animation
- Drag-and-drop reordering
- LocalStorage persistence
- Warm paper-like aesthetic with handwriting fonts
- Satisfying tactile interactions (crumpling, writing sounds)
步骤 4:创建计划
/speckit.plan Use:
- Pure HTML5/CSS3/JavaScript (no frameworks)
- LocalStorage for data persistence
- Google Fonts (Caveat handwriting)
- CSS animations for tactile effects
- Mobile-responsive design
- Fully offline-capable
步骤 5:生成并执行任务
/speckit.tasks    # Creates task breakdown
/speckit.implement  # Executes all tasks

Spec-Kit 的优势

✅ 结构化流程:告别含糊的提示词 ✅ 质量保证:内置清单和验证 ✅ 并行探索:多种实施路径 ✅ 文档编制:自动生成规范 ✅ 可复现:每个项目使用相同的工作流 ✅ 针对 AI 优化:为 Claude Code 设计的命令

成功技巧

  1. 明确具体:规范越详细,输出越好
  2. 迭代改进:不要期望第一次尝试就完美
  3. 使用 Clarify:规划前先解决歧义
  4. 遵循顺序:constitution → specify → plan → tasks → implement
  5. 验证:宣布完成前使用 /speckit.checklist

Spec-Kit 文档

与此技能集成

此 Claude Code 技能包含 Spec-Kit 知识!你可以:

# Query Spec-Kit documentation
claude-code query "spec-kit"
claude-code query "spec-driven development"
claude-code query "specify CLI"

# Get workflow guidance
claude-code docs spec-workflow

示例:启动新项目

# 1. Install spec-kit (one-time)
uv tool install specify-cli --from git+https://github.com/github/spec-kit.git

# 2. Initialize project
specify init my-new-app --ai claude

# 3. In Claude Code, use the commands:
/speckit.constitution  # Set design principles
/speckit.specify      # Define your app
/speckit.plan         # Choose tech stack
/speckit.tasks        # Get task list
/speckit.implement     # Build it!

资源:

评论

支持 Markdown