Skip to content

Commit f48065a

Browse files
authored
pimp styleguide (#7324)
1 parent 12378d5 commit f48065a

File tree

1 file changed

+60
-1
lines changed

1 file changed

+60
-1
lines changed

.gemini/styleguide.md

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
Scope: UI code, both React + TypeScript and CSS \
1+
# Gemini Code Assistant – Style Guide
2+
3+
## General
4+
25
Focus: Correctness and Performance \
36
Tone: In your review, be concise, direct and to the point.
47

@@ -7,6 +10,10 @@ Tone: In your review, be concise, direct and to the point.
710
already seen it.
811
- DO NOT introduce yourself.
912

13+
## Frontend / UI
14+
15+
Scope: UI code, both React + TypeScript and CSS \
16+
1017
Rules:
1118

1219
- avoid setting state from useEffect instead of deriving it
@@ -21,3 +28,55 @@ Guidelines:
2128

2229
- keystroke cost: prefer uncontrolled inputs; make controlled loops cheap
2330
- preload wisely: preload only above-the-fold images; lazy-load the rest
31+
32+
## Backend
33+
34+
Scope: Backend code, testing, and tooling
35+
36+
### Best Practices
37+
38+
These are things we want to encourage where it makes sense to avoid headaches in the future.
39+
40+
#### Integration Testing
41+
42+
Adding new functionality to the GraphQL API or another service should come with a set of integration
43+
tests within `/integration-tests` for testing that new component/functionality.
44+
45+
We encourage avoiding testing low-level functionality (e.g., querying the database) if the
46+
functionality can also be verified at a high level (e.g., retrieving the database data via an API
47+
call). For critical features, it is acceptable to test low-level database in output in addition to
48+
high-level output.
49+
50+
#### I/O and Configuration
51+
52+
- Do not access `process.env` directly in your code.
53+
- Define environment variables in `packages/services/*/src/environment.ts` using Zod schemas
54+
- Parse and validate database results or network HTTP calls to services/third-party services using
55+
Zod schemas.
56+
- Avoid using `fetch` or `node-fetch` directly, as it does not have built-in retries
57+
58+
### Anti Patterns
59+
60+
#### Adding new major logic to `/packages/services/storage`
61+
62+
This module is considered legacy. Instead, we now have smaller classes within the corresponding
63+
GraphQL modules that hold the logic for interacting with Postgres.
64+
65+
It is acceptable to alter existing implementations and fix bugs, but adding methods here when
66+
introducing new database tables is discouraged.
67+
68+
## Releasing
69+
70+
We use changesets for versioning.
71+
72+
- Pull requests touching the Hive SDKs need to have a changeset (`/packages/libraries`) for the
73+
corresponding scope.
74+
- The changeset should describe the introduced changes, providing an overview of new API options.
75+
- If needed: Provide examples for migrating from deprecated API options to newly introduced API
76+
options.
77+
- Pull requests touching the services, migrations, or the dashboard (`/packages/migrations`,
78+
`/packages/services`, `/packages/web/app`, `/docker`) should have a changeset for the `hive`
79+
scope.
80+
- These changesets should have the right amount of informational content for someone to understand
81+
what this change introduces for their self-hosted Hive instance, without going into too much
82+
internal technical detail.

0 commit comments

Comments
 (0)