Show HN: Sixwhyo – Your code reviewed by a six-year-old (and he's not wrong)

hxii1 pts0 comments

sixwhyo – A six-year-old code reviewer who's not afraid to ask<br>"why?" about everything.

sixwhyo → six-why-o → 6 y.o.

INTRO

sixwhyo was created with the sole purpose to help (and<br>remind) you to question your decisions when it comes to writing<br>(potentially) overly complicated code.

Unlike the adults, who tend to overcomplicate things for no reason<br>{p:40} 40% of the time,<br>sixwhyo will spend<br>{p:0} 0% of his time figuring out<br>complicated solutions.

This means that your productivity will go<br>{l:10,29,10,31,16,45,20,65,30,85,100} UP↑<br>and your time wasted on trying to figure out the code will go<br>{l:100,60,95,44,68,27,30,5} DOWN↓

SKILLS

sixwhyo comes with three skills for different purposes,<br>but with the same goal.

NAME<br>DESCRIPTION

sixwhyo

A six-year-old code reviewer who asks "why?" about everything.<br>Catches over-engineering, confusing names, and unnecessary<br>complexity.

sixwhyo-summarize

Output is a 1-2 line summary of the request as a whole: how is the<br>file? Is the class nice? Is the function correct?

sixwhyo-simplify

corrects the code according to the language spec, but through kids<br>eyes, maintaining simplicity and readability.

INSTALLATION

pi install git:github.com/hxii/sixwhyo

For other harnesses (OpenCode, Oh My Pi, Codex), see<br>README

USAGE

TRIGGER<br>WHAT IT DOES

6yo

Activates the kid. Stays on until you say stop.

sixwhyo-simplify<br>One-shot: reviews and rewrites the code, then exits.

sixwhyo-summarize<br>One-shot: 1–2 line file summary, then exits.

EXAMPLES

BEFORE<br># calculator.py<br>from abc import ABC, abstractmethod

class Operation(ABC):<br>@abstractmethod<br>def execute(self, a: float, b: float) -> float:<br>pass

class AdditionOperation(Operation):<br>def execute(self, a: float, b: float) -> float:<br>return a + b

class SubtractionOperation(Operation):<br>def execute(self, a: float, b: float) -> float:<br>return a - b

class MultiplicationOperation(Operation):<br>def execute(self, a: float, b: float) -> float:<br>return a * b

class DivisionOperation(Operation):<br>def execute(self, a: float, b: float) -> float:<br>if b == 0:<br>raise ValueError("Cannot divide by zero")<br>return a / b

class OperationFactory:<br>@staticmethod<br>def create_operation(op_type: str) -> Operation:<br>if op_type == "add":<br>return AdditionOperation()<br>elif op_type == "subtract":<br>return SubtractionOperation()<br>elif op_type == "multiply":<br>return MultiplicationOperation()<br>elif op_type == "divide":<br>return DivisionOperation()<br>else:<br>raise ValueError(f"Unknown operation: {op_type}")

class Calculator:<br>def __init__(self):<br>self.factory = OperationFactory()

def calculate(self, op_type: str, a: float, b: float) -> float:<br>operation = self.factory.create_operation(op_type)<br>return operation.execute(a, b)

def main():<br>calc = Calculator()<br>result = calc.calculate("add", 5, 3)<br>print(f"Result: {result}")

if __name__ == "__main__":<br>main()

REASONING<br>This file is too big and I'm confused.

**Why is it called test.py when it says calculator.py inside?**<br>The comment on line 1 says "calculator.py" but the file is test.py. That's like putting a "cat" label on a dog.

**Why so many classes for adding numbers?**<br>You have:<br>- One class to say "what an operation is" (Operation)<br>- Four classes for adding, subtracting, multiplying, dividing<br>- One class to make the operations (OperationFactory)<br>- One class to use the operations (Calculator)

That's 7 classes to do `a + b`. I can do that with just `a + b`.

**Why does the factory need to exist?**<br>The factory takes a string like "add" and returns an AdditionOperation. But why not just do the math right there? When I want to add 5 and 3, I don't need to build a machine first.

**Why does Calculator need its own class?**<br>It just has one method that asks the factory for an operation and runs it. That's two lines of code, not a whole class.

**What's good:**<br>You did check for dividing by zero. That's smart because dividing by zero makes numbers explode.

AFTER<br>def calculate(op, a, b):<br>if op == "add": return a + b<br>if op == "subtract": return a - b<br>if op == "multiply": return a * b<br>if op == "divide":<br>if b == 0: raise ValueError("Cannot divide by zero")<br>return a / b<br>raise ValueError(f"Unknown operation: {op}")

Submit your Example

Made by hxii · Inspired by<br>my six-year-old, Andy ❤️

float class operation return sixwhyo self

Related Articles