improve-codebase-architecture
Scan a codebase for deepening opportunities, present them as a visual HTML report, then grill through whichever one you pick.
- Category
- Design
- Source
- mattpocock/skills
- License
- MIT
- Proof model
- claude-opus-5-5
- Brief
- “Here is the orders module of a small Express app. ```js // orders.js const db = require("./db"); const stripe = require("stripe")(process.env.STRIPE_KEY); const mailer = require("./mailer"); async function createOrder(req, res) { const { items, couponCode } = req.body; if (!req.user) return res.status(401).end(); let total = 0; for (const i of items) { const p = await db.query("select price, stock from products where id = $1", [i.id]); if (p.rows[0].stock < i.qty) return res.status(409).json({ error: "out of stock" }); total += p.rows[0].price * i.qty; } if (couponCode) { const c = await db.query("select pct, expires from coupons where code = $1", [couponCode]); if (c.rows[0] && new Date(c.rows[0].expires) > new Date()) total = total * (1 - c.rows[0].pct / 100); } const charge = await stripe.paymentIntents.create({ amount: Math.round(total * 100), currency: "usd", customer: req.user.stripeId, confirm: true }); const o = await db.query("insert into orders (user_id, total, status) values ($1, $2, $3) returning id", [req.user.id, total, charge.status]); for (const i of items) await db.query("update products set stock = stock - $1 where id = $2", [i.qty, i.id]); await mailer.send(req.user.email, "Order " + o.rows[0].id, "Thanks! Total: $" + total.toFixed(2)); res.json({ id: o.rows[0].id, total }); } module.exports = { createOrder }; ``` The team keeps breaking checkout when they change coupons or stock rules, and the code is hard to test. Review the architecture and present your findings as a single HTML report: the problems you see, the changes you recommend in order of value, and what the code would look like after the most important change.”
- Skill commit
5beb35b