root-cause-before-fix

A debugging rule that requires identifying a bug's underlying cause and showing evidence before changing code.

In plain words
What is it for?
Use it when investigating errors or reports that something is not working, especially when logs, API responses, database queries, code paths, or traces can provide evidence.
Why use it?
It helps prevent repeated guesses that fix only symptoms and leave the original problem unresolved.

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/flomenco-inc/flo-plugin/root-cause-before-fix
Clone the repo
git clone --depth 1 https://github.com/Flomenco-Inc/flo-plugin

Made for: Cursor.

Per session 958 This file is loaded in full into every session.
When invoked 958 The same file — it is already loaded in full.
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.00958 $0.00958
Opus 5 $0.00479 $0.00479
Sonnet 5 $0.00192 $0.00192
Haiku 4.5 $0.00096 $0.00096

Measured yesterday against content hash 3226b0210295, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

root-cause-before-fix 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 yesterday.

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/root-cause-before-fix.mdc · 91 lines

How it starts

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

Root Cause Before Fix

Before writing any code to fix a bug or address a "not working" report, you MUST state the root cause and evidence. Do not skip this step. Do not say "let me try this" without first saying "the cause is X because of Y."

The problem this prevents

The #1 failure pattern: user reports a bug → agent makes a plausible-looking code change → user tests → still broken → agent makes another guess → still broken → 5 rounds later, a whole day is wasted. The fix is to diagnose before treating.

Required format

Before writing any fix, present this to the user:

**Root cause:** <one sentence — what is actually wrong>
**Evidence:** <the specific log, API response, DB query, code path, or trace that proves it>
**Why this fix:** <how the proposed change addresses the root cause, not just the symptom>

How to gather evidence

For API errors (4xx/5xx)

# Check CloudWatch logs for the Lambda
aws logs filter-log-events \
  --log-group-name /aws/lambda/flo-dev-<service>-<function> \
  --start-time $(date -v-30M +%s000) \
  --profile 469128505698_FlomencoSuperAdmin --region us-east-1 \
  --filter-pattern "ERROR" \
  --query 'events[*].message' --output text | tail -20

For 403 errors specifically

Check whether the route exists in openapi.yaml — API Gateway returns 403 (not 404) for undeclared routes. Also check service_config.yaml for the Lambda mapping. See flo-system-architecture.mdc § "Debugging 403 errors".

For "deployed but not working"

# Verify the Lambda is actually running the new code
aws lambda get-function --function-name flo-dev-<service>-<function> \
  --profile 469128505698_FlomencoSuperAdmin --region us-east-1 \
  --query 'Configuration.{LastModified:LastModified,CodeSha256:CodeSha256}'

For frontend rendering issues

playwright > navigate to https://dev.floapp.co/<page>
playwright > evaluate: document.querySelector('<selector>') !== null
playwright > evaluate: JSON.stringify(window.__REACT_DEVTOOLS_GLOBAL_HOOK__ ? 'devtools' : 'no devtools')
# Check network tab for failed API calls
playwright > evaluate: fetch('https://api.dev.floapp.co/v1/<endpoint>', {headers: {'Authorization': 'Bearer ...'}}).then(r => r.status + ' ' + r.statusText)

Read the full file on GitHub · 91 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. yesterday First seen · 91 lines · 958 tokens per session scan A 3226b0210295

Subscribe to this mod's changes

root-cause-before-fix is a cursor rule published in the GitHub repository Flomenco-Inc/flo-plugin (0 stars, last pushed 2d ago), licensed MIT. It adds 958 tokens to every session, about $0.0048 per session on Opus 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.