{"id":"9337ae78-c08a-45f1-baa9-973a66833f8c","shortId":"27AdUN","kind":"skill","title":"ast-grep Structural Code Search and Rewrite","tagline":"Use ast-grep (sg) to search, lint, and rewrite code across large codebases using AST pattern matching. A blazing-fast alternative to regex-based code transformations that understands syntax structure.","description":"# ast-grep Structural Code Search and Rewrite\n\nUse ast-grep (sg) to search, lint, and rewrite code across large codebases using AST pattern matching. A blazing-fast alternative to regex-based code transformations that understands syntax structure.\n\n## Installation\n\nUse the upstream install or setup path that matches your environment:\n- npm install --global @ast-grep/cli\n- pip install ast-grep-cli\n- brew install ast-grep\n- cargo install ast-grep --locked\n\nRequirements and caveats from upstream:\n- You can use $ sign + upper case letters as a [wildcard](https://en.wikipedia.org/wiki/Wildcard_character), e.g. $MATCH, to match any single AST node. Think of it as [regular expression dot](https://regexone.com/lesson...\n- You can install it from [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm), [pip](https://pypi.org/), [cargo](https://doc.rust-lang.org/cargo/getting-started/installation.html), [cargo-binstall](...\n\nBasic usage or getting-started notes:\n- bash\n- # pnpm approve-builds may be needed\n- <details>\n\n- Source: https://github.com/ast-grep/ast-grep\n- Extracted from upstream docs: https://raw.githubusercontent.com/ast-grep/ast-grep/HEAD/README.md\n\n## Source\n\n- [Agent Skill Exchange](https://agentskillexchange.com/skills/ast-grep-structural-code-search-rewrite/)","tags":["ast","grep","structural","code","search","rewrite","skills","agentskillexchange","agent-skills","ai-agents","ai-tools","awesome-list"],"capabilities":["skill","source-agentskillexchange","skill-ast-grep-structural-code-search-rewrite","topic-agent-skills","topic-ai-agents","topic-ai-tools","topic-awesome-list","topic-claude-code","topic-codex","topic-cursor","topic-llm","topic-mcp","topic-npx-skills","topic-openclaw","topic-skills-catalog"],"categories":["skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/agentskillexchange/skills/ast-grep-structural-code-search-rewrite","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add agentskillexchange/skills","source_repo":"https://github.com/agentskillexchange/skills","install_from":"skills.sh"}},"qualityScore":"0.454","qualityRationale":"deterministic score 0.45 from registry signals: · indexed on github topic:agent-skills · 8 github stars · SKILL.md body (1,304 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-05-18T19:09:28.340Z","embedding":null,"createdAt":"2026-05-18T13:15:12.858Z","updatedAt":"2026-05-18T19:09:28.340Z","lastSeenAt":"2026-05-18T19:09:28.340Z","tsv":"'/),':167 '/ast-grep/ast-grep':193 '/ast-grep/ast-grep/head/readme.md':200 '/cargo/getting-started/installation.html),':171 '/cli':101 '/downloading-and-installing-node-js-and-npm),':163 '/lesson...':154 '/skills/ast-grep-structural-code-search-rewrite/)':207 '/wiki/wildcard_character),':136 'across':20,61 'agent':202 'agentskillexchange.com':206 'agentskillexchange.com/skills/ast-grep-structural-code-search-rewrite/)':205 'altern':31,72 'approv':185 'approve-build':184 'ast':2,11,24,43,52,65,99,105,111,116,143 'ast-grep':1,10,42,51,98,110,115 'ast-grep-c':104 'base':35,76 'bash':182 'basic':175 'binstal':174 'blaze':29,70 'blazing-fast':28,69 'brew':108 'build':186 'cargo':113,168,173 'cargo-binstal':172 'case':129 'caveat':121 'cli':107 'code':5,19,36,46,60,77 'codebas':22,63 'doc':197 'doc.rust-lang.org':170 'doc.rust-lang.org/cargo/getting-started/installation.html),':169 'docs.npmjs.com':162 'docs.npmjs.com/downloading-and-installing-node-js-and-npm),':161 'dot':151 'e.g':137 'en.wikipedia.org':135 'en.wikipedia.org/wiki/wildcard_character),':134 'environ':94 'exchang':204 'express':150 'extract':194 'fast':30,71 'get':179 'getting-start':178 'github.com':192 'github.com/ast-grep/ast-grep':191 'global':97 'grep':3,12,44,53,100,106,112,117 'instal':83,87,96,103,109,114,157 'larg':21,62 'letter':130 'lint':16,57 'lock':118 'match':26,67,92,138,140 'may':187 'need':189 'node':144 'note':181 'npm':95,160 'path':90 'pattern':25,66 'pip':102,164 'pnpm':183 'pypi.org':166 'pypi.org/),':165 'raw.githubusercontent.com':199 'raw.githubusercontent.com/ast-grep/ast-grep/head/readme.md':198 'regex':34,75 'regex-bas':33,74 'regexone.com':153 'regexone.com/lesson...':152 'regular':149 'requir':119 'rewrit':8,18,49,59 'search':6,15,47,56 'setup':89 'sg':13,54 'sign':127 'singl':142 'skill':203 'skill-ast-grep-structural-code-search-rewrite' 'sourc':190,201 'source-agentskillexchange' 'start':180 'structur':4,41,45,82 'syntax':40,81 'think':145 'topic-agent-skills' 'topic-ai-agents' 'topic-ai-tools' 'topic-awesome-list' 'topic-claude-code' 'topic-codex' 'topic-cursor' 'topic-llm' 'topic-mcp' 'topic-npx-skills' 'topic-openclaw' 'topic-skills-catalog' 'transform':37,78 'understand':39,80 'upper':128 'upstream':86,123,196 'usag':176 'use':9,23,50,64,84,126 'wildcard':133","prices":[{"id":"e9ddd18e-fd2f-41cd-b8fe-e040fe848bf6","listingId":"9337ae78-c08a-45f1-baa9-973a66833f8c","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"agentskillexchange","category":"skills","install_from":"skills.sh"},"createdAt":"2026-05-18T13:15:12.858Z"}],"sources":[{"listingId":"9337ae78-c08a-45f1-baa9-973a66833f8c","source":"github","sourceId":"agentskillexchange/skills/ast-grep-structural-code-search-rewrite","sourceUrl":"https://github.com/agentskillexchange/skills/tree/main/skills/ast-grep-structural-code-search-rewrite","isPrimary":false,"firstSeenAt":"2026-05-18T13:15:12.858Z","lastSeenAt":"2026-05-18T19:09:28.340Z"}],"details":{"listingId":"9337ae78-c08a-45f1-baa9-973a66833f8c","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"agentskillexchange","slug":"ast-grep-structural-code-search-rewrite","github":{"repo":"agentskillexchange/skills","stars":8,"topics":["agent-skills","ai-agents","ai-tools","awesome-list","claude-code","codex","cursor","llm","mcp","npx-skills","openclaw","skills-catalog"],"license":"mit","html_url":"https://github.com/agentskillexchange/skills","pushed_at":"2026-05-18T19:02:17Z","description":"The open catalog of AI agent skills — 2,000+ security-scanned skills for Claude Code, Cursor, Codex, and more.","skill_md_sha":"1f2781917e53206b08c7d0d7f51eeddd2b0badfb","skill_md_path":"skills/ast-grep-structural-code-search-rewrite/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/agentskillexchange/skills/tree/main/skills/ast-grep-structural-code-search-rewrite"},"layout":"multi","source":"github","category":"skills","frontmatter":{"name":"ast-grep Structural Code Search and Rewrite","description":"Use ast-grep (sg) to search, lint, and rewrite code across large codebases using AST pattern matching. A blazing-fast alternative to regex-based code transformations that understands syntax structure."},"skills_sh_url":"https://skills.sh/agentskillexchange/skills/ast-grep-structural-code-search-rewrite"},"updatedAt":"2026-05-18T19:09:28.340Z"}}