GoodCode
Every fact once. One heart. No silent failure. Tests that could have failed.
Most "clean code" advice is taste. Taste can't be checked, so a review turns into an argument.
GoodCode is a standard, not a style guide. Ten principles, 59 rules, each with an id like A-37-B. A rule counts as met only if a reviewer can check the evidence. A review cites ids, and an exception that isn't written down doesn't exist.
The plugin gives the standard to Claude. Claude writes code to it, and reviews code against it, citing a rule for every finding.
→ Read the standard: Code Architecture
The ten principles
| # | Principle | In one line |
|---|
| 1 | Priorities | Correctness, traceability, one home, simplicity, economy. In that order. |
| 2 | One home | Every fact is written once. Every copy is derived, generated or checked by a test. |
| 3 | Structure | Each module owns one concern. Dependencies point one way. The folder tree is the map. |
| 4 | Where logic lives | Rules live in one place. Calculation is pure. The flow lives in the heart. |
| 5 | Explicit rules | Every state, transition and rule is named, and traces to a written rule. |
| 6 | Values and boundaries | Input is checked once, at the door. Inside, every value says what it is. |
| 7 | Failure | Nothing turns a failure into silence. |
| 8 | Efficiency and security | Work happens where the data is. Nothing is open until it is granted. |
| 9 | Readable code | Someone who knows the business, not the code, understands any file in one pass. |
| 10 | Proven correct | A passing test is evidence only if it could have failed. |
Before / after
A refund. Twelve lines, and five ways to lose money quietly.
def refund(order_id, amount):
try:
order = db.get(order_id)
if order.status == "paid" or order.status == "shipped":
if amount > order.total:
amount = order.total # quietly clamped
db.update(order_id, status="refunded", refunded=amount)
send_email(order.customer, f"Refunded {amount}")
except Exception:
pass # refund failed? nobody knows
What a GoodCode review says about it:
[must fix] A-37-B except Exception: pass — a failed refund looks like a successful one.
[must fix] A-37-B amount > total is clamped, not rejected — the caller never learns.
[must fix] A-29-B amount arrives unparsed: a float, maybe negative, no currency.
[should fix] A-17-B one function reads, decides, writes and sends. Can't test the rule alone.
[should fix] A-19-B the email is sent from deep inside; the heart can't show it.
[should fix] A-23-B the order lifecycle is two string compares, not a state machine.
[should fix] A-24-B the refund rule has no name and cites no written rule.
After. The rule is a pure, named function. The heart shows the whole flow.
# orders/refund.py — written rule R-12: refund at most the total, only from PAID or SHIPPED.
REFUNDABLE = {Status.PAID, Status.SHIPPED}
def refund_amount(order: Order, requested: Money) -> Money: # R-12
if order.status not in REFUNDABLE:
raise NotRefundable(order.id, order.status)
if requested > order.total:
raise RefundExceedsTotal(order.id, requested, order.total)
return requested
# app/heart.py — the only place that loads, saves and sends.
def handle_refund(command: RefundCommand) -> None: # parsed at the boundary (A-29)
order = orders.load(command.order_id)
amount = refund_amount(order, command.amount)
orders.save(order_machine.apply(order, Event.REFUND, amount))
mail_queue.put(RefundIssued(order.customer, amount))
Now refund_amount can be tested with three numbers, and every way it can fail is raised and has a name.
Install
Claude Code, as two separate prompts: