๐ Full Skill Source โ This is the complete, unedited SKILL.md file. Nothing is hidden or summarized.
Quality Gate โ Test + Verify + Ship Safe โ
Three checkpoints, one skill: Pre-deploy testing, evidence verification, frontend safety.
The Iron Laws โ
- NO DEPLOY without passing
test:gate. - NO CLAIMS without fresh verification output.
- NO FRAGILE FRONTEND โ safety tests are mandatory.
Phase 0: Infrastructure Setup โ
Goal: Identify the framework and install the correct testing dependencies.
- Detect Stack: Check
package.jsonfor framework (React, Vue, Astro, etc.) andwrangler.json(c). - Install Deps:
npm install -D vitest jsdom acorn - Configure: Create
vitest.config.tsorvite.config.tswithenvironment: 'jsdom'. - Wire Scripts:json
{ "scripts": { "test:gate": "vitest run --reporter=verbose" } }
Phase 1: The 4 Core Test Layers โ
Do not combine these files. They form the "Quality Gate."
Layer 1: Frontend Safety (test/frontend-safety.test.ts) โ
Prevents white screens, template corruption, and syntax errors.
test('app.js does not contain catastrophic corruption', () => {
const code = fs.readFileSync('public/static/app.js', 'utf-8');
expect(code).not.toMatch(/=\s*'[^']*\$\{t\(/); // Bug #1
expect(code).not.toMatch(/<\s+[a-zA-Z]/); // Bug #2
});Layer 2: API Routes (test/api-routes.test.ts) โ
Ensures backend endpoints respond correctly.
Layer 3: Business Logic (test/business-logic.test.ts) โ
Tests pure functions, validations, and transformations.
Layer 4: i18n Synchronization (test/i18n-sync.test.ts) โ
Guarantees all language files have identical key counts.
Phase 2: Execution (The Gates) โ
Gate 1: Pre-Deploy Testing โ
ALWAYS run npm run test:gate before deploying. 0 failures required.
Protocol โ
Check for skip override (explicit user words only):
- โ "skip tests", "bแป qua test", "deploy without testing"
- โ "deploy", "quick deploy", "just push it" (= tests required)
Run test gate:
bashnpm run test:gateParse results: total files, total tests, failures, duration
Gate decision:
- 0 failures โ proceed to deploy
- Any failures โ STOP. Fix first. Do NOT deploy.
Anti-Patterns โ
| DON'T | DO |
|---|---|
| Deploy then test | Test then deploy |
| "Tests passed earlier" | Run fresh test:gate NOW |
| Skip for "small changes" | Every change gets tested |
| Run test + deploy parallel | Sequential: test โ gate โ deploy |
Gate 2: Evidence Before Claims โ
ALWAYS run the proving command before saying "fixed" or "done."
The Gate Function โ
1. IDENTIFY โ What command proves this claim?
2. RUN โ Execute the FULL command (fresh)
3. READ โ Full output, check exit code
4. VERIFY โ Does output confirm the claim?
5. ONLY THEN โ Make the claimCommon Failures โ
| Claim | Requires | Not Sufficient |
|---|---|---|
| Tests pass | Test output: 0 failures | "Should pass", previous run |
| Build succeeds | Build: exit 0 | Linter passing |
| Bug fixed | Test symptom: passes | Code changed, assumed fixed |
| Requirements met | Line-by-line checklist | Tests passing |
Red Flags โ STOP โ
- Using "should", "probably", "seems to"
- Expressing satisfaction before verification
- Trusting agent success reports
- ANY wording implying success without running verification
Gate 3: Frontend Integrity โ
Automated via Layer 1 above.
When โ
Setting up or enhancing test suites for projects with frontend JavaScript/TypeScript.
The 7 Layers โ
| Layer | What it checks | Priority |
|---|---|---|
| 1. Syntax Validation | JS parses without errors (via acorn) | CRITICAL |
| 2. Function Integrity | Named functions exist and are callable | Required |
| 3. Template Safety | HTML templates have matching tags | Required |
| 4. Asset References | Referenced files actually exist | Required |
| 5. Corruption Patterns | Known bad patterns (empty functions, truncation) | Required |
| 6. Import/Export | Module references resolve | Recommended |
| 7. CSS Validation | CSS files parse correctly | Recommended |
Setup โ
npm install -D vitest acornLayer 1: Syntax Check (Most Critical) โ
import { parse } from 'acorn';
import { readFileSync } from 'fs';
test('app.js has valid syntax', () => {
const code = readFileSync('public/static/app.js', 'utf-8');
expect(() => parse(code, { ecmaVersion: 2022, sourceType: 'script' })).not.toThrow();
});This single test would have prevented the March 2026 white-screen incident.
Integration โ
| Skill | Relationship |
|---|---|
cm-safe-deploy | Quality gate is the primary blocker for the deploy pipeline |
cm-identity-guard | Verify identity before using quality gate to ship |
cm-tdd | TDD creates the logic for Layer 3 |
cm-safe-i18n | Leverages Layer 4 for parity checks |
The Bottom Line โ
Test before deploy. Evidence before claims. Safety before shipping. Non-negotiable.