Agent rule pattern

Good and bad pairs

The wrong version sits beside the right one.

14 of 100 projects

The shape of the rule

  1. Show the wrong case
  2. Show the right case
  3. Explain the difference
How to use it

Some files show full before-and-after blocks; others use inline pairs. The examples settle cases the rule alone leaves unclear.

Use a pair where prose leaves room for doubt. Put the unwanted and intended cases together, then name the difference.

Examples from real projects

3 examples · Pinned source

Separate invalid input from an empty result

The session example distinguishes missing request headers from a real request without a session cookie, showing the API boundary that validation must preserve.

AGENTS.mdL59
Source excerpt starting at line 59.
- Distinguish invalid usage from valid empty state. Example: a server session check without request headers is invalid usage; a server session check with headers but no session cookie is a valid request that returns `null`.

Prefer behavioral relationships over changing catalog values

The test guidance contrasts assertions about fixed model names and counts with contracts between data structures. It explains how snapshot-like checks can turn expected catalog updates into maintenance failures.

AGENTS.mdL385–394
Source excerpt starting at line 385.
A change-detector fails whenever data *expected to change* is updated — model catalogs,`_config_version`, enumeration counts, hardcoded model lists. It adds no coverage and taxesevery routine update. Don't: `assert "gemini-2.5-pro" in _PROVIDER_MODELS["gemini"]`,`assert DEFAULT_CONFIG["_config_version"] == 21`, `assert len(models) == 8`. Do: `assert"gemini" in _PROVIDER_MODELS and len(_PROVIDER_MODELS["gemini"]) >= 1` (plumbing works);`assert raw["_config_version"] == DEFAULT_CONFIG["_config_version"]` (migration reacheslatest); `assert not (set(moonshot_models) & coding_plan_only_models)` (no leak); everycatalog model has a context-length entry (relationship). If it reads like a snapshot, deleteit; if it reads like a contract between two pieces of data, keep it. Reviewers reject newchange-detectors; authors convert them before re-review.

Show the direction of graph connections

A parent-node lookup needs an inverted connection map; a child lookup uses the original map. The worked code ties the shared helper to the data structure's indexing direction.

AGENTS.mdL201–202
Source excerpt starting at line 201.
**Key concept:** `workflow.connections` is indexed by **source node**.To find parent nodes, use `mapConnectionsByDestination()` to invert it first.

Projects using this pattern (14)

Browse in directory →
Show 6 more projects
← All agent rule patterns