pattern-detection
37
总安装量
38
周安装量
#5510
全站排名
安装命令
npx skills add https://github.com/supercent-io/skills-template --skill pattern-detection
Agent 安装分布
opencode
33
claude-code
29
codex
29
github-copilot
23
antigravity
20
Skill 文档
Pattern Detection
When to use this skill
- ì½ë 리뷰: 문ì í¨í´ ì¬ì ê°ì§
- ë³´ì ê²í : ì·¨ì½ì í¨í´ ì¤ìº
- 리í©í ë§: ì¤ë³µ ì½ë ìë³
- 모ëí°ë§: ì´ì ì§í ì림
Instructions
Step 1: ì½ë ì¤ë© í¨í´ ê°ì§
긴 í¨ì ê°ì§:
# 50ì¤ ì´ì í¨ì 찾기
grep -n "function\|def\|func " **/*.{js,ts,py,go} | \
while read line; do
file=$(echo $line | cut -d: -f1)
linenum=$(echo $line | cut -d: -f2)
# í¨ì ê¸¸ì´ ê³ì° ë¡ì§
done
ì¤ë³µ ì½ë í¨í´:
# ì ì¬í ì½ë ë¸ë¡ ê²ì
grep -rn "if.*==.*null" --include="*.ts" .
grep -rn "try\s*{" --include="*.java" . | wc -l
ë§¤ì§ ëë²:
# íëì½ë©ë ì«ì ê²ì
grep -rn "[^a-zA-Z][0-9]{2,}[^a-zA-Z]" --include="*.{js,ts}" .
Step 2: ë³´ì ì·¨ì½ì í¨í´
SQL Injection ìí:
# 문ìì´ ì°ê²°ë¡ SQL 쿼리 ìì±
grep -rn "query.*+.*\$\|execute.*%s\|query.*f\"" --include="*.py" .
grep -rn "SELECT.*\+.*\|\|" --include="*.{js,ts}" .
íëì½ë©ë ìí¬ë¦¿:
# ë¹ë°ë²í¸, API í¤ í¨í´
grep -riE "(password|secret|api_key|apikey)\s*=\s*['\"][^'\"]+['\"]" --include="*.{js,ts,py,java}" .
# AWS í¤ í¨í´
grep -rE "AKIA[0-9A-Z]{16}" .
ìíí í¨ì ì¬ì©:
# eval, exec ì¬ì©
grep -rn "eval\(.*\)\|exec\(.*\)" --include="*.{py,js}" .
# innerHTML ì¬ì©
grep -rn "innerHTML\s*=" --include="*.{js,ts}" .
Step 3: ì½ë 구조 í¨í´
ìí¬í¸ ë¶ì:
# ì¬ì©ëì§ ìë ìí¬í¸ íë³´
grep -rn "^import\|^from.*import" --include="*.py" . | \
awk -F: '{print $3}' | sort | uniq -c | sort -rn
TODO/FIXME í¨í´:
# 미ìì± ì½ë 찾기
grep -rn "TODO\|FIXME\|HACK\|XXX" --include="*.{js,ts,py}" .
ìë¬ í¸ë¤ë§ í¨í´:
# ë¹ catch ë¸ë¡
grep -rn "catch.*{[\s]*}" --include="*.{js,ts,java}" .
# 무ìëë ìë¬
grep -rn "except:\s*pass" --include="*.py" .
Step 4: ë°ì´í° ì´ì í¨í´
ì ê·ì í¨í´:
import re
patterns = {
'email': r'[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}',
'phone': r'\d{3}[-.\s]?\d{4}[-.\s]?\d{4}',
'ip_address': r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}',
'credit_card': r'\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}',
'ssn': r'\d{3}-\d{2}-\d{4}',
}
def detect_sensitive_data(text):
found = {}
for name, pattern in patterns.items():
matches = re.findall(pattern, text)
if matches:
found[name] = len(matches)
return found
íµê³ì ì´ì íì§:
import numpy as np
from scipy import stats
def detect_anomalies_zscore(data, threshold=3):
"""Z-score ê¸°ë° ì´ìì¹ íì§"""
z_scores = np.abs(stats.zscore(data))
return np.where(z_scores > threshold)[0]
def detect_anomalies_iqr(data, k=1.5):
"""IQR ê¸°ë° ì´ìì¹ íì§"""
q1, q3 = np.percentile(data, [25, 75])
iqr = q3 - q1
lower = q1 - k * iqr
upper = q3 + k * iqr
return np.where((data < lower) | (data > upper))[0]
Step 5: í¸ë ë ë¶ì
import pandas as pd
def analyze_trend(df, date_col, value_col):
"""ìê³ì´ í¸ë ë ë¶ì"""
df[date_col] = pd.to_datetime(df[date_col])
df = df.sort_values(date_col)
# ì´ë íê·
df['ma_7'] = df[value_col].rolling(window=7).mean()
df['ma_30'] = df[value_col].rolling(window=30).mean()
# ì±ì¥ë¥
df['growth'] = df[value_col].pct_change() * 100
# í¸ë ë ë°©í¥
recent_trend = df['ma_7'].iloc[-1] > df['ma_30'].iloc[-1]
return {
'trend_direction': 'up' if recent_trend else 'down',
'avg_growth': df['growth'].mean(),
'volatility': df[value_col].std()
}
Output format
í¨í´ ê°ì§ 리í¬í¸
# í¨í´ ê°ì§ 리í¬í¸
## ìì½
- ì¤ìº íì¼ ì: XXX
- ê°ì§ë í¨í´: XX
- ì¬ê°ë ëì: X
- ì¬ê°ë ì¤ê°: X
- ì¬ê°ë ë®ì: X
## ê°ì§ë í¨í´
### ë³´ì ì·¨ì½ì (HIGH)
| íì¼ | ë¼ì¸ | í¨í´ | ì¤ëª
|
|------|------|------|------|
| file.js | 42 | hardcoded-secret | API í¤ íëì½ë© |
### ì½ë ì¤ë© (MEDIUM)
| íì¼ | ë¼ì¸ | í¨í´ | ì¤ëª
|
|------|------|------|------|
| util.py | 100 | long-function | í¨ì ê¸¸ì´ 150ì¤ |
## ê¶ì¥ ì¡°ì¹
1. [ì¡°ì¹ 1]
2. [ì¡°ì¹ 2]
Best practices
- ì ì§ì ë¶ì: ê°ë¨í í¨í´ë¶í° ìì
- ì¤í ìµìí: ì íí ì ê·ì ì¬ì©
- 컨í ì¤í¸ íì¸: í¨í´ì ë§¥ë½ íì
- ì°ì ìì ì§ì : ì¬ê°ëë³ ì ë ¬
Constraints
íì ê·ì¹ (MUST)
- ì½ê¸° ì ì© ìì
- ê²°ê³¼ ê²ì¦ ìí
- ì¤í ê°ë¥ì± ëª ì
ê¸ì§ ì¬í (MUST NOT)
- ì½ë ìë ìì ê¸ì§
- ë¯¼ê° ì ë³´ ë¡ê¹ ê¸ì§