Skip to content

lidge-jun/codexclaw / plugins/codexclaw/skills/ast-grep

cxc-ast-grep

Verified

Use for AST search and codemods. Triggers: ast-grep, sg, function/call/class/import, empty catch, missing await, YAML rules.

FileKindSize
LICENSEother1.0 KB
SKILL.mdskill md5.0 KB
agents/openai.yamlconfig152 B
references/install.mdmarkdown1.5 KB
references/patterns.mdmarkdown3.4 KB
scripts/ast_grep_helper.pyexecutablescript26.6 KB

references/install.md

View on GitHub
# Installing / provisioning `sg` (ast-grep)

The helper resolves the `sg` binary lazily and never assumes a global install.

## Resolution order

1. `CODEXCLAW_AST_GREP_SG_PATH` (explicit override; `OMO_AST_GREP_SG_PATH` fallback).
2. codexclaw runtime: `$CODEX_HOME/runtime/ast-grep/<os>-<arch>/sg`, then
   `~/.codexclaw/runtime/ast-grep/<os>-<arch>/sg`.
3. A cached binary under this skill's `bin/`.
4. `PATH` (via `which`).
5. Homebrew defaults (`/opt/homebrew/bin/ast-grep`, `/opt/homebrew/bin/sg`).

## Lazy provisioning

Run the helper's `install` subcommand to provision on demand:

```
python3 scripts/ast_grep_helper.py install
```

It delegates to the platform install path and is idempotent — re-running when
`sg` is already present is a no-op. If provisioning fails, the helper prints a
clear hint (network, permissions, or unsupported platform) instead of crashing.

## Manual install options

- npm: `npm install -g @ast-grep/cli`
- Homebrew: `brew install ast-grep`
- Cargo: `cargo install ast-grep`

On Windows: download the binary from the ast-grep releases page or use
`winget install ast-grep`.

After installing, confirm with:

```
python3 scripts/ast_grep_helper.py doctor
```

which reports the resolved binary path and version, or a missing-binary hint.

## codexclaw doctor

`cxc doctor` includes an `ast-grep` status line (provisioned / PATH fallback /
missing / provisioning failed) with the binary path and version when available,
so plugin health surfaces the runtime state without a separate command.
receiving-code-reviewobra/superpowersUse when receiving code review feedback, before implementing suggestions, especially if feedback seems unclear or technically questionable - requires technical rigor and verification, not performative agreement or blind implementationStars: 322kUpdated Claude CodeCodexVerifiedInstall
requesting-code-reviewobra/superpowersUse when completing tasks, implementing major features, or before merging to verify work meets requirementsStars: 322kUpdated Claude CodeCodexVerifiedInstall
using-git-worktreesobra/superpowersUse when starting feature work that needs isolation from current workspace or before executing implementation plans - ensures an isolated workspace exists via native tools or git worktree fallbackStars: 322kUpdated Claude CodeCodexVerifiedInstall
verification-before-completionobra/superpowersUse when about to claim work is complete, fixed, or passing, before committing or creating PRs - requires running verification commands and confirming output before making any success claims; evidence before assertions alwaysStars: 322kUpdated Claude CodeCodexVerifiedInstall