跳到正文
cccskills
免费在 GitHub 公开

conventions

Apply these opinionated testing conventions whenever writing, reviewing, or planning tests: what earns a test and what is coverage theatre, asserting outputs rather than mock calls, the three modes (functional, performance, security), naming and isolation rules, where to mock, and reporting findings for coverage rather than self-filtering. Includes house Jest standards for NestJS unit and contract tests, TDD discipline, and test-report structure.

中文简介正在准备中。当前显示原文说明。

查看安装方法

包含的文件(7)

  • SKILL.md5.4 KB
  • references/nestjs-jest-common.md7.9 KB
  • references/nestjs-jest-contract-tests.md5.5 KB
  • references/nestjs-jest-unit-tests.md6.8 KB
  • references/tdd-iron-laws.md2.3 KB
  • references/test-reports.md1.7 KB
  • references/testing-anti-patterns.md2.1 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Testing

House conventions for writing tests and test strategy.

What a test is for

A test earns its place by failing when the behaviour breaks. That single criterion resolves most arguments about what to test: if you cannot name the bug a test would catch, it is coverage theatre — it costs maintenance on every refactor and reports success while the system is broken.

Two consequences run through everything below:

  • Assert on outputs — return values, thrown errors, persisted state. A test whose only assertion is expect(mock).toHaveBeenCalledWith(…) verifies the wiring you just wrote, not the behaviour. Rewrite the implementation correctly in a different shape and it fails; break the behaviour while keeping the calls and it passes. Both are the wrong way round.
  • Test decisions, not lines. Branches, error translation, state transitions, boundary conditions. A pass-through delegator or a field mapping with no conditional has nothing to get wrong, and a test for it only breaks when someone renames a method.

Coverage percentage is a floor signal — it finds untested files. It cannot tell a valuable test from a vacuous one, so treat a high number as "nothing is empty", never as "the tests are good".

Three modes

Ask all three of a feature; the answers rarely come from the same test.

  • Functional — does it do the right thing, including at its edges and when it fails? For anything with a UI, that includes reachability: tab order lands somewhere sensible, controls have accessible names, and an automated axe pass is clean. A keyboard-only user hitting a dead end is a functional bug, not a polish item.
  • Performance — does it hold up at the load and data volume it will actually see?
  • Security — the concrete asks, per endpoint: no credentials → 401; valid credentials but wrong role → 403; another tenant's object ID → 404 or 403, never the object; malformed or oversized input → 400, not a 500; repeated requests → 429; and the response carries nosniff, a frame policy, and HSTS. Each is one test, and each covers a class of bug that functional tests are structured not to find.

Conventions

  • Name tests as behaviour: should [outcome] when [condition]. When it fails in CI, the name alone should say what broke — a name like it('works') sends the next person to read the body.
  • Tests are independent and order-free. Shared mutable state produces failures that only reproduce in one order, and those cost days.
  • Control time, randomness, and environment. A test that reads the real clock fails on a date boundary, in another timezone, or during the leap second — always at the worst moment, always looking like a real bug.
  • Mock at the process boundary, not between your own units. Every internal mock is a second implementation you now maintain, and it can drift from the real one until the tests pass against a system that no longer exists.
  • Mocks mirror the real response completely. A stub returning { id, name } when production returns fifteen fields passes the test and crashes on user.email. Use factories with realistic defaults.
  • Never add a method to production code for a test (_resetForTesting). Build a fresh instance per test instead; test concerns in production code ship to users.
  • A flaky test is a failing test. Quarantining it and moving on trains the team to ignore red, which is the state where a real regression walks through.
  • Tier the suite by how fast it has to answer. Unit tests run on save and should stay under about five minutes; integration on commit, under fifteen; end-to-end on the pull request, under thirty; anything slower runs nightly. The number that matters is the one a developer waits for — once the inner loop crosses a few minutes, people stop running it locally and CI becomes the first place failures appear.

Reporting findings

When reporting test results or reviewing coverage, report everything you find, including low-severity and uncertain items — rank by severity and confidence, and let a separate pass decide what to act on. Filtering at the point of discovery loses real defects silently, and the reader cannot tell the difference between "nothing found" and "found and dropped".

references/test-reports.md has the report structure and severity definitions.

References

<!-- TDD Iron Laws and Testing Anti-Patterns adapted from obra/superpowers by Jesse Vincent (@obra), MIT License -->
ReferenceLoad when
references/tdd-iron-laws.mdWorking test-first; red-green-refactor discipline
references/testing-anti-patterns.mdReviewing existing tests; diagnosing tests that catch nothing
references/nestjs-jest-common.mdAny Jest test in a NestJS backend — read before the two below
references/nestjs-jest-unit-tests.mdWriting .spec.ts
references/nestjs-jest-contract-tests.mdWriting .contract-spec.ts against a live external API
references/test-reports.mdProducing a test report or defect write-up

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

Write a short, fact-checked reply that answers a colleague's question in one meaning only, ready to copy and paste. The input is their pasted message. Check the claims against the code first, use the project glossary terms, and print only the reply in chat. Read-only — no writes to code, the issue tracker, GitHub, chat or any MCP. Use on "/cortex-communication:answer-buzzkill", "help me answer", "reply to this question", or when the user pastes a colleague's question and asks for an answer in the same manner.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月13日 更新

Apply these opinionated .NET 8 architecture conventions whenever structuring or reviewing a backend service: clean architecture layering and which direction dependencies point, when CQRS with MediatR is worth it, cross-cutting concerns as pipeline behaviours, minimal APIs grouped by feature, keeping DbContext in Infrastructure, health checks and structured logging, WebApplicationFactory integration tests, and when AOT pays off.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月13日 更新

Apply these opinionated Python 3.11+ conventions when writing Python in this codebase: type hints with mypy, async/await, pytest fixtures, dataclasses, Poetry packaging, production patterns.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月13日 更新

csharp

免费

Apply these opinionated C# conventions whenever writing or reviewing C# 12 / .NET 8+ code: nullable enabled with warnings as errors, records and primary constructors, pattern matching over cast chains, the Result pattern for expected failures, async all the way with CancellationToken, IOptions config, IHttpClientFactory, and never returning EF entities from an API.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月13日 更新

ALWAYS invoke for any task involving docstrings, JSDoc/TSDoc, or REST API documentation — even when the request seems handleable without it. Enforces Microsoft contract-first conventions and a bare-minimum rule that Claude won't apply by default: never restate the signature, drop @param/@returns that only echo names and types, always document @throws, and document data shapes as WHAT not WHY. Covers Python docstring styles (Google/NumPy/Sphinx), TSDoc tags and @inheritDoc, and API doc patterns for NestJS/Express/FastAPI/Django. Trigger on: adding or auditing docstrings, redundant or missing tags, deleting comment rot, or producing a documentation-health report. Do not skip for documentation tasks — consistent conventions are the whole point.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月13日 更新

Remove signs of AI-generated writing from text. Use after drafting to make copy sound more natural and human-written. Based on Wikipedia's "Signs of AI writing" guide.

中文简介正在准备中。当前显示原文说明。

alexander-danilenko/cortex-claude-code-plugins172026年10月13日 更新

查看 alexander-danilenko 的全部技能

报告此技能的问题