Rules Hub
Coding Rules Library
Add Rule via JSON
Paste a rule JSON payload to create or update rules directly. Use this when you already have structured rule data and want to bypass the prototype flow.
JSON requirements
These fields must be present for the payload to validate and save.
- Root can be a rule object,
{ "rule": { ... } }, an array of rules, or{ "rules": [ ... ] }. - Required strings:
id,slug,title,shortDescription. - Required enums:
category(frontend, backend, fullstack),stack(react, nextjs, node, express, typescript, testing, performance, architecture, general),priority(p0, p1, p2),scope(universal, stack-specific, project-specific). tagsmust be an array of strings (empty array is OK).badExampleandgoodExamplemust includecode,language(ts, tsx, js, jsx, json),explanationEn, andexplanationHr.- Optional:
notesEn,notesHr,exceptionsEn,exceptionsHr(string or null). - Optional:
highlightLines(number array) andhighlightTokens(string array) inside examples.
Example payload
{
"rules": [
{
"id": "prefer-early-returns",
"slug": "prefer-early-returns",
"title": "Prefer early returns over deep nesting",
"shortDescription": "Early returns keep control flow easy to read and reduce indentation.",
"category": "backend",
"stack": "node",
"priority": "p1",
"scope": "universal",
"tags": ["readability", "control-flow"],
"badExample": {
"code": "function getLabel(status: string) {\n if (status === \"ok\") {\n return \"OK\";\n } else {\n return \"Unknown\";\n }\n}",
"language": "ts",
"explanationEn": "Nested branches add noise and make the function harder to scan. As conditions grow, the code becomes harder to maintain.",
"explanationHr": "Ugnijezdene grane stvaraju sum i otezavaju brzo citanje funkcije. Kako uvjeti rastu, kod postaje tezi za odrzavanje."
},
"goodExample": {
"code": "function getLabel(status: string) {\n if (status !== \"ok\") return \"Unknown\";\n return \"OK\";\n}",
"language": "ts",
"explanationEn": "Early returns keep the happy path clear and reduce indentation. The control flow is simpler to extend.",
"explanationHr": "Rani povratak cuva happy path jasnim i smanjuje uvlake. Tok izvrsavanja je jednostavniji za prosirenje."
},
"notesEn": null,
"notesHr": null,
"exceptionsEn": null,
"exceptionsHr": null
},
{
"id": "validate-api-payloads",
"slug": "validate-api-payloads",
"title": "Validate request payloads before side effects",
"shortDescription": "Validation prevents bad data from reaching the database and gives clients clear errors.",
"category": "backend",
"stack": "node",
"priority": "p0",
"scope": "universal",
"tags": ["validation", "api", "error-handling"],
"badExample": {
"code": "app.post(\"/users\", async (req, res) => {\n const user = await db.user.create({ data: req.body });\n res.json(user);\n});",
"language": "ts",
"explanationEn": "The handler trusts the request body shape. Malformed payloads can cause runtime errors or corrupt data.",
"explanationHr": "Handler vjeruje formatu tijela. Losi payloadi mogu uzrokovati greske ili lose podatke."
},
"goodExample": {
"code": "const UserSchema = z.object({ name: z.string(), email: z.string().email() });\n\napp.post(\"/users\", async (req, res) => {\n const parsed = UserSchema.safeParse(req.body);\n if (!parsed.success) return res.status(400).json({ errors: parsed.error.issues });\n const user = await db.user.create({ data: parsed.data });\n res.json(user);\n});",
"language": "ts",
"explanationEn": "The handler validates before any side effects. Clients get structured 400 errors and the database stays clean.",
"explanationHr": "Validacija ide prije side effecta. Klijenti dobiju jasne 400 greske, a baza ostaje cista."
},
"notesEn": null,
"notesHr": null,
"exceptionsEn": null,
"exceptionsHr": null
}
]
}