‹ 首页

ast-grep

@code-yeongyu · 收录于 1 周前 · 上游提交 今天

Use ast-grep (sg) for AST-aware code search and rewrite across 25 languages. Trigger for structural code matching or deterministic codemods: find every function/call/class/import shaped like X, rewrite console.log to logger.info, strip `as any`, migrate require() to import, find empty catch blocks or missing await, and scan/apply YAML rules. Prefer this over rg/grep when the target is syntax shape rather than text; use rg for string contents, comments, filenames, or regex-style byte searches.

适合你,如果需要在多语言项目中按代码结构而非文本进行搜索和替换

/ 通过 npx 安装 校验哈希
npx oh-my-skill add code-yeongyu/oh-my-openagent/ast-grep
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- code-yeongyu/oh-my-openagent/ast-grep
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify code-yeongyu/oh-my-openagent/ast-grep
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
65973GitHub stars
~3K最小装载
~23.8K含声明引用
~28.5K文本包总量
镜像托管

怎么用

商店整理自技能原文 · 版本 5ef852a · 表述以原文为准
它做什么

安装后,Claude 能根据代码结构(而非文本)搜索和重写代码,支持 25 种编程语言。例如,找到所有带特定参数的函数,或将 console.log 替换为 logger.info。

什么时候触发

当用户要求查找或修改代码结构(如函数、类、调用、导入)时触发。对于纯文本搜索(如字符串内容、注释),则使用 grep。

装好后可以这样说
Claude 会用 ast-grep 搜索匹配的函数定义。
Claude 会先预览再执行替换。
Claude 会运行 sg scan 并展示结果。

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。