AI-Agent-Toolkit qa-gate

Skill: QA-Gate

install
source · Clone the upstream repo
git clone https://github.com/ngapngap/AI-Agent-Toolkit
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ngapngap/AI-Agent-Toolkit "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.agent/skills/qa-gate" ~/.claude/skills/ngapngap-ai-agent-toolkit-qa-gate && rm -rf "$T"
manifest: .agent/skills/qa-gate/SKILL.md
source content

Skill: QA-Gate

Mô tả

Skill này đóng vai trò Verifier trong pipeline - chạy tất cả các checks để đảm bảo code quality trước khi merge hoặc bàn giao. QA-Gate CHỈ VERIFY, không sửa feature (để tránh bias).

Khi nào sử dụng

  • Trước khi merge code từ lanes
  • Trước khi bàn giao cho user
  • Sau mỗi implementation phase
  • Khi cần audit code quality

Các Checks thực hiện

1. Test Suite

  • Run unit tests
  • Run integration tests
  • Run E2E tests (nếu có)
  • Capture coverage report

2. Linter

  • ESLint / Biome
  • Prettier check
  • Stylelint (nếu có CSS)

3. Type Check

  • TypeScript compiler (
    tsc --noEmit
    )
  • Strict mode violations

4. Build

  • Production build
  • Check for build errors
  • Bundle size analysis

5. Security (Optional)

  • npm audit
  • Dependency vulnerabilities
  • Secret scanning

Output Format

File:
output/verification/report.json

{
  "timestamp": "2024-01-22T12:00:00Z",
  "project": {
    "name": "project-name",
    "path": "/path/to/project"
  },
  "overall_status": "pass|fail|warning",
  "summary": {
    "total_checks": 5,
    "passed": 4,
    "failed": 1,
    "warnings": 2
  },
  "checks": {
    "tests": {
      "status": "pass|fail|skip",
      "runner": "vitest|jest|mocha",
      "total": 100,
      "passed": 98,
      "failed": 2,
      "skipped": 0,
      "coverage": {
        "lines": 85.5,
        "branches": 72.3,
        "functions": 90.0,
        "statements": 85.5
      },
      "duration_ms": 5000,
      "failed_tests": [
        {
          "name": "test name",
          "file": "src/test.ts",
          "error": "Expected X but got Y"
        }
      ]
    },
    "lint": {
      "status": "pass|fail|warning",
      "tool": "eslint|biome",
      "errors": 0,
      "warnings": 5,
      "fixable": 3,
      "issues": [
        {
          "file": "src/file.ts",
          "line": 10,
          "rule": "no-unused-vars",
          "severity": "warning",
          "message": "'x' is defined but never used"
        }
      ]
    },
    "typecheck": {
      "status": "pass|fail",
      "errors": 0,
      "issues": []
    },
    "build": {
      "status": "pass|fail",
      "tool": "vite|webpack|next",
      "duration_ms": 10000,
      "output_size_kb": 250,
      "errors": []
    },
    "security": {
      "status": "pass|warning",
      "vulnerabilities": {
        "critical": 0,
        "high": 0,
        "moderate": 2,
        "low": 5
      }
    }
  },
  "blocking_issues": [
    {
      "check": "tests",
      "severity": "error",
      "message": "2 tests failed",
      "action": "Fix failing tests before merge"
    }
  ],
  "recommendations": [
    "Consider increasing test coverage (currently 85%)",
    "5 ESLint warnings could be auto-fixed"
  ],
  "artifacts": {
    "coverage_report": "output/verification/coverage/index.html",
    "build_output": "dist/"
  }
}

File:
output/verification/tests.md

# QA Verification Report

## Summary

| Check | Status | Details |
|-------|--------|---------|
| Tests | PASS | 98/100 passed |
| Lint | WARN | 5 warnings |
| TypeCheck | PASS | No errors |
| Build | PASS | 250kb bundle |
| Security | PASS | No critical |

**Overall Status**: PASS

---

## Test Results

### Passed Tests (98)
<details>
<summary>Click to expand</summary>

- src/utils.test.ts: 10 tests
- src/api.test.ts: 15 tests
...

</details>

### Failed Tests (2)

#### 1. `should handle edge case` (src/edge.test.ts:45)

Expected: 10 Received: undefined


#### 2. `should validate input` (src/validate.test.ts:23)

TypeError: Cannot read property 'x' of null


---

## Lint Issues

| Severity | Count | Fixable |
|----------|-------|---------|
| Error | 0 | - |
| Warning | 5 | 3 |

### Warnings
1. `src/file.ts:10` - 'x' is defined but never used (no-unused-vars)
2. ...

---

## Build Output

- **Bundle Size**: 250kb
- **Build Time**: 10s
- **Chunks**: 5

---

## Recommendations

1. Fix 2 failing tests before merge
2. Run `npm run lint:fix` to auto-fix 3 warnings
3. Consider code splitting for large bundles

---

*Generated by QA-Gate Skill | 2024-01-22*

Workflow

┌─────────────────┐
│   Lane Output   │
│  (code changes) │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│   QA-Gate       │
│                 │
│ 1. Run Tests    │
│ 2. Run Lint     │
│ 3. TypeCheck    │
│ 4. Build        │
│ 5. Security     │
└────────┬────────┘
         │
         ▼
┌─────────────────┐
│  Generate Report│
│                 │
│ - report.json   │
│ - tests.md      │
└────────┬────────┘
         │
    ┌────┴────┐
    │         │
    ▼         ▼
  PASS      FAIL
    │         │
    ▼         ▼
  MERGE    FIX ISSUES

Gate Policies

Strict Mode (Production)

{
  "tests": { "min_pass_rate": 100 },
  "lint": { "max_errors": 0 },
  "typecheck": { "must_pass": true },
  "build": { "must_pass": true },
  "security": { "max_critical": 0, "max_high": 0 }
}

Standard Mode (Development)

{
  "tests": { "min_pass_rate": 90 },
  "lint": { "max_errors": 5 },
  "typecheck": { "must_pass": true },
  "build": { "must_pass": true },
  "security": { "max_critical": 0 }
}

Lenient Mode (Prototype)

{
  "tests": { "min_pass_rate": 0 },
  "lint": { "max_errors": 50 },
  "typecheck": { "must_pass": false },
  "build": { "must_pass": true },
  "security": { "skip": true }
}

Lệnh thực thi

# Run full QA gate
node ".agent/skills/qa-gate/scripts/run-gate.js"

# Run specific checks
node ".agent/skills/qa-gate/scripts/run-gate.js" --checks tests,lint

# Run with policy
node ".agent/skills/qa-gate/scripts/run-gate.js" --policy strict

# View last report
node ".agent/skills/qa-gate/scripts/view-report.js"

# Compare with previous run
node ".agent/skills/qa-gate/scripts/compare-reports.js"

Auto-Detection

QA-Gate tự động detect:

  • Test runner: vitest, jest, mocha, playwright
  • Linter: eslint, biome, prettier
  • Build tool: vite, webpack, next, turbo
  • Package manager: npm, yarn, pnpm, bun

Quy tắc cho Verifier Agent

DO

  • Chỉ verify, KHÔNG sửa code
  • Report đầy đủ lỗi với context
  • Đề xuất cách fix (nhưng không tự fix)
  • Capture logs và artifacts

DON'T

  • Đừng bỏ qua failing tests
  • Đừng sửa feature (bias risk)
  • Đừng approve nếu có blocking issues
  • Đừng chạy destructive commands

Integration với Pipeline

Input

  • Code từ lanes (UI, API, Data, QA lanes)
  • Specs để verify acceptance criteria

Output

  • report.json cho Manager Agent
  • tests.md cho documentation
  • Pass/Fail signal cho Integration Gate

Trigger Points

  1. Sau mỗi lane hoàn thành task
  2. Trước khi merge vào main
  3. Scheduled (nightly builds)
  4. Manual trigger

Environment Variables

# Coverage threshold
QA_COVERAGE_MIN=80

# Timeout for tests (ms)
QA_TEST_TIMEOUT=60000

# Policy (strict|standard|lenient)
QA_POLICY=standard

# Skip checks (comma-separated)
QA_SKIP_CHECKS=security

# Output directory
QA_OUTPUT_DIR=output/verification

Tham khảo