AgentSkillsCN

build-validator

在推送前验证构建、测试与 lint,确保质量门通过。

SKILL.md
--- frontmatter
name: build-validator
description: Validates build, tests, and lint before push to ensure quality gates pass.
context: fork
user-invocable: false

Build Validator

Agent สำหรับตรวจสอบ build, tests, และ lint ก่อน push

Purpose

  • รัน tests และตรวจสอบผลลัพธ์
  • รัน build และตรวจสอบ success
  • รัน linter และตรวจสอบ errors
  • รวบรวมผลลัพธ์เป็น report
  • Block push ถ้าไม่ผ่าน

Instructions

Step 1: Detect Project Type

bash
[ -f "Makefile" ] && echo "Makefile detected"
[ -f "package.json" ] && echo "Node.js project"
[ -f "go.mod" ] && echo "Go project"
[ -f "Cargo.toml" ] && echo "Rust project"
[ -f "pyproject.toml" ] && echo "Python project"

Step 2: Run Tests

Project TypeCommand
Makefilemake test
Node.jsnpm test / bun test / yarn test
Gogo test ./...
Pythonpytest
Rustcargo test

Step 3: Run Build

Project TypeCommand
Makefilemake build
Node.jsnpm run build
Gogo build ./...
Rustcargo build

Step 4: Run Linter

Project TypeCommand
Node.js/TSnpm run lint / eslint .
Gogolangci-lint run / go vet ./...
Pythonruff check . / flake8
Rustcargo clippy

Step 5: Run Type Check (if applicable)

Project TypeCommand
TypeScriptnpm run typecheck / tsc --noEmit
Pythonmypy .

Step 6: Analyze Results

CheckPass Criteria
TestsExit code 0, no failures
BuildExit code 0, artifacts created
LintNo errors (warnings OK)
TypesNo type errors

Output Format

markdown
## Build Validation Report

**Project:** [project-name]
**Date:** YYYY-MM-DD HH:MM:SS
**Branch:** [branch-name]

### Overall Status: PASS / FAIL

---

### Test Results
| Status | Details |
|--------|---------|
| PASS/FAIL | X tests passed, Y failed |

### Build Results
| Status | Details |
|--------|---------|
| PASS/FAIL | Build details |

### Lint Results
| Status | Details |
|--------|---------|
| PASS/FAIL/WARN | Error/warning counts |

### Type Check Results
| Status | Details |
|--------|---------|
| PASS/FAIL | Type error counts |

---

### Summary

| Check | Status | Time |
|-------|--------|------|
| Tests | pass/fail | Xs |
| Build | pass/fail | Xs |
| Lint | pass/fail | Xs |
| Types | pass/fail | Xs |

**Recommendation:** Ready to Push / Do Not Push

Error Recovery

FailureRecovery
Missing depsnpm install / go mod tidy
Stale cacheClean and rebuild
Type errorsFix types first
Lint errorsRun formatter