Loading...
Loading...
Quality verification before commits and deployments. Use for quality checks, running tests, checking coverage, validating changes.
npx skill4agent add usorama/rad-engineer-v2 quality-gatebunpnpmnpmnpxpnpm run Xbun run X--smol# ❌ NEVER USE THESE
pnpm run typecheck # Spawns extra node process
npm run test # Spawns extra node process
npx tsc # Spawns node
# ✅ ALWAYS USE THESE
bun run typecheck # Direct bun execution
bun test # Native bun test runner (17x faster)
bun run lint # Single processLOCK_FILE="/tmp/rad-engineer-quality-gate.lock"# Quick inline resource check (embedded in skill)
check_resources() {
local load kernel_cpu
load=$(sysctl -n vm.loadavg | awk '{print $2}')
kernel_cpu=$(ps -Ao %cpu,comm | grep kernel_task | head -1 | awk '{print $1}')
kernel_cpu=${kernel_cpu:-0}
if (( $(echo "$load > 8.0" | bc -l) )); then
echo "BLOCKED: Load too high ($load). Wait 30 seconds."
return 1
fi
if (( $(echo "$kernel_cpu > 40" | bc -l) )); then
echo "BLOCKED: kernel_task too high (${kernel_cpu}%). Wait 30 seconds."
return 1
fi
return 0
}
# Use before quality gates
check_resources || { sleep 30; check_resources; } || exit 1.claude/hooks/check-system-resources.shLOCK="/tmp/rad-engineer-quality-gate.lock"
cd rad-engineer
# Check resources first
.claude/hooks/check-system-resources.sh || { sleep 30; .claude/hooks/check-system-resources.sh; } || exit 1
# TypeScript check - MUST pass with 0 errors (SERIALIZED)
flock -w 300 "$LOCK" bun run typecheck
# Lint check - MUST pass (SERIALIZED)
flock -w 300 "$LOCK" bun run lintLOCK="/tmp/rad-engineer-quality-gate.lock"
cd rad-engineer
# Check resources first
.claude/hooks/check-system-resources.sh || { sleep 30; .claude/hooks/check-system-resources.sh; } || exit 1
# Run all tests (SERIALIZED) - uses --smol from bunfig.toml
flock -w 300 "$LOCK" bun test
# Coverage (run separately when needed - NOT by default)
# flock -w 300 "$LOCK" bun test --coverageLOCK="/tmp/rad-engineer-quality-gate.lock"
cd rad-engineer
# Verify build succeeds (SERIALIZED)
flock -w 300 "$LOCK" bun run buildcd rad-engineer && \
LOCK="/tmp/rad-engineer-quality-gate.lock" && \
( ../.claude/hooks/check-system-resources.sh || { sleep 30; ../.claude/hooks/check-system-resources.sh; } ) && \
flock -w 300 "$LOCK" sh -c 'bun run typecheck && bun run lint && bun test'[test]
smol = true # Reduces memory from 343MB to 54MB
coverage = false # Disabled by default (run explicitly when needed)
timeout = 300000 # 5 min timeout for integration tests
coverageSkipTestFiles = true✓ TypeScript: 0 errors
✓ Lint: Clean
✓ Tests: XX passed
✓ Coverage: XX% (if explicitly run)
✓ Build: Success
━━━━━━━━━━━━━━━━━━━━━━
Ready to commit!✗ TypeScript: X errors
- src/file.ts:42 - Error message
✗ Tests: X failed
- test/file.test.ts - Test name
Expected: X
Received: Y
━━━━━━━━━━━━━━━━━━━━━━
BLOCKED: Fix issues before commit| Metric | Minimum | Target |
|---|---|---|
| TypeScript Errors | 0 | 0 |
| Lint Errors | 0 | 0 |
| Test Pass Rate | 100% | 100% |
| Coverage | 80% | 90% |
| Build | Pass | Pass |
| Command | Processes Spawned | Memory |
|---|---|---|
| pnpm + tsc = 2 | ~200MB |
| bun only = 1 | ~54MB |
| pnpm + bun = 2 | ~400MB |
| bun only = 1 | ~54MB |
| Approach | Total Processes | Total Memory |
|---|---|---|
| pnpm (old) | 3 × 6 = 18 | ~1.8GB |
| bun (new) | 3 × 3 = 9 | ~162MB |
Agent 1: bun run typecheck → runs immediately
Agent 2: bun run typecheck → runs in PARALLEL!
Agent 3: bun run lint → runs in PARALLEL!
Result: 3+ heavy processes, potential overloadAgent 1: flock ... bun run typecheck → runs, holds lock
Agent 2: flock ... bun run typecheck → WAITS for lock
Agent 3: flock ... bun run lint → WAITS for lock
Result: Only 1 quality gate at a time# ALWAYS CHECK RESOURCES FIRST
.claude/hooks/check-system-resources.sh || sleep 30
# ALWAYS USE FLOCK
LOCK="/tmp/rad-engineer-quality-gate.lock"
# ALWAYS USE BUN
flock -w 300 "$LOCK" bun run typecheck # NOT pnpm
flock -w 300 "$LOCK" bun run lint # NOT npm
flock -w 300 "$LOCK" bun test # NOT npx
# ONE-LINER (copy-paste ready)
cd rad-engineer && LOCK="/tmp/rad-engineer-quality-gate.lock" && flock -w 300 "$LOCK" sh -c 'bun run typecheck && bun run lint && bun test'