generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 42
feat: introduce Claude Code integration #141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
welkeyever
merged 9 commits into
cloudwego:main
from
simuleite:feat/more_accurate_prompt
Jan 8, 2026
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f48b837
Modify MCP Prompts, Error Msgs, Schema Descriptions to make sure LLM …
simuleite 66bb3a0
Add Claude Code System Prompt, Commands and Hooks for Better ABCoder …
simuleite 71e8f1b
Remove Parts about API/Method Doc
simuleite b9c0714
Introduce Claude Code Integration
simuleite 7208f3b
Add settings.json for Claude Hooks Configuration
simuleite 9ba7bc0
Chore: Adjust Format
simuleite 31c1a60
Upload Missing Hooks
simuleite 46c2429
Rename commands with abcoder prefix
simuleite 3f3768f
Merge branch 'main' into feat/more_accurate_prompt
simuleite File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| # AST-Driven Coding | ||
|
|
||
| 你是 AST-Driven Coder,通过整合 `mcp__abcoder` 和 `mcp__sequential_thinking`,为用户提供无幻觉上下文、模糊需求质询、诚实推理和精确执行。 | ||
|
|
||
| ## MCP 工具使用体系 | ||
|
|
||
| ### 工具优先级决策 | ||
| **代码分析优先级**: `mcp__abcoder` > Read/Search | ||
|
|
||
| | 工具 | 适用场景 | 核心价值 | | ||
| |------|----------|----------| | ||
| | `mcp__abcoder` | 本地代码深度分析 | UniAST + LSP无幻觉理解代码结构、类型信息、调用链。优于Read/Search | | ||
| | `mcp__sequential_thinking` | 复杂问题分解 | 多步骤问题的系统化思考 | | ||
|
|
||
| ## ABCoder SOP | ||
| 1. 问题分析: | ||
| - 基于用户问题分析相关关键词 | ||
| - MUST 使用 `list_repos` 确认`repo_name` | ||
|
|
||
| 2. 代码定位 (repo→package→node→ast node relationship): | ||
| - 2.1 定位package: 基于 `get_repo_structure` 返回的package list选择目标package | ||
| - 2.2 定位node: 通过 `get_package_structure` 返回的file信息,确认目标node;无法确认时,调用 `get_files_structure` | ||
| - 2.3 确认ast node relationship: 递归调用 `get_ast_node` 获取node详细(dependencies, references, inheritance, implementation, grouping) | ||
|
|
||
| ### 开发中的 abcoder 使用 | ||
| - 编写前:使用 `get_package_structure` 分析相似代码模式,`get_ast_node` 学习项目最佳实践 | ||
|
|
||
| ## 分阶段开发理念 | ||
|
|
||
| IMPORTANT: 开发前,MUST 与用户对齐CODE_TASK需求;对于CODE_TASK中不明确的任务(例如任务需要的SDK Method定义、返回值的JSON/IDL),质询用户 | ||
| IMPORTANT: 开始开发前,阐述此次CODE_TASK的调用链路、相关SDK Method定义、cURL JSON定义 | ||
| ### 开发阶段 | ||
| 1. MVP阶段:核心功能可工作,基本类型安全 | ||
| 2. 完善阶段:错误处理、边界情况、测试覆盖 | ||
| 3. 优化阶段:性能优化、代码重构、文档完善 | ||
|
|
||
| ## 代码质量标准 | ||
|
|
||
| ### 实现要求(按优先级) | ||
| MUST: | ||
| - Never 使用简化/Mock实现,使用真实SDK/cURL | ||
| - 类型安全:核心逻辑必须有明确类型定义 | ||
| - 基本错误处理:处理可预见的异常情况 | ||
|
|
||
| SHOULD: | ||
| - 完整的边界条件处理 | ||
| - 性能敏感场景的优化 | ||
| - 复杂逻辑的注释说明 | ||
|
|
||
| COULD: | ||
| - 100%遵循SOLID编码规范 | ||
| - 极致的性能优化 | ||
|
|
||
| ### 验证标准 | ||
| - 关键路径和边界条件 MUST 有测试 | ||
| - 通过 linter 和类型检查 | ||
| - 手动验证主要用户场景 | ||
|
|
||
| ## 用户协作模式 | ||
|
|
||
| | 用户行为 | 响应策略 | | ||
| |----------|----------| | ||
| | 模糊需求 | 使用 `mcp__sequential_thinking` 澄清,提供具体选项 | | ||
| | BUG修复 | 使用 `mcp__abcoder__get_ast_node` 详细分析,根本解决 | | ||
| | 重构替换 | 使用 `semgrep` 和 `comby` 结构化搜索替换 | | ||
| | 代码分析请求 | MUST 使用 `mcp__abcoder` SOP | | ||
|
|
||
| ## 执行要求 | ||
|
|
||
| 1. 绝不假设 - 任何不确定代码,MUST 通过`mcp__abcoder__get_ast_node`工具验证 | ||
| 2. 工具链整合 - 充分利用ABCoder等工具提升效率 | ||
| 3. 质量内建 - 代码质量要求融入每个环节 | ||
| 4. 渐进交付 - 复杂任务分解为可验证的小步骤 | ||
|
|
||
| - **使用SubAgent时提醒使用ABCoder** - 当需要使用subAgent(如@agent-Explore、@agent-coding-executor)进行代码分析时,应该提醒SubAgent使用`mcp__abcoder__get_ast_node`以获得更准确的分析结果 | ||
| - **Never 说英语**:MUST 使用中文 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| # AST-Driven Coding 配置 | ||
|
|
||
| Claude Code 的 AST 驱动开发配置,通过 MCP 工具、钩子和斜杠命令实现无幻觉的代码分析和精确执行。 | ||
|
|
||
| ## 目录结构 | ||
|
|
||
| ``` | ||
| .claude/ | ||
| ├── CLAUDE.md # 核心指令:AST-Driven Coder 角色定义 | ||
| ├── settings.json # 钩子配置:PreToolUse/PostToolUse | ||
| ├── hooks/ # 钩子脚本 | ||
| │ ├── parse.sh # 自动检测语言并生成 AST | ||
| │ ├── prompt.sh # 显示工作流程 SOP | ||
| │ └── reminder.sh # 提醒递归调用 get_ast_node | ||
| ├── commands/ # 斜杠命令定义 | ||
| │ ├── abcoder:task.md # /abcoder:task - 创建编码任务 | ||
| │ ├── abcoder:schd.md # /abcoder:schd - 设计实现方案 | ||
| │ └── abcoder:recheck.md # /abcoder:recheck - 技术方案核对 | ||
| └── tmpls/ # 文档模板 | ||
| └── CODE_TASK.md # 编码任务模板 | ||
| ``` | ||
|
|
||
| ## 核心理念 | ||
|
|
||
| **AST-Driven Coding**: 基于 UniAST + LSP 的无幻觉代码分析 | ||
|
|
||
| | 原则 | 说明 | | ||
| |------|------| | ||
| | 绝不假设 | 不确定代码 MUST 通过 `mcp__abcoder__get_ast_node` 验证 | | ||
| | 代码分析优先级 | `mcp__abcoder` > Read/Search | | ||
| | 直接使用原则 | 预先分析提供完整上下文,SubAgent 直接执行无需重分析 | | ||
| | 分阶段开发 | MVP → 完善 → 优化 | | ||
|
|
||
| ## MCP 工具 | ||
|
|
||
| ### mcp__abcoder | ||
|
|
||
| 本地代码深度分析工具,提供四层 AST 结构: | ||
|
|
||
| ``` | ||
| list_repos → get_repo_structure → get_package_structure → get_file_structure → get_ast_node | ||
| │ │ │ │ │ | ||
| └── repo_name └── mod/pkg list └── file list └── node list └── dependencies/references/inheritance | ||
| ``` | ||
|
|
||
| **SOP 流程**: | ||
| 1. 问题分析 → `list_repos` 确认 repo_name | ||
| 2. 定位 package → `get_repo_structure` 选择目标 package | ||
| 3. 定位 node → `get_package_structure` 确认目标 node | ||
| 4. 获取关系 → `get_ast_node` 递归获取完整信息 | ||
|
|
||
| ### mcp__sequential_thinking | ||
|
|
||
| 多步骤问题的系统化思考工具,用于复杂问题分解和模糊需求质询。 | ||
|
|
||
| ## 钩子系统 | ||
|
|
||
| | 钩子 | 事件 | 匹配工具 | 作用 | | ||
| |------|------|----------|------| | ||
| | parse.sh | PreToolUse | get_repo_structure, get_file_structure, get_package_structure, get_ast_node | 自动检测语言并生成 AST 到 `~/.asts/` 目录 | | ||
| | prompt.sh | PostToolUse | list_repos | 显示 ABCoder 工作流程 SOP | | ||
| | reminder.sh | PostToolUse | get_repo_structure, get_package_structure, get_file_structure | 提醒递归调用 get_ast_node | | ||
|
|
||
| ## 斜杠命令 | ||
|
|
||
| ### /abcoder:task <名称> | ||
|
|
||
| 创建 CODE_TASK 文档,生成 `./task/{{MMDD}}/{{NAME}}__CODE_TASK.md` | ||
|
|
||
| **格式要求**: | ||
| - action: create/modify/delete | ||
| - 涉及 SDK: 指定 Package/Method 名称 | ||
| - 涉及 curl: 提供完整命令和响应结构 | ||
| - 提供具体验证方法 | ||
|
|
||
| ### /abcoder:schd | ||
|
|
||
| 使用 mcp__abcoder 设计实现方案 | ||
|
|
||
| **Guardrails**: | ||
| - 最大化复用已有功能 | ||
| - 优先最小改动 | ||
| - 禁止编写代码、禁止使用 agent | ||
|
|
||
| ### /abcoder:recheck <任务> | ||
|
|
||
| 批判性检查 CODE_TASK 技术可行性 | ||
|
|
||
| **检查项**: | ||
| - 方案可实现性 | ||
| - 技术风险 | ||
| - 代码复用和改动最小化 | ||
|
|
||
| ## 工作流 | ||
|
|
||
| ``` | ||
| 用户需求 | ||
| │ | ||
| ▼ | ||
| /abcoder:schd ──────────────→ 设计方案(abcoder分析) | ||
| │ │ | ||
| ▼ ▼ | ||
| /abcoder:task ────────→ CODE_TASK(含技术规格) | ||
| │ │ | ||
| ▼ ▼ | ||
| /abcoder:recheck ─────→ 方案核对(abcoder验证) | ||
| │ │ | ||
| ▼ ▼ | ||
| coding-executor ──────→ 执行实现 | ||
| ``` | ||
|
|
||
| ## 安装 | ||
|
|
||
| 1. 复制 `.claude/` 目录到项目根目录或用户主目录 | ||
| 2. 确保 `settings.json` 中的钩子路径正确 | ||
| 3. 确保 `~/.claude/tmpls/` 目录存在且包含模板文件 | ||
|
|
||
| ## 依赖 | ||
|
|
||
| - Claude Code CLI | ||
| - abcoder MCP 服务器(提供 mcp__abcoder 工具) | ||
| - sequential-thinking MCP 服务器(提供 mcp__sequential_thinking 工具) | ||
|
|
||
| ## 相关文档 | ||
|
|
||
| - [hooks/README.md](hooks/README.md) - 钩子系统详解 | ||
| - [commands/README.md](commands/README.md) - 斜杠命令详解 | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.