diff --git a/AGENTS.md b/AGENTS.md index 10c5bda..dffd776 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -22,6 +22,7 @@ You **MUST** read each of these documents before contributing to this repository --- ## Critical Design Rules + ### 1. Only Store or Cache State When It Serves a Purpose **Never store or cache state unless doing so meets at least one of:** @@ -40,3 +41,57 @@ Proposal: run `which tailscale` at startup, set a `binaryAvailable` boolean, and 2. Creates a new class of edge cases that must be tested: the binary existed when the flag was set but later disappears. The code must now defend against both “flag is false” and “flag is wrong.” 3. Unreliable guard for a failure the code must handle anyway. A missing binary produces a clear exit-code failure on the real command. Checking the flag *and* handling the failure duplicates work. Reference: #11. + + +## Code Style Guidance + +### 1. **NEVER** Write Conditional and Loop Blocks Without Curly Braces + +**ALWAYS** use curly braces, `{}`, for if, else, while, and for blocks, even when they contain only a single statement. This ensures that any future additions to the block remain within the intended control flow. Reference: `CVE-2014-1266`. + +**GOOD** Examples: +```javascript +if (myvar) { + do_action(); +} +``` +```javascript +if (myvar) { do_action(); } +``` +```javascript +while (myvar) { + do_action(); +} +``` +```javascript +while (myvar) { do_action(); } +``` + +**BAD** Examples: +```javascript +if (myvar) + do_action(); +``` +```javascript +if (myvar) do_action(); +``` +```javascript +while (myvar) + do_action(); +``` +```javascript +while (myvar) do_action(); +``` + +### 2. **ALWAYS** Use Semicolons to End Statements + +For maximum clarity and readability, always end lines using semicolons. + +**GOOD** Example: +```javascript +do_action(); +``` +**BAD** Example: +```javascript +do_action() +``` \ No newline at end of file