shift-left-testing
关于
This skill helps developers implement shift-left testing by moving validation and test creation earlier in the development lifecycle. It provides actionable steps for practices like TDD, BDD, and CI/CD integration to catch defects when they are cheapest to fix. Use it to structure your testing strategy with a focus on requirements validation, test-first development, and automated pipeline checks.
快速安装
Claude Code
推荐/plugin add https://github.com/proffesor-for-testing/agentic-qegit clone https://github.com/proffesor-for-testing/agentic-qe.git ~/.claude/skills/shift-left-testing在 Claude Code 中复制并粘贴此命令以安装该技能
技能文档
Shift-Left Testing
<default_to_action> When implementing early testing practices:
- VALIDATE requirements before coding (testability, BDD scenarios)
- WRITE tests before implementation (TDD red-green-refactor)
- AUTOMATE in CI pipeline (every commit triggers tests)
- FOLLOW test pyramid: Many unit (70%), some integration (20%), few E2E (10%)
- FIX defects immediately - never let them accumulate
Quick Shift-Left Levels:
- Level 1: Unit tests with each PR (developer responsibility)
- Level 2: TDD practice (tests before code)
- Level 3: BDD/Example mapping in refinement (requirements testing)
- Level 4: Risk analysis in design (architecture testing)
Critical Success Factors:
- Defects found in requirements cost 1x; in production cost 100x
- Every commit must run automated tests
- Quality is built in, not tested in </default_to_action>
Quick Reference Card
When to Use
- Reducing cost of defects
- Implementing CI/CD pipelines
- Starting TDD practice
- Improving requirements quality
Cost of Defects by Phase
| Phase | Relative Cost | Example |
|---|---|---|
| Requirements | 1x | Fix doc: 30 min |
| Design | 5x | Redesign: few hours |
| Development | 10x | Code fix: 1 day |
| Testing | 20x | Fix + retest: 2 days |
| Production | 100x | Hotfix + rollback + investigation |
Test Pyramid
/\ E2E (10%) - Critical user journeys
/ \
/ \ Integration (20%) - Component interactions
/ \
/________\ Unit (70%) - Fast, isolated, comprehensive
Shift-Left Levels
| Level | Practice | When |
|---|---|---|
| 1 | Unit tests in PR | Before merge |
| 2 | TDD | Before implementation |
| 3 | BDD/Example Mapping | During refinement |
| 4 | Risk Analysis | During design |
Level 1: Tests in Every PR
# CI pipeline - tests run on every commit
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci
- run: npm run test:unit
- run: npm run test:integration
- run: npm run lint
quality-gate:
needs: test
steps:
- name: Coverage Check
run: npx coverage-check --min 80
- name: No New Warnings
run: npm run lint -- --max-warnings 0
Level 2: TDD Practice
// Red: Write failing test first
test('calculates discount for orders over $100', () => {
const order = new Order([{ price: 150 }]);
expect(order.discount).toBe(15); // 10% off
});
// Green: Minimal implementation
class Order {
get discount() {
return this.total > 100 ? this.total * 0.1 : 0;
}
}
// Refactor: Improve while keeping green
Level 3: BDD in Refinement
# Example mapping before coding
Feature: Loyalty Discount
Scenario: Gold member gets 15% discount
Given a customer with "gold" membership
When they checkout with $200 in cart
Then discount applied is $30
And order total is $170
Scenario: New customer gets no discount
Given a customer with no membership
When they checkout with $200 in cart
Then no discount is applied
Level 4: Risk Analysis in Design
// During architecture review
await Task("Risk Analysis", {
phase: 'design',
component: 'payment-service',
questions: [
'What happens when payment gateway times out?',
'How do we handle duplicate submissions?',
'What if inventory changed during checkout?'
]
}, "qe-requirements-validator");
// Output: Testability requirements, failure mode tests
Agent-Assisted Shift-Left
// Validate requirements testability
await Task("Requirements Validation", {
requirements: userStories,
check: ['INVEST-criteria', 'testability', 'ambiguity'],
generateBDD: true
}, "qe-requirements-validator");
// Generate tests from requirements
await Task("Generate Tests", {
source: 'requirements',
types: ['unit', 'integration', 'e2e'],
coverage: 'comprehensive'
}, "qe-test-generator");
// Smart test selection for changes
await Task("Select Regression Tests", {
changedFiles: prFiles,
algorithm: 'risk-based',
targetReduction: 0.7 // 70% time savings
}, "qe-regression-risk-analyzer");
Agent Coordination Hints
Memory Namespace
aqe/shift-left/
├── requirements/* - Validated requirements
├── generated-tests/* - Auto-generated tests
├── coverage-targets/* - Coverage goals by component
└── pipeline-results/* - CI/CD test history
Fleet Coordination
const shiftLeftFleet = await FleetManager.coordinate({
strategy: 'shift-left',
agents: [
'qe-requirements-validator', // Level 3-4
'qe-test-generator', // Level 2
'qe-regression-risk-analyzer' // Smart selection
],
topology: 'sequential'
});
Related Skills
- tdd-london-chicago - TDD practices
- holistic-testing-pact - Proactive testing
- cicd-pipeline-qe-orchestrator - Pipeline integration
- shift-right-testing - Production feedback
Remember
Earlier = Cheaper. Requirements defects cost 1x; production defects cost 100x. Test pyramid: 70% unit, 20% integration, 10% E2E. Every commit runs tests. TDD builds quality in.
With Agents: Agents validate requirements testability, generate tests from specs, and select optimal regression suites. Use agents to implement shift-left practices consistently.
GitHub 仓库
相关推荐技能
sparc-methodology
开发SPARC Methodology为开发者提供了一套从需求分析到部署监控的17种开发模式,通过多智能体协作实现系统化软件开发。它支持TDD工作流和架构设计,适用于复杂项目的全生命周期管理。开发者可以按需调用特定模式来提升代码质量和开发效率。
Verification & Quality Assurance
其他该Skill为开发者提供自动化代码质量验证和可靠性保障系统,通过实时真值评分(0-1分制)和代码质量检查确保输出质量。当评分低于0.95阈值时会自动回滚问题代码,有效维护代码库稳定性。特别适合集成至CI/CD流程,用于监控Agent输出质量和保障项目可靠性。
test-automation-strategy
其他该Skill为开发者提供完整的测试自动化策略指导,涵盖测试金字塔设计、FIRST原则应用和CI/CD集成。它适用于构建新自动化框架或优化现有测试效率的场景,内置页面对象模式等最佳实践模板。通过结构化方法帮助团队建立可靠、可维护且与开发流程深度集成的自动化测试体系。
github-workflow-automation
其他这是一个为开发者提供的GitHub工作流自动化技能,通过AI群体协调实现智能CI/CD流水线和全面的仓库管理。它能自动生成和优化GitHub Actions工作流,支持多智能体协作进行代码分析、测试和部署。开发者可以用它快速建立自适应的工作流系统,提升开发效率和代码质量。
