# Coding Guidelines — BilHej > **Note:** This file is loaded by OpenCode via `AGENTS.md` as an external > instruction source. It is referenced by `opencode.json` instructions. > Keep it current — OpenCode uses it for decision-making. Conventions and standards for the BilHej codebase. These exist to keep the project consistent — especially important as a solo developer returning to the code after weeks or months away. --- ## 1. General Principles - **Readability over cleverness.** Write code you can understand at 2 AM six months from now. - **English for code, Swedish for user-facing strings.** Variable names, comments, commit messages: English. UI text, error messages shown to users, templates: Swedish. - **No commented-out code.** Delete it. Git history keeps it if needed. - **Keep functions small.** A function should do one thing. If it's over 30 lines, it probably does too much. - **No magic numbers.** Use named constants or enums. - **Treat warnings as mistakes.** LSP diagnostics, compiler warnings, and lint warnings are bugs. Never commit code that produces them. If a warning is a known false positive (e.g. Lombok `@RequiredArgsConstructor` triggering "uninitialized final field"), suppress it explicitly at the narrowest scope with a comment explaining why: - Java: `@SuppressWarnings("...") // Lombok generates constructor` - TypeScript: `// @ts-expect-error — pinia getActivePinia returns null in test context` Uncommented suppressions are indistinguishable from ignoring a real problem and are treated as errors. --- ## 2. Git ### Branch Model Three permanent branches, plus short-lived work branches: ``` master ──────────────────────────────────────●──● (production, deployed) ↗ ↗ develop ────────●──────────●────────●───────●──● (integration) ↗ ↗ ↗ feature/foo ──●──●──●───→┘ │ │ feature/bar ───────────────────────●──●─────→┘ ``` | Branch | Purpose | Branches from | Merges to | |--------|---------|---------------|-----------| | `master` | Production — what runs on the server | — | — | | `develop` | Integration — all work branches land here | `master` | `master` (on release) | | `feature/*` | New feature work | `develop` | `develop` | | `fix/*` | Bug fix | `develop` | `develop` | | `chore/*` | Maintenance, upgrades, docs | `develop` | `develop` | ### Rules - **Never commit directly to `master` or `develop`.** All work happens in feature/fix/chore branches. - **Merge strategy**: fast-forward or merge — either is fine for a solo dev project. Prefer simple over complex. - **Keep branches short-lived.** Merge back to `develop` within a few days. Don't let branches drift. - **Update before merging.** Pull latest `develop` into your branch before merging back to avoid surprises. - **Tag releases on `master`**: `v0.1.0`, `v0.2.0`, etc. These mark deployable states. - **Rebase**: only rebase your own unpublished branches. Once pushed/shared, merge instead. - **CI triggers**: push to `develop` → run tests. Push to `master` → run tests + deploy. - **Squash trivial fix commits** before pushing (typo fixes, formatting, etc.). - **Never commit `.env`, credentials, or secrets. `.env.example` only.** ### Branch Naming ``` feature/plate-lookup fix/stripe-webhook-timeout chore/upgrade-spring-boot-3.3 ``` ### Commit Messages ``` : feat: add license plate input component with validation fix: handle empty response from Transportstyrelsen lookup refactor: extract letter preview into composable chore: bump vue to 3.5 ``` Types: `feat`, `fix`, `refactor`, `chore`, `docs`, `test`, `style` --- ## 3. Frontend — Vue.js 3 ### File Naming | Type | Convention | Example | |--------------|-----------------------------|----------------------------------| | Page | PascalCase, in `pages/` | `HomePage.vue`, `OrderHistoryPage.vue` | | Component | PascalCase, in `components/`| `PlateInput.vue`, `LetterPreview.vue` | | Composable | camelCase, `use` prefix | `useAuth.ts`, `usePayment.ts` | | Store | camelCase, in `stores/` | `authStore.ts`, `orderStore.ts` | | API module | camelCase, in `api/` | `orders.ts`, `templates.ts` | ### Component Structure ```vue ``` ### Conventions - Use `