Skip to content

Commit 9cbcb4d

Browse files
authored
feat: Claude Code integrate(Auto config/standard workflow/some fixs & opts) (#147)
* feat: rename illegal files * feat: support auto install cc integretion * optimize: parser before list * optimize: add a cache time for parse.sh * optimize: sop * fix: wrong return schema in hooks * fix: parse cache * optimize: add more details for slash commands * chore: rename schd -> schedule * refactor: cc intergrete * docs: update READEME * feat: re-parse if files changed by cc * fix: wrong key in reminder hook
1 parent ba7a7c0 commit 9cbcb4d

File tree

20 files changed

+562
-212
lines changed

20 files changed

+562
-212
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ testdata/repos
7373
testdata/jsons
7474

7575
src/lang/testdata
76-
*.json
7776
!ts-parser/**/*.json
7877

7978
tools
80-
abcoder
8179

8280
!testdata/asts/*.json

README.md

Lines changed: 88 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -25,101 +25,40 @@ see [UniAST Specification](docs/uniast-zh.md)
2525

2626

2727
# Quick Start
28-
## Use ABCoder as a MCP server
29-
30-
1. Install ABCoder:
31-
32-
```bash
33-
go install github.com/cloudwego/abcoder@latest
34-
```
35-
36-
2. Use ABCoder to parse a repository to UniAST (JSON)
37-
38-
```bash
39-
abcoder parse {language} {repo-path} -o xxx.json
40-
```
41-
42-
ABCoder will try to install any dependency automatically.
43-
In case of failure (or if you want to customize installation), refer to the [docs](./docs/lsp-installation-en.md).
44-
45-
For example, to parse a Go repository:
46-
47-
```bash
48-
git clone https://github.com/cloudwego/localsession.git localsession
49-
abcoder parse go localsession -o /abcoder-asts/localsession.json
50-
```
51-
52-
53-
3. Integrate ABCoder's MCP tools into your AI agent.
54-
55-
```json
56-
{
57-
"mcpServers": {
58-
"abcoder": {
59-
"command": "abcoder",
60-
"args": [
61-
"mcp",
62-
"{the-AST-directory}"
63-
]
64-
}
65-
}
66-
}
67-
```
68-
69-
70-
4. Enjoy it!
71-
72-
Try to click and watch the video below:
73-
74-
<div align="center">
75-
76-
[<img src="images/abcoder-hertz-trae.png" alt="MCP" width="500"/>](https://www.bilibili.com/video/BV14ggJzCEnK)
77-
78-
</div>
79-
80-
81-
## Tips:
82-
83-
- You can add more repo ASTs into the AST directory without restarting abcoder MCP server.
84-
85-
- Try to use [the recommended prompt](llm/prompt/analyzer.md) and combine planning/memory tools like [sequential-thinking](https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking) in your AI agent.
86-
8728

8829
## Claude Code Integration
8930

90-
ABCoder provides deep integration with [Claude Code](https://claude.ai/code) through the AST-Driven Coding workflow, enabling hallucination-free code analysis and precise execution.
31+
ABCoder provides deep integration with [Claude Code](https://claude.ai/code) through the AST-Driven Coding workflow, enabling hallucination-free code analysis and precise execution. Check [Claude Code Specification](docs/claude-code-spec.md) for more details.
9132

9233
### Setup
9334

94-
1. **Install ABCoder Claude Configuration**
95-
96-
Copy [`docs/.claude/`](docs/.claude/) to your home directory or project root:
35+
Use the `init-spec` command to automatically configure Claude Code integration for your project:
9736

98-
```bash
99-
cp -r docs/.claude ~/
100-
```
37+
```bash
38+
# Install ABCoder
39+
go install github.com/cloudwego/abcoder@latest
10140

102-
2. **Configure ABCoder MCP Server**
41+
# Run init-spec in your project directory (optional: specify target path)
42+
cd /path/to/your/project
43+
abcoder init-spec
44+
```
10345

104-
Configure in Claude Code's `~/.claude.json` (the hook uses `abcoder parse go/ts . -o ~/.asts/repo.json` for the default AST folder):
46+
The `init-spec` command will:
47+
1. Copy `.claude` directory to your project root
48+
2. Configure MCP servers in `~/.claude.json`:
49+
- `abcoder`: for code analysis using AST
50+
- `sequential-thinking`: for complex problem decomposition
51+
3. Replace all `{{CLAUDE_HOME_PATH}}` placeholders with actual project paths
10552

106-
```json
107-
{
108-
"mcpServers": {
109-
"abcoder": {
110-
"command": "abcoder",
111-
"args": ["mcp", "~/.asts"]
112-
}
113-
}
114-
}
115-
```
53+
### Start Coding with Claude Code
11654

117-
3. **Configure Hooks**
55+
Once setup, you can start coding with Claude Code:
11856

119-
Claude Code will automatically read hooks from [`~/.claude/settings.json`](docs/.claude/settings.json) to enable:
120-
- Auto-detect language and generate AST before calling `mcp__abcoder` tools
121-
- Display ABCoder workflow SOP to Claude after `list_repos`
122-
- Remind to call `get_ast_node` recursively
57+
1. Start Claude Code in your project directory
58+
2. Use slash common `/abcoder:schedule <problem_desc>` to address your feature/requirement/issue, and ABCoder will help you analyze the codebase and design a technical solution.
59+
3. Once all questions are set, use slash common `/abcoder:task <task_name>` to create a coding task(specification)
60+
4. Recheck the task using `/abcoder:recheck <task_name>` before real implementation
61+
5. Begin coding! Claude Code will process the task step by step according to the specification, leveraging the power of AST-driven analysis.
12362

12463
### AST-Driven Coding Workflow
12564

@@ -137,7 +76,7 @@ list_repos → get_repo_structure → get_package_structure → get_file_structu
13776

13877
| Command | Function | Description |
13978
|---------|----------|-------------|
140-
| [`/abcoder:schd`](docs/.claude/commands/abcoder:schd.md) | Design implementation | Analyze codebase using ABCoder, design technical solution |
79+
| [`/abcoder:schedule` <task_desc>](docs/.claude/commands/abcoder:schedule.md) | Design implementation | Analyze codebase by using ABCoder, design technical solution |
14180
| [`/abcoder:task <name>`](docs/.claude/commands/abcoder:task.md) | Create coding task | Generate standardized CODE_TASK document |
14281
| [`/abcoder:recheck <task>`](docs/.claude/commands/abcoder:recheck.md) | Verify solution | Critically check CODE_TASK feasibility, useful when a CODE_TASK contains external dependencies |
14382

@@ -147,7 +86,7 @@ list_repos → get_repo_structure → get_package_structure → get_file_structu
14786
User Request
14887
14988
150-
/abcoder:schd ──────────→ Design Solution (ABCoder Analysis)
89+
/abcoder:schedule ──────────→ Design Solution (ABCoder Analysis)
15190
│ │
15291
▼ ▼
15392
/abcoder:task ─────────→ CODE_TASK (with Technical Specs, including accurate `get_ast_node` call args)
@@ -156,7 +95,7 @@ User Request
15695
/abcoder:recheck ────→ Verify Solution (ABCoder Validation. After `/abcoder:task` Claude Code will tell you what the external dependencies CODE_TASK contains, use `/abcoder:recheck` to analyze external ast_node and technical detail with ABCoder)
15796
│ │
15897
▼ ▼
159-
sub-agent ─────────→ Execute Implementation
98+
Start coding(sub-agent) ─────────→ Execute Implementation
16099
```
161100

162101
### Configuration Files
@@ -166,19 +105,78 @@ sub-agent ─────────→ Execute Implementation
166105
| [`CLAUDE.md`](docs/.claude/CLAUDE.md) | Core AST-Driven Coder role definition |
167106
| [`settings.json`](docs/.claude/settings.json) | Hooks and permissions configuration |
168107
| [`hooks/`](docs/.claude/hooks/) | Automation scripts (parse/prompt/reminder) |
169-
| [`commands/`](docs/.claude/commands/) | Slash command definitions (abcoder:task/abcoder:schd/abcoder:recheck) |
170-
| [`tmpls/CODE_TASK.md`](docs/.claude/tmpls/CODE_TASK.md) | Coding task template |
108+
| [`commands/`](docs/.claude/commands/) | Slash command definitions (abcoder:task/abcoder:schedule/abcoder:recheck) |
109+
| [`tmpls/ABCODER_CODE_TASK.md`](docs/.claude/tmpls/ABCODER_CODE_TASK.md) | Coding task template |
171110

172111
### Dependencies
173112

174113
- Claude Code CLI
175-
- abcoder MCP server (provides `mcp__abcoder` tools)
176-
- sequential-thinking MCP server (provides `mcp__sequential_thinking` tools, optional)
114+
- ABCoder MCP server (provides `mcp__abcoder` tools)
115+
- Sequential-thinking MCP server (provides `mcp__sequential_thinking` tools, automatically configured by init-spec)
177116

178117
> For detailed configuration, see [docs/.claude/README.md](docs/.claude/README.md)
179118
180119
> Watch the demo video [here](https://github.com/cloudwego/abcoder/pull/141)
181120
121+
## Use ABCoder as a MCP server
122+
123+
1. Install ABCoder:
124+
125+
```bash
126+
go install github.com/cloudwego/abcoder@latest
127+
```
128+
129+
2. Use ABCoder to parse a repository to UniAST (JSON)
130+
131+
```bash
132+
abcoder parse {language} {repo-path} -o xxx.json
133+
```
134+
135+
ABCoder will try to install any dependency automatically.
136+
In case of failure (or if you want to customize installation), refer to the [docs](./docs/lsp-installation-en.md).
137+
138+
For example, to parse a Go repository:
139+
140+
```bash
141+
git clone https://github.com/cloudwego/localsession.git localsession
142+
abcoder parse go localsession -o /abcoder-asts/localsession.json
143+
```
144+
145+
146+
3. Integrate ABCoder's MCP tools into your AI agent.
147+
148+
```json
149+
{
150+
"mcpServers": {
151+
"abcoder": {
152+
"command": "abcoder",
153+
"args": [
154+
"mcp",
155+
"{the-AST-directory}"
156+
]
157+
}
158+
}
159+
}
160+
```
161+
162+
163+
4. Enjoy it!
164+
165+
Try to click and watch the video below:
166+
167+
<div align="center">
168+
169+
[<img src="images/abcoder-hertz-trae.png" alt="MCP" width="500"/>](https://www.bilibili.com/video/BV14ggJzCEnK)
170+
171+
</div>
172+
173+
174+
## Tips:
175+
176+
- You can add more repo ASTs into the AST directory without restarting abcoder MCP server.
177+
178+
- Try to use [the recommended prompt](llm/prompt/analyzer.md) and combine planning/memory tools like [sequential-thinking](https://github.com/modelcontextprotocol/servers/tree/main/src/sequentialthinking) in your AI agent.
179+
182180
183181
## Use ABCoder as an Agent (WIP)
184182

docs/.claude/hooks/abcoder/reminder.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

docs/.claude/settings.json

Lines changed: 0 additions & 43 deletions
This file was deleted.
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Claude Code 的 AST 驱动开发配置,通过 MCP 工具、钩子和斜杠命
1414
│ └── reminder.sh # 提醒递归调用 get_ast_node
1515
├── commands/ # 斜杠命令定义
1616
│ ├── abcoder:task.md # /abcoder:task - 创建编码任务
17-
│ ├── abcoder:schd.md # /abcoder:schd - 设计实现方案
17+
│ ├── abcoder:schedule.md # /abcoder:schedule - 设计实现方案
1818
│ └── abcoder:recheck.md # /abcoder:recheck - 技术方案核对
1919
└── tmpls/ # 文档模板
2020
└── CODE_TASK.md # 编码任务模板
@@ -63,7 +63,7 @@ list_repos → get_repo_structure → get_package_structure → get_file_structu
6363

6464
## 斜杠命令
6565

66-
### /abcoder:task <名称>
66+
### /abcoder:task <任务名称>
6767

6868
创建 CODE_TASK 文档,生成 `./task/{{MMDD}}/{{NAME}}__CODE_TASK.md`
6969

@@ -73,7 +73,7 @@ list_repos → get_repo_structure → get_package_structure → get_file_structu
7373
- 涉及 curl: 提供完整命令和响应结构
7474
- 提供具体验证方法
7575

76-
### /abcoder:schd
76+
### /abcoder:schedule <任务描述>
7777

7878
使用 mcp__abcoder 设计实现方案
7979

@@ -82,7 +82,7 @@ list_repos → get_repo_structure → get_package_structure → get_file_structu
8282
- 优先最小改动
8383
- 禁止编写代码、禁止使用 agent
8484

85-
### /abcoder:recheck <任务>
85+
### /abcoder:recheck <任务名称>
8686

8787
批判性检查 CODE_TASK 技术可行性
8888

@@ -97,7 +97,7 @@ list_repos → get_repo_structure → get_package_structure → get_file_structu
9797
用户需求
9898
9999
100-
/abcoder:schd ──────────────→ 设计方案(abcoder分析)
100+
/abcoder:schedule ──────────────→ 设计方案(abcoder分析)
101101
│ │
102102
▼ ▼
103103
/abcoder:task ────────→ CODE_TASK(含技术规格)
File renamed without changes.

docs/.claude/commands/README.md renamed to internal/utils/assets/.claude/commands/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Claude Code 斜杠命令定义,用于规范化和自动化开发工作流。
1010

1111
**执行流程**:
1212
1. 创建 `./task/{{MMDD}}/` 目录
13-
2. 读取模板 `~/.claude/tmpls/CODE_TASK.md`
13+
2. 读取模板 `{{CLAUDE_HOME_PATH}}/.claude/tmpls/ABCODER_CODE_TASK.md`
1414
3. 根据任务上下文填充模板,生成 `./task/{{MMDD}}/{{NAME}}__CODE_TASK.md`
1515
4. 列出外部依赖包(如有)
1616
5. 提示创建成功
@@ -30,7 +30,7 @@ Claude Code 斜杠命令定义,用于规范化和自动化开发工作流。
3030

3131
---
3232

33-
### /abcoder:schd - 设计实现方案
33+
### /abcoder:schedule - 设计实现方案
3434

3535
使用 mcp__abcoder 分析代码库,设计技术实现方案。
3636

@@ -66,7 +66,7 @@ Claude Code 斜杠命令定义,用于规范化和自动化开发工作流。
6666

6767
## 模板文件
6868

69-
### CODE_TASK.md
69+
### ABCODER_CODE_TASK.md
7070

7171
编码任务模板,定义任务清单格式。
7272

@@ -89,7 +89,7 @@ Claude Code 斜杠命令定义,用于规范化和自动化开发工作流。
8989
用户需求
9090
9191
92-
/abcoder:schd ──────────────→ 设计方案(abcoder分析)
92+
/abcoder:schedule ──────────────→ 设计方案(abcoder分析)
9393
│ │
9494
▼ ▼
9595
/abcoder:task ────────→ CODE_TASK(含技术规格)
@@ -104,11 +104,11 @@ coding-executor ──────→ 执行实现
104104
## 文件位置
105105

106106
```
107-
~/.claude/
107+
{{CLAUDE_HOME_PATH}}/.claude/
108108
├── commands/
109109
│ ├── abcoder:task.md
110-
│ ├── abcoder:schd.md
110+
│ ├── abcoder:schedule.md
111111
│ └── abcoder:recheck.md
112112
└── tmpls/
113-
└── CODE_TASK.md
113+
└── ABCODER_CODE_TASK.md
114114
```

0 commit comments

Comments
 (0)