Cupid code review

From Habitat-Thinking/ai-literacy-superpowers · View interactive version

Cupid code review is an AI agent skill from the GitHub repository Habitat-Thinking/ai-literacy-superpowers. Use when reviewing or refactoring code and wanting a structured lens beyond SOLID — applies Daniel Terhorst-North's CUPID properties to surface improvement opportunities in any codebase or language.

How to use this skill

Skill file

CUPID as a Code Review and Refactoring Lens

Overview

CUPID is a set of five properties — Composable, Unix philosophy, Predictable, Idiomatic, Domain-based — described by Daniel Terhorst-North as things good code tends toward, not rules it must comply with. That makes them ideal review lenses: you are asking "how strongly does this code exhibit this property?" and "what would moving it further in this direction look like?"

Use them as questions, not verdicts.


The Five Lenses

C — Composable: plays well with others

Code is composable when it can be combined with other code in many contexts without modification.

Review questions:

Refactoring signals:

Move toward: Smaller surface area. Dependencies injected. Works in isolation.


U — Unix philosophy: does one thing well

Not just single responsibility — the function does its one thing completely and well, with a clear, nameable purpose.

Review questions:

Refactoring signals:

Move toward: One clear responsibility. Name that earns no qualification. Flat abstraction level.


P — Predictable: does what you expect

Given its name and context, the code behaves consistently, without surprises. Deterministic where possible. Fails loudly rather than silently.

Review questions:

Refactoring signals:

Move toward: Behaviour matches name. Side effects visible in signature. Loud failure.


I — Idiomatic: feels natural

Code that fits its language, ecosystem, and team conventions. A reader familiar with the context should not be surprised by the patterns used.

Review questions:

Refactoring signals:

Move toward: Follows the grain of the language. Uses established patterns. No surprises for the familiar reader.


D — Domain-based: the solution domain models the problem domain

The code uses the language of the business or problem domain. Names come from the domain, not from technical implementation details.

Review questions:

Refactoring signals:

Move toward: Names from the domain. Structure that reflects domain relationships. Code a domain expert could navigate.


Quick Reference

| Property | Core question | Primary smell |

| --------- | ------------- | ------------- |

| Composable | Can I use this anywhere without baggage? | Hidden dependencies, large surface area |

| Unix | Does it do one thing, completely? | "and" in name, mixed abstraction levels |

| Predictable | Does it behave as its name suggests? | Hidden side effects, silent failure |

| Idiomatic | Does it feel natural here? | Reinventing the wheel, inconsistent patterns |

| Domain-based | Does it speak the domain's language? | Generic or technical names for business concepts |


Using CUPID as a Review Lens

Work through each property in turn for the code under review. For each one:

  1. Ask the review questions above
  2. Note which properties are weakly exhibited
  3. Describe a concrete change that would move toward the property

Avoid framing as pass/fail. The goal is: "this code is more Predictable than Composable — what would make it more Composable?"

Using CUPID as a Refactoring Guide

When deciding where to start refactoring:

  1. Score each property loosely (strong / weak / absent) for the target code
  2. Prioritise the weakest property that, if improved, would make the others easier
  3. Domain-based often unlocks everything else: when names are right, the right structure becomes obvious
  4. Composable refactoring tends to have the highest leverage — isolated code is testable, movable, reusable

Common Mistakes


Optional: README Status Addendum

After completing a CUPID assessment, offer to add or update a CUPID Status section in the project's README. Do not add it automatically — offer it and let the user decide.

When to offer

Badge

Add a shields.io static badge to the project's badge row (alongside CI and language badges) that links to the #cupid-status section. Update the date whenever the assessment is refreshed:

[![CUPID Status](https://img.shields.io/badge/CUPID-assessed_YYYY--MM--DD-DAA520?style=flat-square)](README.md#cupid-status)

The goldenrod colour (DAA520) is intentional — it matches the CUPID five-star rating aesthetic and is visually distinct from the green CI badges. The badge links directly to the status table in the same README.

GitHub label

If the project has a GitHub repository, ensure a CUPID assessed label exists for tagging PRs that include a CUPID review. Create it once with:

gh label create "CUPID assessed" --color "DAA520" --description "PR includes a CUPID code quality assessment" --repo <owner>/<repo>

Apply the label when opening a PR that includes a full CUPID review or a targeted CUPID-guided refactoring.

Standard format

Add a ## CUPID Status section (or update it if already present) using this template:

## CUPID Status

Last assessed: YYYY-MM-DD

| Property | Strength | Top opportunity |
| --------- | -------- | --------------- |
| Composable | ★★★★☆ | Brief description |
| Unix philosophy | ★★★☆☆ | Brief description |
| Predictable | ★★★★★ | — |
| Idiomatic | ★★★☆☆ | Brief description |
| Domain-based | ★★★★☆ | Brief description |

Strength ratings: use ★ symbols on a 1–5 scale. A — in the opportunity column means no meaningful opportunity was identified.

Top opportunity: one sentence describing the single most impactful change for that property. Keep it specific enough to be actionable, not a restatement of the property definition.

Placement in the README

Insert the section after any existing badges, overview, or quick-start content, and before detailed technical documentation. It should be easy to find at a glance — near the top, not buried at the bottom.

The badge belongs in the badge row at the very top of the README, after language/CI badges.

Workflow

If the project uses a branch/PR workflow (e.g. a CLAUDE.md that requires working on branches), follow that workflow to add the addendum: create a branch, make the change, open a PR. Do not commit directly to main if the project convention says otherwise.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.