AgentSkillsCN

verification-loop

针对代码变更设立六阶段质量门控机制。依次执行构建、类型检查、代码风格检查、测试、安全扫描与差异对比审核。支持 JavaScript/TypeScript、Python 与 Rust,并具备自动检测与跳过条件。

SKILL.md
--- frontmatter
name: verification-loop
description: Six-phase quality gate for code changes. Runs build, typecheck, lint, test, security, and diff-review in sequence. Supports JavaScript/TypeScript, Python, and Rust with auto-detection and skip conditions.
version: 1.0.0
category: development
last_updated: 2026-01-24
phases:
  - build
  - typecheck
  - lint
  - test
  - security
  - diff-review
supported_languages:
  - javascript
  - typescript
  - python
  - rust
related_skills:
  - testing-production
  - code-reviewer
  - systematic-debugging

Verification Loop Skill

Overview

Six-phase quality gate validating code changes sequentially. Each phase must pass before proceeding. Auto-detects project type and adapts commands.

When to Use

  • Before committing changes
  • Pre-merge validation
  • CI/CD pipeline integration
  • Code review preparation

Phase Definitions

Phase 1: Build

ProjectCommandSkip If
Node.jsnpm run buildNo build script in package.json
Pythonuv build / python -m buildNo pyproject.toml or setup.py
Rustcargo build --releaseNo Cargo.toml

Phase 2: Typecheck

ProjectCommandSkip If
TypeScripttsc --noEmitNo tsconfig.json
Pythonpyright / mypy .No type checker installed
Rust(included in build)Always (cargo handles types)

Phase 3: Lint

ProjectCommandSkip If
JS/TSeslint . --ext .js,.jsx,.ts,.tsxNo eslint config
Pythonruff check . / flake8 .No linter config
Rustcargo clippy -- -D warningsNo Cargo.toml

Phase 4: Test

ProjectCommandSkip If
JS/TSnpm test / npm run test:coverageNo test script
Pythonpytest --covNo tests directory
Rustcargo testNo tests

Phase 5: Security

ProjectCommandSkip If
JS/TSnpm auditNo package-lock.json
Pythonsafety check / pip-audit / bandit -r .No scanner installed
Rustcargo auditcargo-audit not installed

Phase 6: Diff Review

Command: git diff HEAD~1 --stat

Provides summary of changes for review context. Always informational, never fails.

Detection Logic

bash
# Project type detection
detect_project() {
  [ -f "package.json" ] && echo "node"
  [ -f "pyproject.toml" ] || [ -f "setup.py" ] && echo "python"
  [ -f "Cargo.toml" ] && echo "rust"
}

# Skip conditions per phase
should_skip_typecheck() {
  [ ! -f "tsconfig.json" ] && [ ! -f "pyproject.toml" ]
}

should_skip_lint() {
  [ ! -f ".eslintrc.js" ] && [ ! -f ".eslintrc.json" ] && \
  [ ! -f "ruff.toml" ] && [ ! -f "Cargo.toml" ]
}

should_skip_test() {
  [ ! -d "tests" ] && [ ! -d "test" ] && \
  ! find . -name "*_test.py" -o -name "test_*.py" | grep -q .
}

Execution Flow

code
START -> BUILD -> TYPECHECK -> LINT -> TEST -> SECURITY -> DIFF-REVIEW -> SUCCESS
              \         \         \       \          \
               -> SKIP   -> SKIP   -> SKIP -> SKIP   -> SKIP (if conditions met)

Any phase FAIL -> STOP with error report

Configuration

Environment Variables

bash
VERIFICATION_SKIP_PHASES="security,diff-review"  # Skip specific phases
VERIFICATION_COVERAGE_MIN=80                      # Coverage threshold
VERIFICATION_STRICT=true                          # Fail on warnings

Config File (.verification-loop.yml)

yaml
phases:
  build:
    enabled: true
    timeout: 300
  typecheck:
    enabled: true
    timeout: 120
  lint:
    enabled: true
    allow_warnings: false
  test:
    enabled: true
    coverage_threshold: 80
  security:
    enabled: true
    severity_threshold: moderate
  diff-review:
    enabled: true
    compare_ref: HEAD~1

skip_conditions:
  - pattern: "*.md"
    skip_phases: [build, typecheck, lint, test]

Error Handling

PhaseOn Failure
BuildStop, report compilation errors
TypecheckStop, report type errors
LintStop, report lint violations
TestStop, report failed tests
SecurityReport vulns, continue if below threshold
Diff-ReviewAlways succeeds (informational)

Integration

CI (GitHub Actions): Use fetch-depth: 2 for diff-review, run each phase in sequence.

Pre-Commit Hook:

bash
#!/bin/bash
./verification-loop.sh --skip=security,diff-review
[ $? -ne 0 ] && exit 1

Metrics

MetricTarget
Pass Rate>95%
Duration<60s
Test Coverage>80%

Version 1.0.0 (2026-01-24): Initial release