testing-conventions

A set of testing rules for changes to source code and tests. It requires new behavior to have dedicated tests and asks developers to consider end-to-end tests, which check a complete workflow using the real Agent.

In plain words
What is it for?
Use it when modifying src/ code or tests, adding a feature or field, changing Agent interactions, or deciding which unit and end-to-end tests are needed.
Why use it?
It prevents treating passing old tests as proof that a new feature works. The rules ensure new parameters, fields, and interactions are checked directly, including in realistic end-to-end scenarios.

Cursor rule for Cursor

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.

agentmods
npx agentmods add rules/0xranx/golembot/testing-conventions
Clone the repo
git clone --depth 1 https://github.com/0xranx/golembot

Made for: Cursor.

Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 1,388 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found 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 $0.00000 $0.01388
Opus 5 $0.00000 $0.00694
Sonnet 5 $0.00000 $0.00278
Haiku 4.5 $0.00000 $0.00139

Measured 2d ago against content hash 138dcc3d3b1d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

testing-conventions 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 2d 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.

.cursor/rules/testing-conventions.mdc · 108 lines

How it starts

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

Testing Conventions

Feature Changes Must Be Verified (Most Important Rule)

Any substantive change to source files under src/ must:

  1. Add dedicated tests for the new functionality — passing existing tests is not enough. Each new feature/field/parameter needs corresponding test cases; these must fail when the feature is removed.
  2. Evaluate whether e2e tests need updates — if the change affects interaction with the real Agent (e.g. params, output parsing, event types), add new assertions in e2e.
  3. Run e2e once (pnpm run e2e) to ensure real scenarios still work — even if the change seems small.

⚠️ Anti-Pattern Warning

"Changed code + all old tests pass = done" — that is wrong. Old tests only verify old behavior. New functionality without dedicated tests is effectively unverified.

Typical mistakes:

  • Added apiKey to InvokeOpts → but no test verifies apiKey is actually passed to the engine
  • Added durationMs to done event → but no test for with/without duration_ms scenarios
  • Modified parseStreamLine → but e2e has no assertion for the new fields returned by the real Agent

Correct approach:

  1. Unit tests: mock engine captures new params; verify end-to-end propagation of new fields from source to consumer
  2. e2e assertions: verify new fields have values in real conversations (e.g. durationMs > 0)
  3. Do not consider it done until tests have been run

Unit Tests (vitest)

Location: src/__tests__/<module>.test.ts

Mock Engine Pattern

Unit tests do not call the real Agent (Cursor / Claude Code). Replace with a mock engine:

async function* mockInvoke(prompt, opts): AsyncIterable<StreamEvent> {
  yield { type: 'text', content: 'mock response' };
  yield { type: 'done', sessionId: 'mock-session-123' };
}

Inject via vi.mock('../engine.js', ...), returning mock engine from createEngine.

Key Test Scenarios

  • session.test.ts: Multi-key routing, Phase 1 format migration, concurrency safety
  • index.test.ts: sessionKey routing, KeyedMutex concurrency isolation, resetSession
  • server.test.ts: All HTTP endpoints, SSE streaming, Bearer auth, CORS, input validation
  • engine.test.ts: stream-json parsing (parseStreamLine + parseClaudeStreamLine), ANSI stripping, injectClaudeSkills, createEngine factory
  • workspace.test.ts: golem.yaml read/write, skills scanning, AGENTS.md generation

Read the full file on GitHub · 108 lines

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. 2d ago First seen · 108 lines · 0 tokens per session scan A 138dcc3d3b1d

Subscribe to this mod's changes

testing-conventions is a cursor rule published in the GitHub repository 0xranx/golembot (319 stars, last pushed 14d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 1,388 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.