用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/sawrus/agent-guides --skill test-pyramid命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
Production-grade GitHub Actions workflows — reusable workflows, OIDC cloud auth, caching, matrix builds, and environment protection rules. Use when the user creates, reviews, or debugs CI/CD pipelines in .github/workflows, or asks about GitHub Actions deployment, OIDC authentication, or workflow optimization.
Systematic diagnosis of Kubernetes pod failures — CrashLoopBackOff, OOMKilled, Pending, ImagePullBackOff, and service connectivity issues. Use when the user encounters pods not starting, container restart loops, scheduling failures, or service unreachability in a K8s cluster.
Implement distributed tracing with OpenTelemetry, Tempo/Jaeger — instrumentation, sampling, and trace-to-log correlation. Use when the user asks about distributed tracing, OpenTelemetry setup, span instrumentation, trace propagation, or connecting traces to logs and metrics.
正在显示 SKILL.md
基于 SOC 职业分类
| name | test-pyramid |
| type | skill |
| description | Decide what type of test to write, structure the suite, measure health, and apply test doubles correctly. |
| related-rules | ["test-strategy.md","quality-gates.md"] |
| allowed-tools | Read, Write, Edit, Bash |
Expertise: Test type selection, suite health, test doubles, coverage strategy, CI integration.
Is this a user-visible multi-step workflow (login → action → confirmation)?
→ E2E test (Playwright/Cypress/Detox)
Does the code call external systems (DB, API, queue, file system)?
→ Integration test (real or containerized dependency)
Is this pure business logic, calculation, data transformation, conditional?
→ Unit test (fast, isolated, no I/O)
Is this a contract between two services?
→ Contract test (Pact or schema validation)
| Layer | Target % | When runs | Max duration |
|---|---|---|---|
| Unit | 70% | Every commit | < 2 min |
| Integration | 20% | Every PR | < 5 min |
| E2E | 10% | Pre-release | < 20 min |
Suite health signals to act on:
Situation → Double
──────────────────────────────────────────────────────────
Verify a function WAS called → Mock
Control what a dependency returns → Stub
Need working but simplified implementation → Fake (in-memory DB)
Observe calls without replacing behavior → Spy
Golden rule: Never mock what you don't own. Wrap third-party libraries in your own adapter → mock the adapter.
# ❌ Mocking requests directly
with patch("requests.get") as mock:
mock.return_value.json.return_value = {"status": "ok"}
# ✅ Mock your own wrapper
class HttpClient:
async def get(self, url: str) -> dict: ...
class FakeHttpClient:
async def get(self, url: str) -> dict:
return {"status": "ok"}
service = MyService(http_client=FakeHttpClient())
Coverage is a floor, not a ceiling. Priority:
# ❌ Coverage inflation — tests nothing meaningful
def test_order_fields_exist():
order = Order(id=1, status="pending")
assert order.id == 1 # tests Python, not your logic
# ✅ Tests behavior and business rules
def test_order_cannot_be_cancelled_if_already_shipped():
order = Order(id=1, status="shipped")
with pytest.raises(OrderStateError, match="Cannot cancel shipped order"):
order.cancel()
# Naming: test_<when>_<expected_outcome>
def test_create_order_with_invalid_product_id_raises_not_found(): ...
def test_apply_discount_when_code_expired_returns_zero(): ...
# Structure: Arrange / Act / Assert
def test_order_total_includes_tax():
order = Order(items=[OrderItem(price=Decimal("100.00"), quantity=2)])
total = order.calculate_total(tax_rate=Decimal("0.20"))
assert total == Decimal("240.00")
# Parametrize for multiple inputs
@pytest.mark.parametrize("quantity,expected_error", [
(0, "must be greater than 0"),
(-1, "must be greater than 0"),
(1001, "exceeds maximum"),
])
def test_order_item_quantity_validation(quantity, expected_error):
with pytest.raises(ValidationError, match=expected_error):
OrderItem(product_id="prod_1", quantity=quantity)
make test (unit + integration) < 5 mintime.sleep() — use explicit waits or mocks for time