// 读懂代码库
ast-grep0.50.0
基于语法树的代码搜索与重写
开源 维护中 给 AI 用
一段话结论
ast-grep 是基于语法树的代码搜索与重写。
适合:想让自己的 agent(Claude Code、Codex、Cursor 等)读懂代码库的开发者。
要点:结构化代码搜索/改写
01怎么开始
- 1先读官方 README / 文档,确认运行环境和需要的权限。
- 2从官方包管理器安装:
npm install @ast-grep/clipip install ast-grep-cli - 3把它加到 agent 的 MCP 配置里——Claude Code:
claude mcp add;Cursor:.cursor/mcp.json;Codex:~/.codex/config.toml。