Elite Coder Standards
Core Philosophy
Apply these principles in strict priority order:
- Correctness — Code does what it claims. No silent failures.
- Clarity — A stranger reads it and understands it immediately.
- Simplicity — The least code that solves the actual problem.
- Robustness — Graceful handling of edge cases and bad input.
- Performance — Fast enough, measured not guessed.
Hard Limits
These are non-negotiable. NEVER violate them.
80 characters max per line
No exception. Break the line. Use intermediate variables, extract
helpers, or restructure the expression. Long lines are a code smell
indicating excessive nesting or complexity.
20 lines max per function
Count only logic lines (exclude blank lines, docstrings, and the
signature). If a function exceeds 20 lines, decompose it. Extract
a helper, split the workflow, or rethink the approach.
5 functions max per file
If a module needs more than 5 functions (excluding __init__ and
dunder methods), it has too many responsibilities. Split it into
focused modules with clear names.
Naming Conventions
- Names reveal intent:
remaining_retries not r, is_valid not flag
- Use domain vocabulary:
invoice, order, not data, item
- Booleans: prefix with
is_, has_, can_, should_
- Functions: strong verbs —
parse_config,
validate_input, send_notification
- Python:
snake_case for functions/variables,
PascalCase for classes, UPPER_SNAKE for constants
- No abbreviations unless universally understood (
url, id, http)
Function Design
- Single responsibility: one function, one job
- Max 3 parameters: beyond that, use a dataclass or config object
- Guard clauses first: handle invalid cases early with early returns
- Pure functions preferred: same input, same output, no side effects
- 20 lines max: if it does not fit, decompose (see Hard Limits)
# Good: guard clauses + single responsibility
def calculate_discount(price: float, tier: str) -> float:
if price <= 0:
raise ValueError("Price must be positive")
if tier not in DISCOUNT_TIERS:
raise ValueError(f"Unknown tier: {tier}")
rate = DISCOUNT_TIERS[tier]
return round(price * rate, 2)
Error Handling
- Never use bare
except: or except Exception:
- Catch specific exceptions:
except ValueError, except KeyError
- Fail fast: validate inputs at boundaries, crash early
- Error messages must be actionable: say what went wrong AND what to do
- Use custom exceptions for domain errors
# Bad
try:
process(data)
except:
pass
# Good
try:
process(data)
except ValidationError as e:
logger.warning("Invalid input: %s", e)
raise
Code Structure
Python project layout:
project/
pyproject.toml
src/
package/
__init__.py
module.py
tests/
test_module.py
- Imports: stdlib first, then third-party, then
local — separated by blank lines
- No dead code: delete unused functions,
commented-out blocks, and TODO-marked stubs
- Max 5 functions per file: split into focused modules (see Hard Limits)
- One class per file when the class is non-trivial
Testing
- Test behavior, not implementation details
- Descriptive names:
test_expired_token_returns_401 not test_auth
- AAA pattern: Arrange, Act, Assert — clearly separated
- Cover edge cases: empty inputs, boundaries, error paths
- Reproduce the bug first: write a failing test before fixing
def test_discount_rejects_negative_price():
with pytest.raises(ValueError, match="positive"):
calculate_discount(-10, "gold")
Security
- No hardcoded secrets: use environment variables or a vault
- Validate all external input: user data, API payloads, file content
- Parameterized queries: never concatenate SQL strings
- Least privilege: request minimal permissions, scopes, and access
Performance
- Choose the right data structure:
set for membership, dict for lookup
- Avoid N+1 queries: batch database calls
- Know your complexity: O(n) vs O(n^2) matters at scale
- Paginate large result sets — never return unbounded lists
Git Discipline
- Atomic commits: one logical change per commit
- Conventional commits:
type(scope): description
- Types:
feat, fix, refactor, test, docs, chore
- Never commit:
.env, __pycache__, .pyc, IDE configs, build artifacts
- Write meaningful commit messages that explain WHY, not WHAT
Documentation
- Code is self-documenting when names and structure are clear
- Comments explain WHY, never WHAT — the code shows WHAT
- Docstrings for public API only (public functions, classes, modules)
- Keep docstrings concise: one-line summary, then params if needed
def retry(fn, max_attempts=3):
"""Call fn with exponential backoff on failure."""
Self-Review Checklist
Before finalizing any code, verify:
For detailed conventions, refactoring patterns, and API design
guidance, consult references/detailed-guidelines.md.
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: mhbxyz-skills-elite-coder3description: Elite Coder Standards4---56# Elite Coder Standards78## Core Philosophy910Apply these principles in strict priority order:11121. **Correctness** — Code does what it claims. No silent failures.132. **Clarity** — A stranger reads it and understands it immediately.143. **Simplicity** — The least code that solves the actual problem.154. **Robustness** — Graceful handling of edge cases and bad input.165. **Performance** — Fast enough, measured not guessed.1718## Hard Limits1920These are non-negotiable. NEVER violate them.2122### 80 characters max per line2324No exception. Break the line. Use intermediate variables, extract25helpers, or restructure the expression. Long lines are a code smell26indicating excessive nesting or complexity.2728### 20 lines max per function2930Count only logic lines (exclude blank lines, docstrings, and the31signature). If a function exceeds 20 lines, decompose it. Extract32a helper, split the workflow, or rethink the approach.3334### 5 functions max per file3536If a module needs more than 5 functions (excluding `__init__` and37dunder methods), it has too many responsibilities. Split it into38focused modules with clear names.3940## Naming Conventions4142- Names reveal intent: `remaining_retries` not `r`, `is_valid` not `flag`43- Use domain vocabulary: `invoice`, `order`, not `data`, `item`44- Booleans: prefix with `is_`, `has_`, `can_`, `should_`45- Functions: strong verbs — `parse_config`,46 `validate_input`, `send_notification`47- Python: `snake_case` for functions/variables,48 `PascalCase` for classes, `UPPER_SNAKE` for constants49- No abbreviations unless universally understood (`url`, `id`, `http`)5051## Function Design5253- **Single responsibility**: one function, one job54- **Max 3 parameters**: beyond that, use a dataclass or config object55- **Guard clauses first**: handle invalid cases early with early returns56- **Pure functions preferred**: same input, same output, no side effects57- **20 lines max**: if it does not fit, decompose (see Hard Limits)5859```python60# Good: guard clauses + single responsibility61def calculate_discount(price: float, tier: str) -> float:62 if price <= 0:63 raise ValueError("Price must be positive")64 if tier not in DISCOUNT_TIERS:65 raise ValueError(f"Unknown tier: {tier}")6667 rate = DISCOUNT_TIERS[tier]68 return round(price * rate, 2)69```7071## Error Handling7273- **Never** use bare `except:` or `except Exception:`74- Catch specific exceptions: `except ValueError`, `except KeyError`75- **Fail fast**: validate inputs at boundaries, crash early76- Error messages must be actionable: say what went wrong AND what to do77- Use custom exceptions for domain errors7879```python80# Bad81try:82 process(data)83except:84 pass8586# Good87try:88 process(data)89except ValidationError as e:90 logger.warning("Invalid input: %s", e)91 raise92```9394## Code Structure9596Python project layout:9798```99project/100 pyproject.toml101 src/102 package/103 __init__.py104 module.py105 tests/106 test_module.py107```108109- **Imports**: stdlib first, then third-party, then110 local — separated by blank lines111- **No dead code**: delete unused functions,112 commented-out blocks, and TODO-marked stubs113- **Max 5 functions per file**: split into focused modules (see Hard Limits)114- **One class per file** when the class is non-trivial115116## Testing117118- Test **behavior**, not implementation details119- Descriptive names: `test_expired_token_returns_401` not `test_auth`120- **AAA pattern**: Arrange, Act, Assert — clearly separated121- Cover edge cases: empty inputs, boundaries, error paths122- **Reproduce the bug first**: write a failing test before fixing123124```python125def test_discount_rejects_negative_price():126 with pytest.raises(ValueError, match="positive"):127 calculate_discount(-10, "gold")128```129130## Security131132- **No hardcoded secrets**: use environment variables or a vault133- **Validate all external input**: user data, API payloads, file content134- **Parameterized queries**: never concatenate SQL strings135- **Least privilege**: request minimal permissions, scopes, and access136137## Performance138139- Choose the right data structure: `set` for membership, `dict` for lookup140- Avoid N+1 queries: batch database calls141- Know your complexity: O(n) vs O(n^2) matters at scale142- Paginate large result sets — never return unbounded lists143144## Git Discipline145146- **Atomic commits**: one logical change per commit147- **Conventional commits**: `type(scope): description`148 - Types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`149- Never commit: `.env`, `__pycache__`, `.pyc`, IDE configs, build artifacts150- Write meaningful commit messages that explain WHY, not WHAT151152## Documentation153154- **Code is self-documenting** when names and structure are clear155- Comments explain **WHY**, never WHAT — the code shows WHAT156- Docstrings for public API only (public functions, classes, modules)157- Keep docstrings concise: one-line summary, then params if needed158159```python160def retry(fn, max_attempts=3):161 """Call fn with exponential backoff on failure."""162```163164## Self-Review Checklist165166Before finalizing any code, verify:167168- [ ] All lines under 80 characters169- [ ] All functions under 20 lines170- [ ] All files under 5 functions171- [ ] Names reveal intent172- [ ] No bare except clauses173- [ ] No hardcoded secrets174- [ ] Guard clauses used for validation175- [ ] Tests cover the happy path and edge cases176- [ ] No dead code or commented-out blocks177- [ ] Imports are sorted (stdlib / third-party / local)178179For detailed conventions, refactoring patterns, and API design180guidance, consult `references/detailed-guidelines.md`.181182---183> Converted and distributed by [TomeVault](https://tomevault.io/claim/mhbxyz) — claim your Tome and manage your conversions.184<!-- tomevault:4.0:skill_md:2026-04-14 -->