write-tests
Skill1 starsChanged 5 months agoMITView on GitHub
Writes tests for this Django/DRF plus Next.js stack — Django TestCase with a tenant fixture factory, APIClient carrying the cookie JWT, a mandatory tenant-isolation test (user B gets 404/empty for user A's row), RBAC denial tests, and vitest that mocks the shared fetch-client to test hooks and Zod parsing. Use when adding tests, writing a TestCase or vitest spec, testing a ViewSet or React Query hook, covering tenant isolation or a permission denial, or asking what to test here. Not for real-browser end-to-end specs — fixtures, storage-state auth, tenant seeding, flake control (see browser-e2e-testing) — driving a change end to end before calling it done (see verify), or wiring the CI that runs the suite (see ci-cd).
33 other projects use a version of this.
Adopted by
Most recently taken up by
- dzhng/skillstheir own version, first seen Oct 4, 2026
- dzhng/jevgreptheir own version, first seen Oct 2, 2026
- dzhng/duet-agenttheir own version, first seen Oct 2, 2026
- aprameyak/coding-skillstheir own version, first seen Oct 2, 2026
- getsentry/sentry-javascripttheir own version, first seen Sep 27, 2026
- NarekManukyan/flutter-mobx-kittheir own version, first seen Sep 17, 2026
Used with
Projects with it also use audit-choices, close-spec and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
dzhngSkillaudit-choices
Audit the choices an implementing agent made, not its diff — a pure decision audit that traces the session's history into a choices ledger, changes no code, and never blocks an unsupervised run. Working code still embeds architecture the user never chose; surface it because future work inherits it. Use when the user wants to review the decisions the AI made on their behalf, before merging or committing AI-implemented work, when integrating a delegated subagent's pass, or when a fix "works" but might be a point fix.
Also in 3 projects that use this
dzhngSkillclose-spec
When a spec under specs/<feature>/ is done shipping (a write-spec build, or any planned task that produced a spec), archive it to specs/done/ and rewrite it from a build-plan into a durable rationale — the why, the principles, the invariants — pointing back to the real code for the how. Use when implementation has landed and the plan no longer matches what shipped, or the user says a feature/spec is finished. Pairs with [write-spec](../write-spec/SKILL.md) (the plan this closes) and [review](../review/SKILL.md) (run before closing).
Also in 3 projects that use this
LucasMatuszewskiSkillaudit-agents
Audit and maintain agent configuration files (.claude/agents, AGENTS.md, CLAUDE.md, agent-memory). Checks for duplicates, outdated info, naming conflicts, wrong technical facts, and files over 200 lines. Fixes all issues and commits.
Also in 3 projects that use this
Halcyon666Skillwrite-skills
Creates high-quality Agent Skills (SKILL.md files) that follow the open Agent Skills specification. Use when asked to create a skill, write a SKILL.md, package agent instructions, build a reusable capability, or turn a workflow into a shareable skill. Produces spec-compliant, concise, well-structured skills optimized for agent discovery and execution.
Also in 3 projects that use this
isLinXuSkilleval-skills
AI Agent Skill unit testing framework. A framework-agnostic toolkit for discovering, scaffolding, selecting, evaluating, and reporting on AI skills. Use this skill to assess skill quality before production, compare candidate skills on the same benchmark, enforce quality gates in CI/CD, and generate human-readable evaluation reports.
Also in 3 projects that use this
TrecekSkillaudit-tests
Audit the test suite for useless tests, consolidation opportunities, over-mocking, weak assertions, and other test quality issues. Use when user says "audit tests", "audit test suite", "review tests", or "test quality check". Generates an improvement plan in temp/ with explanations for each proposed change.
Also in 3 projects that use this
- +6 more from dzhng
Other versions33 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 33
- getsentry/sentry-javascript★ 8.8ksame name
- huggingface/OpenEnv★ 2.6ksame name
- dzhng/jevgrep★ 2.3ksame name
- NeoLabHQ/context-engineering-kit★ 1.7ksame name
- dzhng/skills★ 978same name
- microsoft/semantic-link-labs★ 584same name
- atherio-danp/cde-dotnetcc★ 109same name
- getsentry/abacus★ 77same name
- alamops/skills★ 52same name
- dzhng/duet-agent★ 46same name
23 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository49 other files it gives its agents.
- accessibilitySkill
- ai-evalsSkill
- ai-integrationSkill
- architecture-decisionsSkill
- audit-loggingSkill
- aws-servicesSkill
- browser-e2e-testingSkill
- celery-tasksSkill
- changelogSkill
- ci-cdSkill
- codebase-guideSkill
- code-reviewSkill
- commit-messageSkill
- cookie-auth-csrfSkill
- dashboard-data-designSkill
- db-concurrencySkill
- debugSkill
- dependency-auditSkill
- deploy-awsSkill
- design-systemSkill
- drf-apiSkill
- drf-zod-contractSkill
- frontend-perfSkill
- git-workflowSkill
- i18n-rtlSkill
- incident-responseSkill
- migrationsSkill
- money-decimalSkill
- multi-tenancySkill
- nextjs-moduleSkill
- observabilitySkill
- perf-reviewSkill
- production-readinessSkill
- product-ux-designSkill
- rbac-permissionsSkill
- react-querySkill
- security-reviewSkill
- skill-authoringSkill
- tailwind-shadcnSkill
- tenant-session-switchSkill
- threat-modelingSkill
- verifySkill
- version-checkSkill
- visual-ui-designSkill
- webhook-handlerSkill
- websockets-channelsSkill
- zod-formsSkill
- zustand-stateSkill
- example-skillSkill
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 1 is distinctive, and 2 are very specific to this project.
0
Common
Most of the 31 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 14
Test behavior at the boundary, not implementation.
- Very specific: line 65
Keep Arrange / Act / Assert visibly separate — build state, do the one thing, assert the outcome.
- Distinctive: line 72
Before committing, break the code on purpose and confirm the test goes red — a test that passes no matter what is worse than none.
“Common” is measured: kept by at least 6 in 10 of the 31 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Write tests (what and how to test on this stack)
When to use
Adding or reviewing tests for a ViewSet, serializer, task, hook, or schema. Test the seams that carry your invariants — tenant isolation, RBAC, contract parsing — not framework internals. Every scoped resource ships with a tenant-isolation test.
Pattern
Test behavior at the boundary, not implementation. On the backend that means the
DRF request/response through APIClient with a real auth cookie; on the frontend it
means the hook plus its Zod parse, with the shared fetch-client mocked — never the
raw network. Two tests are non-negotiable for any tenant-scoped endpoint: user B
cannot see user A's row (404/empty), and a user lacking the RBAC perm is denied (403).
Steps / idioms
- Tenant fixture factory — build isolated tenants once, reuse everywhere.
- APIClient with the cookie JWT — authenticate the way production does (set the
HttpOnly access cookie simple-jwt reads), not
force_authenticate. The two required tests —
test_tenant_isolation(detail 404 and empty list) andtest_rbac_denied(missing perm → 403). One Python example covers all three:# tests/test_invoices.py — rename Entreprise/entreprise + perm codenames to match your repo def make_tenant(name, perms=()): # tenant fixture factory ent = Entreprise.objects.create(name=name) user = User.objects.create_user(f"{name}@t.io", "pw", entreprise=ent) user.user_permissions.add(*resolve_perms(perms)) # RBAC codenames, e.g. invoice_view return ent, user class InvoiceIsolationTest(APITestCase): def setUp(self): self.ent_a, self.user_a = make_tenant("a", perms=["invoice_view"]) self.inv_a = Invoice.objects.create(entreprise=self.ent_a, total=10) def auth(self, user): # set the HttpOnly access cookie simple-jwt reads self.client.cookies["access"] = str(AccessToken.for_user(user)) def test_tenant_isolation(self): # THE required test _, user_b = make_tenant("b", perms=["invoice_view"]) self.auth(user_b) assert self.client.get(f"/api/invoices/{self.inv_a.pk}/").status_code == 404 assert self.client.get("/api/invoices/").json() == [] # empty, not A's row def test_rbac_denied(self): # missing perm returns 403 _, viewer = make_tenant("c", perms=[]) self.auth(viewer) assert self.client.get("/api/invoices/").status_code == 403- Frontend —
vi.mockthe shared fetch-client module (notglobal.fetchor MSW), then assert the hook plus its Zod parse. Az.coerce.number()field, for instance, turns the API's"10.50"string into10.5— test that coercion, not the network.
What to skip
Framework internals (Django's ORM, DRF routing, TanStack Query's cache), trivial getters/setters, and pure passthrough. If a test would only re-assert that Django or Zod works, delete it. Cover your logic — scoping, permissions, coercion, edge cases.
Shape of a test
Keep Arrange / Act / Assert visibly separate — build state, do the one thing,
assert the outcome. Name the test after the behavior so it reads as a sentence:
test_empty_value_is_rejected, not test_2. One behavior per test — if the name
needs an "and", split it. Always cover the unhappy path: empty, zero, negative,
the boundary value, and the missing-permission case, not just the golden input.
Is the test real?
Before committing, break the code on purpose and confirm the test goes red — a
test that passes no matter what is worse than none. Assert the one value that
encodes the behavior (resp.json()["total"] == "12.500"), not an exact HTML dump or
a huge JSON blob that breaks on any cosmetic change. Mock only the boundary — the
outbound HTTP call, the clock — and run the real logic under test through it.
Async and UI tests
- Celery tasks — run them synchronously with
CELERY_TASK_ALWAYS_EAGER = Trueso a.delay()executes inline and you assert its effect directly. Control time (freeze the clock) to assert retry/backoff — a failing task reschedules with a growing countdown — and idempotency: run the task twice on the same input and confirm the second run is a no-op (no duplicate row, no double charge). Mock external calls at the boundary (the outbound HTTP client, the payment SDK), not the task body, so the real task logic runs through the mock (seecelery-tasks). - React components — use a component-testing library with
user-event(not rawfireEvent) to test form validation and submission — a bad value shows the error, a good one calls the mutation once. Cover all four TanStack Query states: loading (skeleton), empty (no rows), error (retry visible), success (data renders). Render under your locale provider to check translated strings and RTL direction (dir="rtl") so a mirrored layout doesn't regress silently. - Top of the pyramid — keep a few real-browser E2E tests for the critical
journeys and push all other detail down to the layers above; see
browser-e2e-testingfor fixtures, auth/storage-state, tenant seeding and flake control.
Adapt to your repo
Rename Entreprise/entreprise, the perm codenames, the cookie name (access vs your
SIMPLE_JWT["AUTH_COOKIE"]), and the fetch-client import path (@/lib/api-client) to
match your project. Confirm AccessToken.for_user matches your simple-jwt token class,
and run the suite against the same database engine as production so behavior matches.
Gotchas
- The isolation test must assert both the detail 404 and the list being empty — a
passing detail check with a leaking list is the classic miss (see
multi-tenancy). - Authenticate via the cookie, not
force_authenticate— the latter skips the exact cookie/CSRF path production uses and hides auth-wiring bugs. - Mock the shared client module, not
global.fetch— you are testing your hook and schema, not the browser's networking. - A green suite proves shape, not real behavior — still drive the flow (see
verify). - For money or precise computations, assert the exact known value and pin a
hand-verified golden fixture — never an approximate compare (see
money-decimal). - For concurrency, don't try to reproduce the race; test the invariant the lock
protects — balance never negative, no duplicate numbers (see
db-concurrency). - Make each test self-contained: build all state in setup. No reliance on run order, leftover data from another test, or the machine's timezone.
- A flaky test is a bug — fix the cause, never rerun until it goes green.
- A red test is a stop sign. Never delete or skip a failing test just to merge.
See also
multi-tenancycelery-tasksmoney-decimaldb-concurrencybrowser-e2e-testingverifyci-cd
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.

