用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/RunnerQuan/SAFE-Agent --skill review命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | review |
| description | Multi-agent code analysis covering security, performance, quality, and architecture |
| disable-model-invocation | false |
I'll review your code for potential issues.
Token Optimization:
Caching Behavior:
.claude/cache/review/last-review.json/security-scan, /predict-issues skillsUsage:
review - Review changed files only (default, 2,000-4,000 tokens)review --security - Security focus only (3,000-5,000 tokens)review --performance - Performance focus only (3,000-5,000 tokens)review --full - Complete codebase review (10,000-20,000 tokens)Optimization: Determine Review Scope
# Check for focus area flags (saves 75% by running only requested sub-agents)
FOCUS_SECURITY=false
FOCUS_PERFORMANCE=false
FOCUS_QUALITY=false
FOCUS_ARCHITECTURE=false
FULL_REVIEW=false
# Parse arguments (e.g., --security, --full)
for arg in "$@"; do
case $arg in
--security) FOCUS_SECURITY=true ;;
--performance) FOCUS_PERFORMANCE=true ;;
--quality) FOCUS_QUALITY=true ;;
--architecture) FOCUS_ARCHITECTURE=true ;;
--full) FULL_REVIEW=true ;;
esac
done
# Default to changed files only (90% token savings)
if [ "$FULL_REVIEW" = false ]; then
FILES_TO_REVIEW=$(git diff --name-only HEAD)
if [ -z "$FILES_TO_REVIEW" ]; then
echo "✓ No changed files to review"
exit 0 # Early exit, saves 95% tokens
fi
echo "Reviewing changed files: $(echo "$FILES_TO_REVIEW" | wc -l) files"
else
echo "Reviewing entire codebase (--full flag)"
fi
Optimization: Check Cached Review Results
# Check cache for unchanged files (70% savings on re-reviews)
CACHE_FILE=".claude/cache/review/last-review.json"
if [ -f "$CACHE_FILE" ] && [ "$FULL_REVIEW" = false ]; then
# Compare file checksums to detect changes
CHANGED=$(echo "$FILES_TO_REVIEW" | while read file; do
if [ -f "$file" ]; then
CURRENT_CHECKSUM=$(md5sum "$file" 2>/dev/null | cut -d' ' -f1)
CACHED_CHECKSUM=$(jq -r ".files.\"$file\".checksum" "$CACHE_FILE" 2>/dev/null)
if [ "$CURRENT_CHECKSUM" != "$CACHED_CHECKSUM" ]; then
echo "$file"
fi
fi
done)
if [ -z "$CHANGED" ]; then
echo "✓ No file changes since last review"
jq '.issues' "$CACHE_FILE"
exit 0
Let me create a checkpoint before detailed analysis:
git add -A
git commit -m "Pre-review checkpoint" || echo "No changes to commit"
I'll use specialized sub-agents for comprehensive analysis (optimized with focus areas):
Sub-Agent Selection (saves 75% by running only what's needed):
# Default: Run all agents on changed files only
# With flags: Run specific agents only
if [ "$FOCUS_SECURITY" = true ] || [ "$FULL_REVIEW" = true ]; then
# Security sub-agent: Credential exposure, input validation, vulnerabilities
echo "Running security analysis..."
fi
if [ "$FOCUS_PERFORMANCE" = true ] || [ "$FULL_REVIEW" = true ]; then
# Performance sub-agent: Bottlenecks, memory issues, optimization
echo "Running performance analysis..."
fi
if [ "$FOCUS_QUALITY" = true ] || [ "$FULL_REVIEW" = true ]; then
# Quality sub-agent: Code complexity, maintainability, best practices
echo "Running quality analysis..."
fi
if [ "$FOCUS_ARCHITECTURE" = true ] || [ "$FULL_REVIEW" = true ]; then
# Architecture sub-agent: Layer separation, dependency direction, patterns
echo "Running architecture analysis..."
Optimization: Grep-Before-Read Pattern (saves 85% in sub-agents)
Each sub-agent will use Grep to identify problematic patterns before reading full files:
# Security Agent: Grep for security patterns first (100 tokens vs 5,000+)
SECURITY_ISSUES=$(Grep pattern="password|secret|api[_-]?key|token" files="$FILES_TO_REVIEW" head_limit=20)
# Performance Agent: Grep for performance anti-patterns
PERF_ISSUES=$(Grep pattern="for.*for|O\(n\^2\)|sleep|setTimeout.*loop" files="$FILES_TO_REVIEW" head_limit=20)
# Only read files that matched patterns (saves 85% tokens)
I'll examine files using optimized Grep-then-Read analysis:
When I find multiple issues, I'll create a todo list to address them systematically.
For each issue, I'll use progressive disclosure (saves 60% tokens):
Critical Issues (show full details):
High Priority (summarize):
Medium/Low Priority (count only):
Save Review Results to Cache (70% savings on re-reviews)
# Cache review results with file checksums
mkdir -p .claude/cache/review
cat > .claude/cache/review/last-review.json <<EOF
{
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"files": {
$(echo "$FILES_TO_REVIEW" | while read file; do
CHECKSUM=$(md5sum "$file" 2>/dev/null | cut -d' ' -f1)
echo "\"$file\": {\"checksum\": \"$CHECKSUM\"}"
done | paste -sd,)
},
"issues": {
"critical": 0,
"high": 0,
"medium": 0,
"low": 0
}
}
EOF
After review, I'll ask: "Create GitHub issues for critical findings?"
Important: I will NEVER:
This focuses on real problems that impact your application's reliability and maintainability.
This skill implements aggressive token optimization achieving 60-80% token reduction compared to naive implementation:
Token Budget:
1. Git Diff Scope Limiting (saves 90%)
# Default: Review only changed files
FILES_TO_REVIEW=$(git diff --name-only HEAD)
if [ -z "$FILES_TO_REVIEW" ]; then
echo "✓ No changed files to review"
exit 0 # Exit early, saves ~18,000 tokens
fi
# Count files (set reasonable limit)
FILE_COUNT=$(echo "$FILES_TO_REVIEW" | wc -l)
if [ $FILE_COUNT -gt 50 ]; then
echo "⚠️ $FILE_COUNT files changed (showing first 50)"
FILES_TO_REVIEW=$(echo "$FILES_TO_REVIEW" | head -50)
fi
# vs. Full codebase scan: find . -name "*.ts" -o -name "*.js"
# Savings: 100 tokens vs 10,000+ tokens
2. Focus Area Flags (saves 75%)
# Run only requested analysis agents
if [ "$FOCUS_SECURITY" = true ]; then
# Run security agent only (2,500 tokens)
# Skip performance, quality, architecture agents
elif [ "$FOCUS_PERFORMANCE" = true ]; then
# Run performance agent only (2,500 tokens)
elif [ -z "$FOCUS_*" ]; then
# Run all agents (8,000 tokens total)
fi
# Savings: 75% when using focus flags
3. Grep-Before-Read in Sub-Agents (saves 85%)
# Security Agent Example
# Instead of reading all files, grep for patterns first
# Grep for security issues (200 tokens)
SECURITY_PATTERNS=$(grep -rn "password\|secret\|api_key\|token" $FILES_TO_REVIEW | head -20)
if [ -z "$SECURITY_PATTERNS" ]; then
echo "✓ No security issues detected"
exit 0 # Skip file reads, saves 4,500 tokens
fi
# Only read files with matches (500 tokens vs 5,000+)
FILES_WITH_ISSUES=$(echo "$SECURITY_PATTERNS" | cut -d: -f1 | sort -u)
# Read only these files for context
# Total: 700 tokens vs 5,000+ tokens
4. Review Result Caching (saves 70% on re-reviews)
CACHE_FILE=".claude/cache/review/last-review.json"
# Compare file checksums
for file in $FILES_TO_REVIEW; do
CURRENT=$(md5sum "$file" | cut -d' ' -f1)
CACHED=$(jq -r ".files.\"$file\".checksum" "$CACHE_FILE")
if [ "$CURRENT" = "$CACHED" ]; then
# File unchanged, use cached results
continue # Skip analysis, saves 500 tokens per file
fi
done
# Only analyze changed files since last review
Cache Contents:
Cache Invalidation:
--no-cache flag--full review5. Progressive Disclosure (saves 60-85%)
# Level 1: Critical issues only (default) - 2,000 tokens
echo "Found 2 critical issues:"
echo " - SQL injection in UserController.ts:45"
echo " - Hardcoded API key in config.ts:12"
# Level 2: Critical + High (--verbose flag) - 4,000 tokens
echo "Also found 5 high-priority issues:"
echo " - Memory leak in EventEmitter..."
# Level 3: All issues (--verbose --all flags) - 8,000 tokens
echo "Also found 12 medium and 8 low priority issues..."
# Most users only need Level 1 (saves 60-85%)
6. Multi-Agent Parallel Execution (no serial overhead)
# Run sub-agents in parallel (when all needed)
{
security_agent &
performance_agent &
quality_agent &
architecture_agent &
}
wait
# Collect results from each agent
# No serial token overhead (each agent is optimized independently)
| Operation | Before | After | Savings | Method |
|---|---|---|---|---|
| File discovery | 5,000 | 100 | 98% | Git diff vs full scan |
| Security analysis | 4,500 | 700 | 84% | Grep-before-Read |
| Performance analysis | 4,000 | 600 | 85% | Pattern detection |
| Quality analysis | 3,500 | 500 | 86% | Complexity grep |
| Architecture analysis | 3,000 | 400 | 87% | Dependency grep |
| Result formatting | 500 | 200 | 60% | Progressive disclosure |
| Total (All Agents) | 20,500 | 2,500 | 88% | Combined optimizations |
| Total (Single Focus) | 10,000 | 1,500 | 85% | Focus flag + optimizations |
First Run (No Cache, Changed Files):
Subsequent Runs (Cache Hit, No Changes):
Focus Area Review:
Full Codebase Review (--full flag):
Large Projects (500+ files):
.claude/cache/review/
├── last-review.json # Review results with checksums
│ ├── timestamp
│ ├── files # {file: {checksum, issues}}
│ ├── issues # {critical, high, medium, low}
│ └── agent_results # Per-agent findings
├── security-patterns.json # Security patterns cache (7d TTL)
├── performance-baselines.json # Performance baselines (30d TTL)
└── quality-metrics.json # Code quality trends (30d TTL)
Efficient patterns:
# Review changed files only (default)
/review # 2,000-4,000 tokens
# Security-focused review
/review --security # 1,500-2,500 tokens
# Performance-focused review
/review --performance # 1,500-2,500 tokens
# Multiple focus areas
/review --security --performance # 3,000-5,000 tokens
# Full codebase review
/review --full # 8,000-15,000 tokens
# Verbose output (all issues)
/review --verbose --all # +2,000 tokens
# Bypass cache
/review --no-cache # Force fresh analysis
Flags:
--security: Security analysis only--performance: Performance analysis only--quality: Code quality analysis only--architecture: Architecture analysis only--full: Review entire codebase--verbose: Show high-priority issues--all: Show all issues (including low priority)--no-cache: Bypass result cacheSecurity Agent (85% reduction):
# Grep patterns (200 tokens)
grep -rn "password\|secret\|apikey\|token" --include="*.ts" | head -20
# Only read matched files (500 tokens vs 4,500)
# Total: 700 tokens vs 4,500 tokens
Performance Agent (85% reduction):
# Grep for anti-patterns (150 tokens)
grep -rn "for.*for\|O(n\^2)\|sleep.*loop" --include="*.ts" | head -20
# Grep for large iterations (100 tokens)
grep -rn "while.*true\|forEach.*forEach" --include="*.ts" | head -20
# Total: 600 tokens vs 4,000 tokens
Quality Agent (86% reduction):
# Use complexity tools via bash (200 tokens)
npx eslint $FILES_TO_REVIEW --format json | jq '.[] | select(.errorCount > 0)'
# Total: 500 tokens vs 3,500 tokens
Architecture Agent (87% reduction):
# Grep for dependency violations (150 tokens)
grep -rn "import.*from.*\.\./" --include="*.ts" | head -20
# Analyze layer violations (150 tokens)
grep -rn "ui.*import.*database\|controller.*import.*ui" | head -20
# Total: 400 tokens vs 3,000 tokens
Optimized review workflow:
/review # Multi-agent analysis (2,500 tokens)
# If critical issues:
/security-scan # Detailed security scan (1,500 tokens)
/create-todos # Track issues (400 tokens)
/fix-todos # Fix issues (variable)
/review --security # Verify fixes (1,500 tokens)
/commit # Commit fixes (400 tokens)
# Total: ~6,800 tokens (vs ~35,000 unoptimized)
Cache shared with:
/security-scan - Security patterns and vulnerabilities/predict-issues - Issue patterns and history/code-review-checklist - Review criteria and resultsBenefit: Reviewing with /review caches patterns for other skills (70% savings)
Tested on:
Success criteria: