Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
backend ruleP1universalStack: node
llmschemapromptscorrectness
Keep validation constraints consistent with what the LLM is told to produce
If a schema caps a field length, the prompt must instruct the model to stay within that cap; otherwise valid model output fails parsing.
PR: hegnar-journalist-boost · org-mining-deep-2026-06Created: Jun 17, 2026
Bad example
Old codetypescript
| 1 | const schema = z.object({ reasoning: z.string().max(240) }); |
| 2 | // prompt never tells the model to keep reasoning under 240 chars |
Explanation (EN)
Objašnjenje (HR)
Good example
New codetypescript
| 1 | const schema = z.object({ reasoning: z.string().max(240) }); |
| 2 | const PROMPT = 'Explain your choice in at most 240 characters.'; |
Explanation (EN)
Objašnjenje (HR)