Agent Skill
2/7/2026

coding-standards

Core coding principles and design aphorisms for writing maintainable code. Use when writing, reviewing, or refactoring code. Use it anytime you need to write code.

L
latitude
3895GitHub Stars
1Views
npx skills add latitude-dev/latitude-llm

SKILL.md

Namecoding-standards
DescriptionCore coding principles and design aphorisms for writing maintainable code. Use when writing, reviewing, or refactoring code. Use it anytime you need to write code.

name: coding-standards description: Core coding principles and design aphorisms for writing maintainable code. Use when writing, reviewing, or refactoring code. Use it anytime you need to write code. license: MIT metadata: author: latitude version: '1.0.0'

Coding Standards

Principles for writing maintainable, debuggable code that stands the test of time.

When to Apply

Reference these guidelines when:

  • Writing new code or reviewing pull requests
  • Debugging issues caused by unclear data flow
  • Designing APIs, method signatures, or data structures
  • Refactoring code for maintainability
  • Deciding how to handle errors and edge cases
  • Managing state in applications

Principles at a Glance

PrincipleCore IdeaKey Rule
Nil ValuesNull means absence, nothing elseNever give semantic meaning to null
Grep TestCode must be findableIf you can't grep it, it's too clever
Data FirstStructure determines codeDesign data structures before algorithms
Stable DependenciesDepend on what's stableDepend on abstractions, not implementations
Loud FailuresHidden bugs are worseIf it can fail, make it fail loudly
Tell, Don't AskObjects own their behaviorDon't query state to make external decisions
Avoid DichotomiesReality is nuancedReject false binary choices
Single Source of TruthState lives in one placeNever derive state from state
Explicit ParametersClarity over clevernessAvoid booleans and hashes as arguments
Task ParametersFresh data in async codePass IDs to tasks, not models

Quick Reference

Null Handling

Bad: Using null to signal a semantic condition

const role = ROLES[user.role] // Returns undefined if not found
processRole(role) // Explodes somewhere far away

Good: Validate at boundaries, use explicit types

const role = ROLES[user.role]
if (!role) throw new Error(`Unknown role: ${user.role}`)
processRole(role)

Findable Code

Bad: Dynamic method dispatch

const method = `handle${eventType}`
this[method](data) // Good luck finding handleUserCreated

Good: Explicit mapping

const handlers = {
  userCreated: this.handleUserCreated,
  userDeleted: this.handleUserDeleted,
}
handlers[eventType]?.(data)

Dependency Direction

Bad: Concrete depends on concrete

class PaymentService {
  private stripe = new StripeClient() // Locked to Stripe forever
}

Good: Depend on abstractions

class PaymentService {
  constructor(private gateway: PaymentGateway) {} // Any gateway works
}

Error Handling

Bad: Silent failures

try {
  await saveUser(user)
} catch (e) {
  // Swallowed silently
}

Good: Fail loudly or handle explicitly

const result = await saveUser(user)
if (result.error) {
  captureException(result.error)
  throw result.error
}

Tell, Don't Ask

Bad: Query state, then act

if (monitor.getValue() > monitor.getLimit()) {
  monitor.triggerAlarm()
}

Good: Let the object decide

monitor.setValue(newValue) // Triggers alarm internally if needed

State Management

Bad: Derived state

const [items, setItems] = useState(props.items) // Copied from props

Good: Single source of truth

const items = props.items // Always read from source

Method Signatures

Bad: Boolean parameter

viewController.present(other, true) // What does true mean?

Good: Explicit methods

viewController.animatePresentation(other)
viewController.immediatelyPresent(other)

Async Tasks

Bad: Passing models to queues

queue.add('processUser', { user }) // Stale by execution time

Good: Pass identifiers

queue.add('processUser', { userId: user.id }) // Fetch fresh data in job

Detailed Guide

Read the GUIDE.md file for comprehensive explanations, rationale, and additional examples for each principle.

Skills Info
Original Name:coding-standardsAuthor:latitude