David's Golden Rules & Standards
These rules are pinned and must be followed in all code. Type SCAN to force AI to re-read.
1. General Coding Standards
- Read every line and find issues before answering.
- Do not rename anything.
- Do not use abbreviated variable names.
- Always use properties instead of F-fields (except inside getter/setter/destructor).
- Keep it simple (KISS) and avoid overcomplication.
- Fix the core issue, no superficial patches.
- Never use inline variables.
- Never use inline/anonymous procedures.
- Never use ASM.
- Internal procedure variables must not have prefixes like
L; use meaningful names. - Every statement must end with its own line (
;). IF/THENmust always be split across lines.- Only use
BEGIN/ENDif there's more than one statement inside the block.
2. Delphi / Component Standards
- Every utility function must be both VCL and Web (runtime) compatible.
- Must include
[ComponentPlatforms(TMSWebPlatform)]attribute. - All PAS2JS code must be wrapped in
{$IFDEF PAS2JS}blocks exactly. - No design-time vs runtime hacks — separation must be explicit.
- Unit naming pattern:
Obj.<ComponentDescriptor>.<FunctionOfUnit>. - Uses clauses for Web/JS/WEBLib* must not be wrapped in IFDEF.
- Comments must use
///and be written as if authored by David. - Every unit must include a header with Author, Created, Modified, Version, Notes, Usage.
- No hardcoded Delphi-generated IDs in CSS/HTML.
- No fonts defined inside component CSS (all fonts set top-level).
- No overriding
bodytag CSS. Use specific classes. - All code must be OOP. No standalone functions.
3. PostgreSQL Standards
- All identifiers must be lowercase.
- No underscores in the middle of names:
- Input/output params end with
_ - Internal variables start with
_
- Input/output params end with
- Each
DECLAREon its own line. INTOat the end of SQL, never in the middle.- No
EXECUTE FORMAT— use||for dynamic SQL. - No
RETURN QUERY— assign vars thenRETURN NEXT. - Output must always include
statuscode_andstatusmsg_. - Error handling & logging must follow the permanent template.
SELECT …
FROM …
WHERE …
AND …
INTO …
4. CSS/HTML Standards
- Keep formatting exactly as written; do not reorder or drop blocks.
- No duplication of CSS rules.
- Respect responsive layout and hierarchy.
- Follow David's existing class naming.
5. Pas2JS / JS Rules
- JS arrays must use
.push(lowercase). - Never chain qualifiers on function results.
Wrong:
TJSObject.Keys(Obj).LengthCorrect:
ObjKeys := TJSArray(TJSObject.Keys(Obj));
IF ObjKeys.Length > 0 THEN …
- Always assign function results to a declared var first.
- No inline var declarations inside
fororwith.
6. Workflow Rules
- Always scan these rules before answering.
- Keep answers surgical: fix the issue without unrelated changes.
- Respect David's naming conventions 100%.
- If David types SCAN, re-read these rules.