소스 정보
- 저장소
- Mte90/dotfiles
- 최근 소스 활동
- 2026년 8월 26일 09:10
- 감지된 SKILL.md 언어
- 영어
- 스타
- 51
- 포크
- 6
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/Mte90/dotfiles --skill ast-grep명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
| name | ast-grep |
| description | ast-grep - Fast structural code search, linting, and rewriting CLI tool |
| metadata | {"author":"mte90","version":"1.0.0","tags":["ast-grep","code-search","linting","refactoring","cli","ast"]} |
Fast and user-friendly tool for large-scale code searching, linting, and rewriting using AST patterns.
ast-grep (sg) is a CLI tool that searches code based on Abstract Syntax Tree patterns, similar to syntax-aware grep/sed. It supports multiple languages and can perform automated code refactoring.
all, any, and not operatorsinside, has, precedes# Via cargo
cargo install ast-grep
# Via npm
npm install -g ast-grep
# Via pip
pip install ast-grep
# Download pre-built binary
curl -L https://github.com/ast-grep/ast-grep/releases/download/nightly/ast-grep-x86_64-unknown-linux-musl.tar.gz | tar xz
# Basic pattern search - find all console.log calls
ast-grep run --pattern 'console.log($ARG)' --lang javascript src/
# Short form with language inference from file extensions
ast-grep -p 'console.log($ARG)' src/
# Search with multiple arguments using multi-metavariable
ast-grep -p 'console.log($$$ARGS)' src/
# Search for function declarations
ast-grep -p 'function $NAME($$$PARAMS) { $$$ }' --lang typescript src/
# Debug pattern parsing
ast-grep -p 'console.log($A)' --lang javascript --debug-query=ast
# Show context around matches
ast-grep -p 'TODO' --context 3 src/
# Search and rewrite - add optional chaining
ast-grep -p '$OBJ.val && $OBJ.val()' --rewrite '$OBJ.val?.()' src/
# Interactive mode - confirm each replacement
ast-grep -p '$PROP && $PROP()' -r '$PROP?.()' --interactive src/
# Apply all rewrites without confirmation
ast-grep -p 'var $X' -r 'let $X' --update-all src/
# Output results as JSON for piping to other tools
ast-grep -p 'import $$$' --json src/ | jq '.[] | .text'
# Scan with a single rule file
ast-grep scan --rule rules/no-console.yml src/
# Scan with project configuration (sgconfig.yml)
ast-grep scan --config sgconfig.yml src/
# Scan with inline rule (no file needed)
ast-grep scan --inline-rules '
id: no-debugger
language: JavaScript
rule:
pattern: debugger
' src/
# Filter rules by ID pattern
ast-grep scan --filter 'security-*' src/
# Output in SARIF format for CI integration
ast-grep scan --format sarif src/
# Set rule severity via CLI
ast-grep scan --error=no-console --warning=prefer-const src/
# GitHub Actions compatible output
ast-grep scan --format github src/
$VAR - Matches single AST node$$$VARGS - Matches zero or more AST nodes (variadic)# JavaScript/TypeScript
'console.log($MSG)' # Single argument
'console.log($$$ARGS)' # Multiple arguments
'function $NAME($$$PARAMS) { $$$ }' # Function declaration
'const $X = $Y' # Variable declaration
'$X && $X()' # Conditional call
# Python
'def $FUNC($$$ARGS): $$$' # Function definition
'class $NAME($$$BASE): $$$' # Class definition
'import $X from $Y' # Named import
'from $X import $$$' # From import
'for $X in $Y: $$$' # For loop
# Explicit language
ast-grep -p 'pattern' --lang typescript src/
# Auto-detect from file extension
ast-grep -p 'pattern' src/
# rules/no-console.yml
id: no-console
message: "Do not use console.log in production"
severity: warning
language: JavaScript
rule:
pattern: console.log($ARG)
# sgconfig.yml
rules:
- id: no-var
message: "Use let/const instead of var"
severity: warning
language: JavaScript
rule:
pattern: var $X
fix:
rewrite: let $X
- id: prefer-const
message: "Use const for variables not reassigned"
severity: warning
language: JavaScript
rule:
pattern: let $X = $Y
from: $Y
where:
- $Y
fix:
rewrite: const $X = $Y
id: security-no-inner-html
message: "Setting innerHTML can lead to XSS attacks"
severity: error
language: TypeScript
rule:
pattern: |
$EL.innerHTML = $SOURCE
fix:
rewrite: |
$EL.textContent = $SOURCE
scope: script
# .github/workflows/lint.yml
name: ast-grep
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run ast-grep
uses: ast-grep/ast-grep-action@latest
with:
args: scan --format github src/
# .pre-commit-config.yaml
repos:
- repo: https://github.com/ast-grep/ast-grep
rev: stable
hooks:
- id: ast-grep
args: ['--config', 'sgconfig.yml', 'scan']
Install from VS Code Marketplace: ast-grep
Features:
ast-grep -p 'TODO' --lang typescript src/
ast-grep -p 'console.log($$$ARGS)' --rewrite '' --update-all src/
ast-grep -p 'var $X' -r 'const $X' --lang javascript --update-all src/
ast-grep -p 'class $NAME extends React.Component { $$$ }' \
--rewrite 'class $NAME extends React.Component {
componentDidCatch(error, info) {
console.error(error, info);
}
$$$ }' \
--lang javascript --update-all src/
# Define rule in YAML
# rules/no-unused-vars.yml
id: no-unused-vars
language: TypeScript
rule:
pattern: |
const $NAME = $VALUE
where:
- $VALUE
scope: code
# Find fetch calls inside useEffect
id: fetch-in-useeffect
language: TypeScript
rule:
all:
- pattern: 'fetch($ARGS)'
- inside:
pattern: 'useEffect(() => { $$$ }, $$$)'
# Find async functions that use await but lack try-catch
id: async-without-try
language: TypeScript
rule:
all:
- pattern: 'async function $F($$$) { $$$ }'
- has:
pattern: 'await $EXPR'
- not:
inside:
pattern: 'try { $$$ } catch { $$$ }'
# Detect eval() usage
id: no-eval
language: JavaScript
message: "eval() is dangerous - potential code injection"
severity: error
rule:
pattern: 'eval($ARG)'
# Detect hardcoded passwords
id: hardcoded-secret
language: Python
message: "Hardcoded credentials detected"
severity: error
rule:
pattern: |
password = '$PASS'
# Test pattern without rewriting
ast-grep -p 'pattern' src/
# Then run with --dry-run equivalent (no --update-all)
ast-grep -p 'pattern' --rewrite 'new_pattern' --interactive src/
# Explicit language avoids ambiguity
ast-grep -p '$X' --lang python src/
ast-grep -p 'console.log' --json src/ | jq '.[] | .file_path'
# Find files modified in git and search
git diff --name-only HEAD~1 | xargs ast-grep -p 'pattern'
# Search and format
ast-grep -p 'pattern' --json src/ | jq -r '.[].file_path' | xargs prettier --write
ast-grep run --pattern before applying fixes--interactive mode for important rewritessgconfig.yml for project-wide rules--lang flag to avoid ambiguity--update-all without testing pattern first