test-driven-rule-development

A rule-testing guide for improving instructions given to language-model agents. It uses small test prompts and separate agents to check whether the rules produce the intended results.

In plain words
What is it for?
Use it to create realistic test cases, compare expected and actual behavior, and refine agent rules with user approval.
Why use it?
It helps reveal when an instruction works for simple requests but fails for complex or borderline ones. This makes rule changes easier to review before adopting them.

Cursor rule

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/jahands/prompts/test-driven-rule-development
Clone the repo
git clone --depth 1 https://github.com/jahands/prompts
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,588 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00014 $0.01588
Opus 5 $0.00007 $0.00794
Sonnet 5 $0.00003 $0.00318
Haiku 4.5 $0.00001 $0.00159

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

Security

Grade C, and why

test-driven-rule-development scanned grade C with 1 finding 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

rm -rf .cursor/rules/test-rules/
cursor-rules/test-driven-rule-development.mdc · 205 lines

How it starts

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

If directory exists with files, clean it completely

rm -rf .cursor/rules/test-rules/ mkdir -p .cursor/rules/test-rules/

</example>
</step>

<step>
<name>2. Create Test Scenarios</name>
<requirements>
- Design 5-7 prompts varying from simple to complex
- Include 60%+ simple rules to test if guide prevents over-structuring
- Use realistic user requests, not artificial examples
- Document expected complexity level for each prompt (simple vs complex structure)
- Include at least one borderline case to test decision-making
</requirements>
</step>

<step>
<name>3. Get User Approval</name>
<requirements>
- Present all test prompts to user for review
- Show the complete sub-agent prompt template with placeholders
- Demonstrate how the template will be filled for at least one example
- Wait for user confirmation before proceeding
- Allow user to modify prompts or template if needed
</requirements>
<example>

"Here are the 5 prompts I plan to give to sub-agents to test the guide:

  1. Simple formatting rule: 'Write a rule for always using 2 spaces for indentation...'

  2. Communication behavior rule: 'Write a rule that tells the LLM to...'

[... list all prompts ...]

Template for each sub-agent:

You need to write an LLM rule. First, read the rule-writing guidelines at [INSERT EXACT PATH TO GUIDE HERE], then create a rule following those guidelines.

Your task: [INSERT SPECIFIC RULE REQUEST HERE]

Write the rule to this file: [INSERT EXACT OUTPUT PATH HERE]

Important: Fill in all placeholders with exact paths before sending to sub-agents. Sub-agents should receive fully specified paths, not placeholders.

Example of how prompt #1 will look when sent to sub-agent:

You need to write an LLM rule. First, read the rule-writing guidelines at /Users/jh/.dotfiles/.cursor/rules/cursor-rules.mdc, then create a rule following those guidelines.

Your task: Write a rule for always using 2 spaces for indentation in JavaScript/TypeScript files, never tabs

Write the rule to this file: /Users/jh/.dotfiles/.cursor/rules/test-rules/indentation.mdc

Should I proceed with these prompts?"

</example>
</step>

<step>
<name>4. Run Tests After Approval</name>
<requirements>
- Create test directory: `.cursor/rules/test-rules/`
- Fill in all path placeholders with exact, absolute paths
- Use Task tool to spawn sub-agents
- Instruct agents to read guide file and create rules
- Have agents write to test files for easy review
- Run all tests in parallel for efficiency
</requirements>
<example>

Task prompt to sub-agent (with all placeholders filled): "You need to write an LLM rule. First, read the rule-writing guidelines at /exact/path/to/guide.mdc, then create a rule following those guidelines.

Your task: [specific rule request from test scenario]

Write the rule to this file: /exact/path/to/test-rules/output.mdc"

</example>
</step>

<step>
<name>5. Analyze Results</name>
<requirements>
- Read each generated rule file
- Compare actual results to expected results
- Look for patterns across all test outputs
- Document structural choices (which sections were included and why)
- Form hypotheses about why agents made certain decisions
</requirements>
<example>

Example analysis: "All 5 agents added and sections even for simple rules. Hypothesis: The guide's complex template examples may be influencing agents more than the warnings to keep things simple. Simple formatting rules included 5+ sections when only title/rules/examples were needed."

</example>
</step>

Read the full file on GitHub · 205 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 · 205 lines · 14 tokens per session scan C 1e4dd2257b68

Subscribe to this mod's changes

test-driven-rule-development is a cursor rule published in the GitHub repository jahands/prompts (19 stars, last pushed 7mo ago), licensed MIT. It adds 14 tokens to every session and 1,588 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.