ForkFree

Prompts / Coding

Give the AI Code Ownership

You get a feature added with the duplicated code merged, rather than a third copy bolted on. Telling the AI it owns the design and will maintain it long term shifts it from patching to tidying.

Worked in our testIt merged the duplicate functions into one shared pricing helper, added the discount to both the basket total and the invoice, kept the old behaviour for callers with no customer, and listed what it couldn't verify. It fell short on format, because "Risks" was asked for as a line but came as a five-bullet list. "Line-for-line identical" also overstates it, since the variable names differ.

The prompt

Act as the sole owner and long-term maintainer of this codebase. Its design is your decision, and you will be the one living with it for years.

Task: Add the requested feature to the code below, and leave the codebase tidier than you found it.

Feature request: {feature_request}

Existing code:
{existing_code}

Steps:
1. Read the existing code and list any duplicated logic, near-identical functions or copy-pasted blocks relevant to the feature.
2. Decide on the cleanest design as the long-term owner would, merging duplicates into shared helpers rather than adding another copy.
3. Implement the feature using that design, keeping existing behaviour unchanged.
4. Check that every caller of any merged code still works, and note anything you could not verify.

Output:
First, a short "Design decisions" list of no more than five bullet points explaining what you merged and why. Then the complete updated code in one code block per file. Finish with a "Risks" line naming anything the maintainer should test.

Change the parts in curly braces. Use it when a codebase has copy-pasted logic and you want a feature added without piling on more duplication.

What happened when we ran it

We sent

Act as the sole owner and long-term maintainer of this codebase. Its design is your decision, and you will be the one living with it for years.

Task: Add the requested feature to the code below, and leave the codebase tidier than you found it.

Feature request: Add a 10% discount for customers who have placed more than five orders. The discount must appear on both the basket page total and the emailed invoice.

Existing code:
def basket_total(items):
    total = 0
    for i in items:
        total += i['price'] * i['qty']
    return round(total, 2)

def invoice_total(items):
    t = 0
    for item in items:
        t += item['price'] * item['qty']
    return round(t, 2)

def send_invoice(customer, items):
    body = 'Total: ' + str(invoice_total(items))
    email(customer['email'], body)

Steps:
1. Read the existing code and list any duplicated logic, near-identical functions or copy-pasted blocks relevant to the feature.
2. Decide on the cleanest design as the long-term owner would, merging duplicates into shared helpers rather than adding another copy.
3. Implement the feature using that design, keeping existing behaviour unchanged.
4. Check that every caller of any merged code still works, and note anything you could not verify.

Output:
First, a short "Design decisions" list of no more than five bullet points explaining what you merged and why. Then the complete updated code in one code block per file. Finish with a "Risks" line naming anything the maintainer should test.

The model replied

**Design decisions** - `basket_total` and `invoice_total` were line-for-line identical, so I merged them into one `price_order(items, customer)` that returns subtotal, discount and total. The basket page and the invoice now share one pricing path and can't drift apart. - The discount rule lives in one place (`loyalty_discount_rate`) with named constants, so changing the threshold or percentage is a one-line edit. - `basket_total` stays as a thin wrapper, and `invoice_total` is kept as an alias so callers I can't see don't break. Both default to no customer, which means no discount, so existing calls behave exactly as before. - The invoice body keeps the original `Total: X` line. When a discount applies, it adds Subtotal and Discount lines above it. - Rounding is applied once to the subtotal and once to the discount, so the displayed lines always add up exactly. ```python LOYALTY_ORDER_THRESHOLD = 5 # discount applies to MORE than this many orders LOYALTY_DISCOUNT_RATE = 0.10 def loyalty_discount_rate(customer): """Return the discount rate for a customer (0 if none applies).""" if customer and customer.get('order_count', 0) > LOYALTY_ORDER_THRESHOLD: return LOYALTY_DISCOUNT_RATE return 0 def price_order(items, customer=None): """Single source of truth for basket and invoice pricing. Returns a dict with 'subtotal', 'discount' and 'total'. """ subtotal = round(sum(i['price'] * i['qty'] for i in items), 2) discount = round(subtotal * loyalty_discount_rate(customer), 2) return { 'subtotal': subtotal, 'discount': discount, 'total': round(subtotal - discount, 2), } def basket_total(items, customer=None): return price_order(items, customer)['total'] # Deprecated alias kept for unseen callers; delete once none remain. invoice_total = basket_total def send_invoice(customer, items): pricing = price_order(items, customer) lines = [] if pricing['discount']: lines.append('Subtotal: ' + str(pricing['subtotal'])) lines.append('Loyalty discount: -' + str(pricing['discount'])) lines.append('Total: ' + str(pricing['total'])) email(customer['email'], '\n'.join(lines)) ``` **Risks** - I couldn't see the basket page, the customer model, or any other callers. The basket page must pass the customer into `basket_total(items, customer)` or `price_order`, otherwise it won't show the discount, and it should also render `price_order(...)['discount']` if you want a visible discount line. - I assumed the customer dict has an `order_count` key, and that it counts orders already placed (excluding the current one). Confirm both, and adjust `loyalty_discount_rate` if the field is named differently or the count includes the current order. - Test the boundaries (5 orders gets no discount, 6 does), a customer with no `order_count`, an anonymous basket (`customer=None`), and an empty basket. - The invoice body is now multi-line when a discount applies. Check that the email renders it correctly, especially if it's sent as HTML. - Search for other uses of `invoice_total` before removing the alias.

Run on Claude Sonnet 5.5, 12 Nov 2026. Automatic check: 4 out of 5.

Mentioned for

Claude

Where it came from

Found on Web, shared by Simon Willison (quoting Anthropic docs): A quote from Prompting Claude Fable 5.2.

This is our own version of the idea, written and tested by us. The original may differ.

More coding prompts

Coding Worked in our test
Generate Strict JSON Spec From Description

You get a clean, machine-readable JSON object that matches your rules on the first try. It works because the model reads the rules first, then checks its own answer against each one before replying.

Found on GitHub, shared by DominikScholz
Coding Partly worked
Match Ownership Wording to Change Size

You get a tightly scoped code change, plus a separate list of things the AI spotted but left alone. It works because you state how far the AI may go, so a sense of "ownership" does not trigger unrequested refactoring.

Found on Web, shared by explainx.ai
Coding Worked in our test
Turn Vague Bug Reports Into Concrete Objectives

You get a bug fix broken into a reproduction, a minimal change and a regression test, each checked against clear objectives. Concrete objectives stop the model drifting into large rewrites or guessing at what "fixed" means.

Found on Web, shared by David Ch (@chhddavid)