read-before-write

read-before-write is a cursor rule for Cursor from arango-solutions/arango-sparql-py. It costs 384 tokens per session, scanned A, original, MIT.

A coding rule that says you should inspect the existing project before adding new code. It focuses on finding matching patterns, helpers, tests, and conventions first.

In plain words
What is it for?
Use it before creating types, functions, endpoints, tests, errors, or configuration fields so the change follows the codebase's established approach.
Why use it?
It reduces duplicated code and prevents new code from conflicting with the project's existing naming, structure, error handling, and logging.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it before creating types, functions, endpoints, tests, errors, or configuration fields so the change follows the codebase's established approach.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/arango-solutions/arango-sparql-py/read-before-write
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.

Clone the repo
git clone --depth 1 https://github.com/arango-solutions/arango-sparql-py

Made for: Cursor.

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 read-before-write

README.md
[![agentmods](https://agentmods.dev/badge/rules/arango-solutions/arango-sparql-py/read-before-write/github.svg)](https://agentmods.dev/rules/arango-solutions/arango-sparql-py/read-before-write)
Your own site
<a href="https://agentmods.dev/rules/arango-solutions/arango-sparql-py/read-before-write"><img src="https://agentmods.dev/badge/rules/arango-solutions/arango-sparql-py/read-before-write/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 read-before-write

Your own site · 80×15
<a href="https://agentmods.dev/rules/arango-solutions/arango-sparql-py/read-before-write"><img src="https://agentmods.dev/badge/rules/arango-solutions/arango-sparql-py/read-before-write.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 384 This file is loaded in full into every session.
When invoked 384 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.1 $0.00384 $0.00384
Opus 5.5 $0.00154 $0.00154
Sonnet 5.5 $0.00077 $0.00077
Haiku 4.5 $0.00038 $0.00038

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

Security

Grade A, and why

read-before-write 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 1mo 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/read-before-write.mdc · 53 lines

What it actually says

Read Before Write

"Match the codebase, don't fight it."

Before writing ANY code, understand what already exists. The codebase has patterns, conventions, and utilities. Use them, don't reinvent them.

The Reading Protocol

Before implementing anything:

  1. Pattern Search — How does the codebase already do this?
  2. Utility Search — Is there a helper for this?
  3. Existing Implementation — Has someone already solved this?
  4. Test Pattern Search — How are similar things tested?

What You Must Find Before Writing

Before Writing Find First
New struct/type Existing similar types
New function Existing utilities with same behavior
New endpoint Existing endpoint patterns
New test Existing test helpers/patterns
New error type Existing error conventions
New config field Existing config structure

Pattern Matching Requirements

When you find existing patterns, you MUST:

  1. Use the same naming conventions
  2. Use the same file organization
  3. Use the same error handling style
  4. Use the same logging approach
  5. Use existing utilities — don't write formatTime() if utils.FormatTime() exists

The Duplication Detector

Question If Yes →
Does this function already exist? Use it
Does a similar type already exist? Extend or reuse it
Is there a util/helper for this? Call it
Is there an established pattern? Follow it

The codebase was here before you. Your job is to make it more consistent, not less.

Read first. Match the patterns. Then write.

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. 1mo ago First seen · 53 lines · 384 tokens per session scan A 3cafa318b431

Subscribe to this mod's changes

read-before-write is a cursor rule published in the GitHub repository arango-solutions/arango-sparql-py (2 stars, last pushed 10d ago), licensed MIT. It adds 384 tokens to every session, about $0.0015 per session on Opus 5.5. 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-31.