Conventions
Code conventions and patterns used in this codebase
This guide covers the conventions and patterns used in this codebase to keep things consistent and maintainable.
Feature Directory Structure
Features live in src/features/ and follow a flat-first approach. Only add subfolders when navigating becomes painful.
Guidelines
File Count
Structure
≤ 8 files
Keep flat
9-15 files
Consider subfolders if natural groupings exist
> 15 files
Likely needs ui/, hooks/, server/, etc.
When to Add Subfolders
Add structure only when you have clear logical groupings:
Small features stay flat:
Code Style
Imports
- Prefer the
~alias for imports from the root - In
./packages/*, use relative imports instead
Console Output
Use console.info() instead of console.log():
Node Built-ins
Use the node: prefix for built-in modules:
Comments
Write few, lowercase comments. Code should be self-documenting:
Exports
Prefer named exports over default exports, especially in routes. React Refresh doesn’t support default exports, so named exports ensure HMR works properly. One uses the last export of a file as the page component when there’s no default export:
Environment Variables
Never modify /src/server/env-server.ts directly - it’s auto-generated.
To add new environment variables:
- Add to the
envsection inpackage.json - Run
bun env:update - Optionally add an example value to
.env.development
Verification
After making changes, verify your work:
- Small changes:
bun check:all - Larger changes:
bun run ci --dry-run
Edit this page on GitHub.