writing-tests

writing-tests is a skill for Claude Code, Codex from PostHog/posthog-foss. It costs 206 tokens per session (6,611 once invoked), scanned A, a copy of writing-tests, MIT.

A guide for deciding which automated tests are worth adding and how to keep them focused. It applies to tests written with tools such as pytest, Jest, or Playwright.

In plain words
What is it for?
Use it before adding or changing a test, fixture, assertion, or test setup in backend, frontend, or browser code.
Why use it?
It prevents slow, low-value test coverage and asks each new assertion to protect against a specific realistic regression.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: installed under .agents/ (shared by several agents); mentions AGENTS.md.

Good fit Use it before adding or changing a test, fixture, assertion, or test setup in backend, frontend, or browser code.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/posthog/posthog-foss/writing-tests
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add PostHog/posthog-foss --skill writing-tests
Clone the repo
git clone --depth 1 https://github.com/PostHog/posthog-foss

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for writing-tests

README.md
[![agentmods](https://agentmods.dev/badge/skills/posthog/posthog-foss/writing-tests/github.svg)](https://agentmods.dev/skills/posthog/posthog-foss/writing-tests)
Your own site
<a href="https://agentmods.dev/skills/posthog/posthog-foss/writing-tests"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/writing-tests/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for writing-tests

Your own site · 80×15
<a href="https://agentmods.dev/skills/posthog/posthog-foss/writing-tests"><img src="https://agentmods.dev/badge/skills/posthog/posthog-foss/writing-tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 206 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 6,611 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin 91% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00206 $0.06611
Opus 5.5 $0.00082 $0.02644
Sonnet 5.5 $0.00041 $0.01322
Haiku 4.5 $0.00021 $0.00661

Measured 4d ago against content hash 1ad83cc2f81d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

writing-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

91% identical to writing-tests — 379 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/writing-tests/SKILL.md · 337 lines

How it starts

The opening of the file, as written. The whole thing — 337 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Writing tests worth keeping

The handbook carries the rationale and the same rules for people: Backend coding conventions › Testing (docs/published/handbook/engineering/conventions/backend-coding.md). This skill is the gate an agent runs before it writes a test. It holds the decision procedure and a catalog of the bug shapes we actually ship. The gate covers added coverage, not only new test functions. One fixture and one assertion added to an existing block go through the same questions, because that is the shape this skill prefers.

The gate

Answer questions 1 and 2 in one sentence each before you write the test, and question 3 before you commit it. A question you can't answer stops the test.

1. Does it earn its place?

What realistic regression does this test catch that no existing test already catches?

Name the bug, the code path, and the input that would break it. "Increases coverage", "good practice", and "the function exists" are not answers. A good answer sounds like "if someone makes parse_filters drop the team_id clause, this fails" or "empty-cohort input used to 500; this locks in the 400."

Aim each test at a failure mode we actually ship. references/mistakes-we-make.md catalogs those shapes, the test that catches each, and the failure modes no unit test should chase. A test that maps to none of them is probably not worth keeping.

2. Where does it go?

Passing question 1 buys the coverage, not a new test function. Find the test that covers the nearest behavior and answer:

Why can't this be a case in that test?

When your case is a variation of that behavior, extend it with a @parameterized case in Python or a test.each row in Jest. Write a standalone test only when you can name one of three reasons: the setup differs, the behavior belongs to a different unit, or no relevant test exists. "It's cleaner as its own test" names none of them.

Read the full file on GitHub · 337 lines

Files

What ships with it

2 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 4d ago Changed · +4 lines 1ad83cc2f81d
  2. 10d ago Changed ed4fb2673fbe
  3. 11d ago Changed · +5 lines cc45aaa237f3
  4. 12d ago Changed · +1 lines cf10f1094c20
  5. 19d ago Changed · +1 lines 7df42452b49f
  6. 20d ago Changed · +91 lines · -5 tokens per session 708ed8fbd32b
  7. 25d ago Changed · +6 lines af655f617d15
  8. 1mo ago Changed · +5 lines 4abf2aa32274
  9. 1mo ago Changed · +3 lines cc7de7cac3a7
  10. 2mo ago First seen · 221 lines · 211 tokens per session scan A db7ec8fddfb0

Subscribe to this mod's changes

writing-tests is a skill published in the GitHub repository PostHog/posthog-foss (734 stars, last pushed today), licensed MIT. It adds 206 tokens to every session and 6,611 once invoked, about $0.0008 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 91% identical to writing-tests, differing in 379 lines, and is treated as a copy.

Related

writing-tests compared with skills from other repositories

writing-tests next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
writing-testsPostHog/posthog-fossSkill734todayMITA206Claude Code, Codex
imagegenopenai/codexSkill137ktodayApache-2.0A113Codex
playwright-climicrosoft/playwrightSkill101ktodayApache-2.0A19Claude Code
browser-automationopenclaw/openclawSkill395ktodayMITA36Claude Code
systematic-debuggingobra/superpowersSkill331k3d agoMITA21Claude Code
free-llm-apismnfst/awesome-free-llm-apisSkill15kyesterdayCC0-1.0A113Claude Code, Codex
next-cache-components-adoptionvercel/next.jsSkill144ktodayMITA95Claude Code