staged-changes-review
npx skills add https://github.com/adonis0123/adonis-skills --skill staged-changes-review
Agent 安装分布
Skill 文档
Staged Changes Review
Checklist-driven, deterministic review of Git staged changes. Produces reproducible findings by combining grep-based scanning with closed-question semantic analysis.
è¾åºè¦æ±
éè¦ï¼æ¬æè½å¿ 须使ç¨ä¸æè¾åºææåæç»æå建议ã
- è¯è¨: å§ç»ä½¿ç¨ä¸æåå¤
- ç¼ç : UTF-8
- 飿 ¼: ä¸ä¸ãç®æ´ï¼åç°å¿ é¡»é带代ç è¯æ®
Workflow (8 Steps)
Execute steps in strict order: 0 â 0.5 â 1 â 2 â 2.5 â 3 â 4 â 5. Do not skip or reorder any step.
Step 0: Collect Changes
git diff --cached
git diff --cached --stat
git diff --cached --name-status
If no staged changes exist, output “æ æååæ´ï¼å®¡æ¥ç»æ¢ã” and stop.
Step 0.5: Detect Project Profile
Detect the project type once to determine which rule categories to activate.
# Detect framework
python3 -c "
import json, sys
try:
with open('package.json') as f:
d = json.load(f)
deps = {**d.get('dependencies', {}), **d.get('devDependencies', {})}
if 'next' in deps:
print('react-nextjs')
elif 'react' in deps:
print('react-app')
else:
print('generic')
except:
print('generic')
" 2>/dev/null || echo "generic"
# Count staged file types
git diff --cached --name-only | grep -cE '\.(tsx|jsx)$' || echo 0
git diff --cached --name-only | grep -cE '\.py$' || echo 0
Record the detected profile â it determines active rule categories:
| Profile | Condition | Active Rule Categories |
|---|---|---|
| react-nextjs | next in dependencies |
SEC + REACT + PERF + ASYNC + STR + LOGIC/BREAK + BIZ + REPO |
| react-app | react but no next |
SEC + REACT + ASYNC + STR + LOGIC/BREAK + BIZ + REPO (001-007) |
| python-generic | Python files majority, no package.json | SEC + STR + LOGIC/BREAK + BIZ + REPO (001-006) |
| generic | No package.json or detection failed | SEC + STR + LOGIC/BREAK + BIZ + REPO (001-006) |
REACT-* and PERF-* rules are skipped entirely for python-generic or generic profiles. REPO-007 requires react-nextjs or react-app; REPO-008 requires react-nextjs only. If detection fails, default to generic.
Step 1: Classify Files
Classify every staged file into priority tiers using the rules in references/review-rules.md §1.
- Assign each file exactly one priority (P0âP4).
- Skip P4 files entirely â do not read or scan them.
- Sort remaining files by priority (P0 first, P3 last).
- Record the file list for the report’s “审æ¥èå´” section.
Step 2: Deterministic Scan
For each file (P0 â P3 order), execute every applicable deterministic rule from references/review-rules.md §2.
Execution method:
- Use grep patterns from
references/language-patterns.mdmatching the file’s language. - Run each grep against the staged diff (
git diff --cached -- <file>) or the file itself. - If a pattern matches, record a finding immediately â no subjective filtering.
- Use the severity from
references/review-rules.md§4 â do NOT modify severity.
MANDATORY: Every rule à file combination must be executed or explicitly marked N/A (wrong file type or inactive profile). Do not skip rules because “they seem unlikely.”
Step 2.5: Impact Scope Analysis
For P0/P1 files, run a one-time impact scope assessment and record results for the “å½±åèå´” section.
# 1. New/modified exported symbols in staged diff
git diff --cached -U0 -- "*.ts" "*.tsx" | grep -E "^\+export (function|const|class|interface|type)"
# 2. API route changes
git diff --cached --name-only | grep -E "app/api/|pages/api/"
# 3. Server Action changes (security impact)
git diff --cached -- "*.ts" "*.tsx" | grep -E '^[+-].*("use server"|'"'"'use server'"'"')'
# 4. Environment variable changes
git diff --cached -- ".env*" 2>/dev/null | grep -E "^[+-][A-Z_]+" | head -10
For each exported symbol found (up to 5 symbols), check reference count:
# Replace SYMBOL_NAME with actual symbol
grep -rl "SYMBOL_NAME" --include="*.ts" --include="*.tsx" src/ 2>/dev/null | wc -l
If no impact scope items are detected, note “æ æ¾èå½±åèå´åæ´” in the report.
Step 3: Semantic Review
For each file (P0 â P3 order), answer every applicable semantic question from references/review-rules.md §3 and §3b.
Execution method:
- Read the file’s staged diff and surrounding context (use
Readtool for full file when needed). - For each semantic rule, answer the closed question with exactly one of:
- YES â issue found. MUST provide: file:line + evidence snippet.
- NO â reviewed, no issue found.
- N/A â rule does not apply to this file type or change.
- Only YES answers produce findings. Use the severity from §4.
BIZ è§åæ§è¡è¯´æ:
- 对 P1 æä»¶ï¼ä½¿ç¨
git show HEAD:<path>è·ååæ´åçæ¬ï¼ä¸æåçæ¬å¯¹æ¯è¿è¡ before/after è¡ä¸ºåæã - BIZ findings å¿ é¡»å 嫔忴åè¡ä¸º”ã”åæ´åè¡ä¸º”å”å½±ååºæ¯”åæ®µã
- 纯éæï¼é»è¾ç价忢ï¼ä¸åºæ¥ä¸ºè¡ä¸ºåæ´ã
- éæ ·éå¶: P1 æä»¶è¶ è¿ 10 个æ¶ï¼BIZ è§åä» åæå 5 个æä»¶ï¼å¹¶æ³¨æ”å©ä½ N 个æä»¶æªè¿è¡ BIZ åæï¼éæ ·éå¶ï¼”ã
MANDATORY: Answer every question. Do not skip questions because context seems insufficient â answer N/A with a brief reason instead.
Step 4: Merge & Deduplicate
- Collect all findings from Steps 2 and 3.
- Generate a fingerprint for each finding:
{ruleId}:{file}:{line}. - Deduplicate by fingerprint â if the same fingerprint appears from both a deterministic and semantic rule, keep the one with higher severity.
- Group findings by severity: CRITICAL â HIGH â MEDIUM â LOW.
- Apply output budget limits from
references/report-template.md§3.
Step 5: Generate Report
Output the report using the exact structure from references/report-template.md §2.
- 审æ¥èå´: file counts and rule counts.
- å½±åèå´: impact scope analysis results.
- ä¸å¡å½±ååæ: BIZ findings çæè¦è¡¨æ ¼ï¼åæ´æä»¶ / BIZ è§å / è¡ä¸ºåæ´æè¦ï¼ãè¥æ BIZ åç°ï¼è¾åº”æªæ£æµå°ç¨æ·å¯æç¥çä¸å¡è¡ä¸ºåæ´”ã
- åç°æ»è§: severity summary table.
- ç»è®º: auto-select from
references/review-rules.md§5 based on highest severity found. - å级åç°: findings in
references/report-template.md§1 format, grouped by severity. BIZ findings æ severity å½å ¥å¯¹åºçº§å«ã - æä»¶å®¡æ¥ç©éµ: per-file summary table.
Execution Constraints (MANDATORY)
These constraints are non-negotiable. Violating any constraint invalidates the review.
- No skipping: Every rule must be evaluated against every applicable file. Document N/A explicitly.
- No free-form analysis: Only report findings that match a defined rule ID. Do not invent new categories.
- Forced answers: Every semantic question must receive YES, NO, or N/A. Leaving a question unanswered is forbidden.
- Evidence lock: Every YES finding must cite a specific file:line and include a code snippet. Findings without evidence are invalid.
- Severity is immutable: Use the severity from the mapping table. Do not upgrade or downgrade based on subjective judgment.
- Conclusion is templated: The conclusion must be one of the four templates in review-rules.md §5. Do not write a custom conclusion.
- Fingerprint required: Every finding must include a fingerprint in
{ruleId}:{file}:{line}format.
Context Budget Strategy
When staged changes are large (>500 lines or >15 files):
- P0 files: Always read full content â security-critical.
- P1 files: Read full diff. If a single file diff >200 lines, focus on: function signatures, exported symbols, error handling blocks, and security-sensitive patterns.
- P2 files: Read diff only. Focus on SEC rules and BREAK-003/BREAK-004.
- P3 files: Scan diff headers only. Apply STR rules only.
- If total context would exceed capacity, process files strictly by priority and stop at capacity with a note: “å©ä½ N 个ä½ä¼å 级æä»¶æªå®¡æ¥”.
REACT/ASYNC rule sampling limit: For rules that require Read tool for semantic verification (REACT-001, REACT-003, ASYNC-001, ASYNC-002), if grep returns more than 5 matches, take the first 5 matches only and note “N 夿ªéªè¯ï¼éæ ·éå¶ï¼”. This prevents excessive Read tool calls.
Validator Interface Contract
This skill’s output is consumed by staged-review-validator. The following fields are required for compatibility:
- Finding title must include
[ruleId]prefix (e.g.,[SEC-003] SQL æ¼æ¥é£é©) - Each finding must include a
æçº¹(Fingerprint) field - Severity uses 4 levels: CRITICAL / HIGH / MEDIUM / LOW
- Report structure follows
references/report-template.md§2 BIZ-*findings ä½¿ç¨ before/after æ ¼å¼ï¼å«”åæ´åè¡ä¸º”ã”åæ´åè¡ä¸º”ã”å½±ååºæ¯”åæ®µï¼ï¼è¯¦è§references/report-template.md§1
References
references/review-rules.mdâ Rule definitions, file classification, severity mappingreferences/report-template.mdâ Finding format, report structure, output budgetreferences/language-patterns.mdâ Language-specific grep patterns by rule ID