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)
- Consistency over preference - Follow existing patterns in the codebase
- Clear naming - Names should describe purpose, not implementation
- Error handling - Never swallow errors; always handle or propagate
- Testing - All public functions require tests
- Documentation - Public APIs need JSDoc/godoc comments
See Also
- Contributing Guide - How to contribute to Fulcrum
- Architecture Decisions - ADRs for major decisions
Document Version: 1.0 Last Updated: January 20, 2026