Skip to content

Code Style Guides

Coding standards and conventions for the Fulcrum codebase.


Overview

Fulcrum is a polyglot codebase using Go for backend services and TypeScript/JavaScript for the dashboard and SDKs. All contributors should follow these style guides to maintain consistency.

Language Guides

Language Primary Use Guide
Go Backend services, gRPC Effective Go standards
TypeScript Dashboard, TypeScript SDK Google TypeScript Style
JavaScript Build tools, scripts Google JavaScript Style

Quick Reference

Go

// Context first, error wrapping, MixedCaps naming
func DoThing(ctx context.Context, tenantID string) (*Result, error) {
    if err := validate(tenantID); err != nil {
        return nil, fmt.Errorf("validation: %w", err)
    }
    // ...
}

TypeScript

// Named exports, const by default, triple equals
export { PolicyEngine };

const evaluator = new PolicyEvaluator();
if (result.status === 'DENIED') {
    // ...
}

Tooling

Language Formatter Linter
Go gofmt / go fmt golangci-lint
TypeScript prettier eslint
JavaScript prettier eslint

Pre-commit Hooks

The repository includes pre-commit hooks that automatically: - Format code with the appropriate formatter - Run linters - Check for secrets


Key Rules (All Languages)

  1. Consistency over preference - Follow existing patterns in the codebase
  2. Clear naming - Names should describe purpose, not implementation
  3. Error handling - Never swallow errors; always handle or propagate
  4. Testing - All public functions require tests
  5. Documentation - Public APIs need JSDoc/godoc comments

See Also


Document Version: 1.0 Last Updated: January 20, 2026