Skip to content

Commit ad7f6d6

Browse files
committed
do not change generated files
1 parent 3aa9fab commit ad7f6d6

File tree

5 files changed

+26
-12
lines changed

5 files changed

+26
-12
lines changed

AGENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ export async function createServer(formData: FormData) {
254254
### ❌ NEVER DO
255255

256256
- **Use `any` type** - STRICTLY FORBIDDEN. Use `unknown` + type guards or proper types
257-
- Edit files in `src/generated/*` (auto-generated)
257+
- **Edit files in `src/generated/*`** - Auto-generated, will be overwritten on regeneration
258258
- Use `'use client'` on every component
259259
- Create manual fetch logic in components
260260
- Use `.then()` promise chains
@@ -274,6 +274,8 @@ export async function createServer(formData: FormData) {
274274

275275
### Using Generated API Client
276276

277+
**⚠️ IMPORTANT: Never edit files in `src/generated/*`** - they are auto-generated and will be overwritten.
278+
277279
**Queries (GET)**:
278280

279281
```typescript

CLAUDE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ This document provides context and guidelines for Claude (and other AI assistant
6868
### 3. Generated API Client
6969

7070
- **Never write manual fetch logic** - Always use hey-api generated hooks
71+
- **Never edit generated files** - They are regenerated from OpenAPI spec and changes will be lost
7172
- API client regenerated from OpenAPI spec via custom script
7273
- Type-safe API calls with automatic loading/error states
7374

@@ -137,7 +138,9 @@ pnpm generate-client:nofetch # Regenerate without fetching
137138
### DON'T ❌
138139

139140
1. **🚫 Don't EVER use `any` type** - STRICTLY FORBIDDEN. Use `unknown` + type guards or proper types
140-
2. **Don't edit generated files** - `src/generated/*` is auto-generated
141+
2. **🚫 Don't EVER edit generated files** - `src/generated/*` is auto-generated and will be overwritten
142+
- Generated files are overwritten on every `pnpm generate-client` run
143+
- If you need to configure or extend the client, do it in your own files
141144
3. **Don't use `'use client'` everywhere** - Only when necessary
142145
4. **Don't create custom fetch logic** - Use hey-api hooks
143146
5. **Don't use `.then()`** - Use async/await

src/app/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from "next";
22
import { Geist, Geist_Mono } from "next/font/google";
33
import { Toaster } from "sonner";
4+
import "@/lib/api-client";
45
import "./globals.css";
56

67
const geistSans = Geist({

src/generated/client.gen.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,4 @@ export type CreateClientConfig<T extends ClientOptions = ClientOptions2> = (
2020
override?: Config<ClientOptions & T>,
2121
) => Config<Required<ClientOptions> & T>;
2222

23-
// Configure client with baseUrl for both SSR and client-side
24-
// In development: points to standalone MSW mock server (http://localhost:9090)
25-
// In production: points to real backend API
26-
const baseUrl = process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:9090";
27-
28-
export const client = createClient(
29-
createConfig<ClientOptions2>({
30-
baseUrl,
31-
}),
32-
);
23+
export const client = createClient(createConfig<ClientOptions2>());

src/lib/api-client.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* API Client Configuration
3+
*
4+
* Configures the hey-api generated client with the correct base URL.
5+
* This must be imported before any API calls are made.
6+
*/
7+
8+
import { client } from "@/generated/client.gen";
9+
10+
// Configure client with baseUrl for both SSR and client-side
11+
// In development: points to standalone MSW mock server (http://localhost:9090)
12+
// In production: points to real backend API
13+
client.setConfig({
14+
baseUrl: process.env.NEXT_PUBLIC_API_BASE_URL || "http://localhost:9090",
15+
});
16+
17+
export { client };

0 commit comments

Comments
 (0)