skill-inspector / rules
Cursor rule2 starsChanged 10 months agoApache-2.0View on GitHub
When implementing unit tests, adhere to the following principles to ensure robust, maintainable, and fast tests: By following these guidelines, you can write unit tests that are reliable, fast, and accurately reflect the behavior of your code.
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 4,181 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/tech-stack.mdcCursor rule
- .cursor/rules/typescript-coding-convention.mdcCursor rule
- build-and-fixSkill
- clean-projectSkill
- initialize-projectSkill
- lint-and-fixSkill
- node-upgradeSkill
- security-vulnerability-auditSkill
- setup-dev-envSkill
- test-and-fixSkill
- update-llm-modelsSkill
The file
We split this unit-test-manners.mdc into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 7
When implementing unit tests, adhere to the following principles to ensure robust, maintainable, and fast tests:
- Distinctive: line 10
Do not rely on mocks or patches, especially for methods or functions that involve external interactions such as network requests, database …
- Distinctive: line 16
Consider patterns such as "functional core, imperative shell" or "Hexagonal Architecture" to separate business logic from infrastructure …
≈ “Common” is an estimate: at least 1 in 5 of the 6,668 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
globs: **/*.test.ts
alwaysApply: false
---
# Unit Test Manners: Decoupling for Testability
When implementing unit tests, adhere to the following principles to ensure robust, maintainable, and fast tests:
1. **Avoid Mocks and Patches for External Dependencies:**
* Do not rely on mocks or patches, especially for methods or functions that involve external interactions such as network requests, database calls, or file system operations.
* Such tests often become brittle, difficult to maintain, and can give a false sense of security, as they test the interaction with a mocked dependency rather than the actual behavior of the system under test when integrated with real dependencies.
2. **Decouple Methods and Functions:**
* Design your methods and functions to be as decoupled as possible from external dependencies.
* Focus on creating "pure" functions or components with clear inputs and deterministic outputs, allowing them to be tested in isolation without the need for network requests or other I/O operations.
* Consider patterns such as "functional core, imperative shell" or "Hexagonal Architecture" to separate business logic from infrastructure concerns.
* For infrastructure components that still require testing, explore techniques like "Nullables" where production code includes an "off" switch for dependencies or mechanisms to track output for state-based assertions, as discussed in "Testing Without Mocks: A Pattern Language" by James Shore [https://www.jamesshore.com/v2/blog/2018/testing-without-mocks].
By following these guidelines, you can write unit tests that are reliable, fast, and accurately reflect the behavior of your code.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

