# Reach for the Stock Solution

Before writing code that solves a **common** problem, find out whether
the framework already ships the answer. The prior probability that a
stock solution exists is set by the **framework's philosophy**, not by
how hard the problem feels.

Rails sits at the extreme end of that scale, and the reason is the
point: convention over configuration is not a nice property of Rails,
it is its *defining premise* — common problems have one blessed answer,
already written, already wired. So in an opinionated framework, "surely
there is a standard way to do this" is not a hopeful guess; it is the
framework's core promise. Hand-rolling a solution to a common problem
there is a bet AGAINST the framework's defining property, and that bet
is nearly always lost.

Scale your confidence to the framework: Rails, Django, Ember → a stock
answer almost certainly exists. Bare Rack, Express, a thin utility
library → it genuinely may not. The more opinionated the framework, the
more suspect any bespoke implementation should look, in authoring and in
review alike.

## Three triggers

Any one of these means stop and search before you write:

1. **The framework is opinionated.** Convention over configuration is a
   promise. Treat a missing answer as a search failure until proven
   otherwise.
2. **The requirement traces to a published spec, RFC, or standard.** If
   the behavior is mandated externally, the ecosystem has almost
   certainly already implemented it.
3. **You catch yourself surprised the framework lacks something
   obvious.** See below — the surprise is the tell.

## The tell is SURPRISE

"Shocking it doesn't do this out of the box" is evidence of a SEARCH
FAILURE, not a framework gap — and in a convention-over-configuration
framework it is nearly conclusive. If you feel that surprise, you have
already generated the strongest available signal that you are about to
duplicate something. Do not note the feeling and build anyway.

## Search for the COMPONENT, not the BEHAVIOR

A stock piece that is merely **not enabled by default** looks identical
to absence from the outside. Rails does not load
`Rack::ContentLength` by default — the component was blessed, shipped,
and one line of config away, and it was still mistaken for missing.
That opt-in shape is exactly what convention over configuration looks
like at the edges, and it is the shape most likely to be misread.

**"Not on by default" is never "not provided."** Grep the framework's
own middleware/component list, not just its docs for the behavior.

## The mechanical check: compare against peer systems

When you conclude your system is uniquely broken in a **common** way,
test that uniqueness against peer systems **before** building. Pick two
or three well-known applications on the same stack and check whether
they exhibit the bug. This takes about thirty seconds.

If the peers behave correctly, the question is **"what do they load that
we don't"** — never "what should I write." Peer comparison is the
cheapest available discriminator between *our bug* and *our missing
standard component*.

## Why this matters more than the wasted time

Two costs, and the second is the larger one.

**It is a competence signal.** Building one from scratch without first
checking shows you do not really know the platform you are building on.
A hand-rolled solution to a common problem is diagnostic of missing
fluency in the stack being modified — and the remedy is not "remember to
search" as a ritual. Fluency in the platform IS the job.

**Bespoke code misinforms every future reader.** A hand-rolled
implementation reads to every subsequent maintainer as a DELIBERATE
signal: "the standard thing must not have worked here, so someone wrote
this." That is false information planted at a decision point. The waste
of the author's time ends; the misinformation compounds with every
reader after.

## Why this is a rule

It fires at authoring time, before the code exists, so it cannot live
only in an audit lens. `cabinet-framework-quality` and
`cabinet-mantine-quality` already detect hand-rolled reimplementations —
but they run *after* the work, when the bespoke version is written and
the sunk cost argues to keep it.

It is also distinct from `maintainability.md`'s Single Source of Truth,
which asks whether the logic already exists **in this codebase**. This
rule asks whether it already exists **in the platform underneath it** —
a different search, in a different place, with a different answer.

The originating case: a `content-length: 0` on HEAD responses was
correctly diagnosed as violating RFC 9110 §9.3.2, then fixed with a
bespoke ~40-line Rack middleware that reimplemented
`Rack::ContentLength` nearly line for line — same guards, same edge
cases. The real fix was one line of configuration. Both the
opinionated-framework trigger and the published-spec trigger were
present, the surprise was felt and noted, and the peer check that
settled it in thirty seconds was run only after the operator pushed
back twice.
