SDE · Coding Rules Admin

Classic ASP / VBScript Coding Rules

Every time we hit a new error in ASP work, add the rule here so Claude never hits it again. Currently tracking 28 rules.

Add a new rule

Paste directly from an error message or Claude's fix explanation. Only Category and Title are required — fill in what you have.

Existing Rules

Click Edit on any row to load it into the form above. Deleting soft-archives the rule (IsActive=0) — not gone forever, but hidden from GetCodingRules.asp.

Cookies & Auth

#TitleSevTagsActive
8.1Request.Cookies — coerce with & "" and always validatecriticalcookie,auth,securityon

Database

#TitleSevTagsActive
3.1MARS deadlock — one open recordset per connectioncriticaldatabase,mars,recordset,sqlserveron
3.2Always close recordsets and null the referencewarningdatabase,recordset,cleanupon
3.3Always SQL-escape user values before building SQLcriticaldatabase,security,sql-injectionon
3.4Clamp form input lengths to column width before SQLwarningdatabase,validation,inputon
3.5Migrations must be idempotentwarningdatabase,migration,idempotenton
3.6Admin check on BN_Members is MemberRole='admin', NOT a boolean IsAdmin columncriticaldatabase,schema,admin,members,bn_memberson

Error Handling

#TitleSevTagsActive
9.1Master defensive pattern — never let data crash the pagecriticalerror-handling,defensiveon

File Organization

#TitleSevTagsActive
4.1Define helper Functions at the TOP of the ASP filewarningfile-organization,hoistingon
4.2Never use <!--#include--> inside a conditionalwarningfile-organization,includeon

HTML Rendering

#TitleSevTagsActive
7.1Always HTMLEncode user-provided valuescriticalhtml,xss,escapeon
7.2Use a separate attribute-safe escape for HTML attributeswarninghtml,escape,attributeon
7.3JS-safe inline needs a JSReady helperwarninghtml,javascript,escapeon

LLM APIs

#TitleSevTagsActive
6.1Use ===SECTION=== delimiters, not nested JSON-in-stringcriticalai,llm,parsing,geminion
6.2Set maxOutputTokens generously (8192+)warningai,llm,tokens,geminion
6.3In the system prompt, say "no JSON, no markdown, no preamble"warningai,llm,promptingon

Null Handling

#TitleSevTagsActive
2.1Null & "" = Null (not "")criticalnull,vbscript,stringon
2.2Always coerce recordset field reads with & ""criticalnull,recordset,databaseon
2.3Mid/Left/InStr on non-string Variants throws Type mismatchcriticalnull,vbscript,string,dictionaryon
2.4CDate can throw Type mismatch even when IsDate is Truecriticaldate,cdate,vbscripton
2.5Read migration-added columns defensivelywarningmigration,schema,defensiveon

User Input

#TitleSevTagsActive
5.1Coerce every form value with & "" before usingwarninginput,form,coerceon
5.2Validate numeric input with IsNumeric before castingcriticalinput,validation,numericon
5.3Multi-valued checkboxes join with ", " automaticallybest-practiceinput,form,checkboxon

VBScript Syntax

#TitleSevTagsActive
1.1Identifiers cannot start with an underscorecriticalvbscript,syntax,namingon
1.2Single-line If/Then cannot be chained with ElseIfcriticalvbscript,syntax,control-flowon
1.3Functions return by assigning to the function namecriticalvbscript,syntax,functionon
1.4VBScript has no native IIf — define your owncriticalvbscript,syntax,iifon