Skill站外收录 @skilllib/skill-2014279366123925505
reality-verification
确保修复类任务在执行前准确复现问题、执行后严格验证效果,覆盖代码测试、类型检查、构建部署、API响应及UI界面等各类场景,并同步评估测试质量,防止仅通过模拟而未检验真实逻辑的虚假通过。
测试与安全 AI 技能
Skills.MD
# Reality Verification
## Core Rule
**For fix goals: reproduce the failure BEFORE work, verify resolution AFTER.**
## Goal Detection
Classify user goals to determine if diagnosis is needed.
### Detection Heuristics
| Pattern | Type | Match |
|---------|------|-------|
| fix, repair, resolve, debug, patch | Fix | `\b(fix\|repair\|resolve\|debug\|patch)\b` |
| broken, failing, error, bug, issue | Fix | `\b(broken\|failing\|error\|bug\|issue)\b` |
| "not working", "doesn't work" | Fix | `not\s+working\|doesn't\s+work` |
| add, create, build, implement, new | Add | `\b(add\|create\|build\|implement\|new)\b` |
**Conflict resolution**: If both Fix and Add patterns present, treat as Fix. Fixing enables the feature.
## Command Mapping
Map goal keywords to reproduction commands.
| Goal Keywords | Reproduction Command |
|---------------|---------------------|
| CI, pipeline, actions | `gh run view --log-failed` |
| test, tests, spec | project test command (package.json scripts.test) |
| type, types, typescript | `pnpm check-types` or `tsc --noEmit` |
| lint, linting | `pnpm lint` or `eslint .` |
| build, compile | `pnpm build` or `npm run build` |
| deploy, deployment | `gh api` or MCP fetch to check status |
| E2E, UI, browser, visual | MCP playwright to screenshot or run E2E suite |
| endpoint, API, response | MCP fetch with expected status/response validation |
| site, page, live | MCP fetch/playwright to verify live behavior |
**Fallback**: If no keyword match, ask user or skip diagnosis.
## E2E Verification with MCP Tools
For deployment and UI verification, use MCP tools:
### Playwright (UI/E2E)
```
When goal involves: UI broken, E2E failing, visual regression, page not loading
BEFORE: Use MCP playwright to:
- Capture screenshot of broken state
- Run failing E2E test
- Document visible error
AFTER: Same action should:
- Show fixed UI
- E2E test passes
- No visible error
```
### Fetch (API/Deployment)
```
When goal involves: API down, endpoint failing, deployment broken, 500 errors
BEFORE: Use MCP fetch to:
- Hit endpoint, capture status code
- Document error response body
- Note timestamp
AFTER: Same endpoint should:
- Return expected status (200, 201, etc)
- Response matches expected schema
- No error in body
```
## BEFORE/AFTER Documentation
### BEFORE State (Diagnosis)
Document in `.progress.md` under `## Reality Check (BEFORE)`:
```markdown
## Reality Check (BEFORE)
**Goal type**: Fix
**Reproduction command**: `pnpm test`
**Failure observed**: Yes
**Output**:
```
FAIL src/auth.test.ts
Expected: 200
Received: 401
```
**Timestamp**: 2026-01-16T10:30:00Z
```
### AFTER State (Verification)
Document in `.progress.md` under `## Reality Check (AFTER)`:
```markdown
## Reality Check (AFTER)
**Command**: `pnpm test`
**Result**: PASS
**Output**:
```
PASS src/auth.test.ts
All tests passed
```
**Comparison**: BEFORE failed with 401, AFTER passes
**Verified**: Issue resolved
```
## VF Task Format
Add as task 4.3 (after PR creation) for fix-type specs:
```markdown
- [ ] 4.3 VF: Verify original issue resolved
- **Do**:
1. Read BEFORE state from .progress.md
2. Re-run reproduction command: `<command>`
3. Compare output with BEFORE state
4. Document AFTER state in .progress.md
- **Verify**: `grep -q "Verified: Issue resolved" ./specs/<name>/.progress.md`
- **Done when**: AFTER shows issue resolved, documented in .progress.md
- **Commit**: `chore(<name>): verify fix resolves original issue`
```
## Test Quality Reality Check
When verifying test-related fixes, also check for mock-only test anti-patterns:
### Mock-Only Test Red Flags
Tests may pass but not actually test implementation. Detect:
1. **Mockery Pattern**: Test file has more mock setup than real assertions
- Count: `grep -c "mock\|stub\|spy" test-file` vs `grep -c "expect(" test-file`
- Red flag: Mock lines > 3x assertion lines
2. **Missing Real Imports**: Test only imports test libraries, not actual module
- Check: Does test import the real implementation?
- Red flag: Only imports from jest/vitest/testing-library
3. **Behavioral-Only Testing**: All assertions are mock interactions
- Check: `grep "toHaveBeenCalled\|spy.calledWith" test-file`
- Red flag: No `toBe`, `toEqual`, `toMatch` assertions on real values
4. **No Integration Coverage**: Every dependency is mocked
- Check: Are there any tests without mocks?
- Red flag: 100% mock coverage = 0% real integration tested
5. **Partial Mocks**: Using `vi.spyOn`/`jest.spyOn` excessively
- Red flag: Mixing real and mocked behavior creates unpredictability
6. **No Mock Cleanup**: Mocks persist across tests
- Check: `grep "afterEach\|mockClear\|mockReset" test-file`
- Red flag: Missing cleanup = flaky tests
### Reality Check for Test Fixes
For "fix tests" specs, verify BOTH conditions:
```markdown
## Reality Check (Test Quality)
**Before State**:
- Tests: FAILING
- Mock ratio: N/A (tests failing)
**After State**:
- Tests: PASSING ✓
- Mock quality check:
- Mock declarations: 2
- Real assertions: 15
- Real module import: YES ✓
- Integration tests: 3 ✓
- Mock cleanup: afterEach present ✓
**Verdict**: Tests now pass AND test real behavior (not just mocks)
```
If tests pass but have mock quality issues:
```markdown
## Reality Check (Test Quality)
**After State**:
- Tests: PASSING ⚠️
- Mock quality issues:
- Mock declarations: 20
- Real assertions: 4
- Mock ratio: 5.0x (exceeds 3x threshold)
- Real module import: MISSING
- Integration tests: 0
**Verdict**: Tests pass but only test mocks, not implementation
**Required**: Fix test quality before marking VERIFICATION_PASS
```
## Why This Matters
| Without | With |
|---------|------|
| "Fix CI" spec completes but CI still red | CI verified green before merge |
| Tests "fixed" but original failure unknown | Before/after comparison proves fix |
| Silent regressions | Explicit failure reproduction |
| Manual verification required | Automated verification in workflow |
| Tests pass but only test mocks | Tests verify real behavior, not mock behavior |
| False sense of security from green tests | Confidence that tests catch real bugs |
# Version 2.1.0
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「reality-verification」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次