Skip to content

Commit 99aee06

Browse files
author
Antigravity
committed
Create gemini.md
1 parent 8c2b87e commit 99aee06

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

gemini.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Agent Development Guidelines
2+
3+
## API Documentation Requirement
4+
5+
**IMPORTANT**: Whenever making changes to API endpoints, you MUST update the `api-docs.md` file to reflect those changes.
6+
7+
## When to Update api-docs.md
8+
9+
Update the documentation when:
10+
11+
1. **Creating a new endpoint** - Add full documentation including:
12+
- HTTP method and path
13+
- Authentication requirement (Session, API Key, or Public)
14+
- Request body schema (if applicable)
15+
- Query parameters (if applicable)
16+
- Response schema
17+
- CURL example
18+
19+
2. **Modifying an existing endpoint** - Update:
20+
- Request/response schema changes
21+
- Authentication changes
22+
- New query parameters or body fields
23+
24+
3. **Deleting an endpoint** - Remove the endpoint from documentation
25+
26+
4. **Changing authentication** - Update the `**Authentication**:` line
27+
28+
## Authentication Types
29+
30+
Use one of these authentication labels:
31+
32+
- `**Authentication**: Session or API Key` - Most common for authenticated endpoints
33+
- `**Authentication**: Session or API Key (owner only)` - When ownership is required
34+
- `**Authentication**: Session or API Key (owner or editor)` - Role-based access
35+
- `**Authentication**: None` - Public endpoints
36+
- `**Authentication**: Session` - Session-only endpoints (TTS/STT use this pattern)
37+
38+
## Authentication Implementation
39+
40+
For new authenticated endpoints, use the shared auth utility:
41+
42+
```typescript
43+
import { getAuthenticatedUserId } from '$lib/backend/auth-utils';
44+
45+
export async function GET({ request }: RequestEvent) {
46+
const userId = await getAuthenticatedUserId(request);
47+
// ... endpoint logic
48+
}
49+
```
50+
51+
For optional authentication (public with optional user context):
52+
53+
```typescript
54+
import { tryGetAuthenticatedUserId } from '$lib/backend/auth-utils';
55+
56+
export async function GET({ request }: RequestEvent) {
57+
const userId = await tryGetAuthenticatedUserId(request);
58+
// userId may be undefined if not authenticated
59+
}
60+
```
61+
62+
## Documentation Format
63+
64+
Follow this template when adding a new endpoint:
65+
66+
```markdown
67+
#### METHOD `/api/endpoint-path`
68+
Brief description of what the endpoint does.
69+
70+
**Authentication**: Session or API Key
71+
72+
**Request Body**:
73+
\`\`\`json
74+
{
75+
"field": "type (description)"
76+
}
77+
\`\`\`
78+
79+
**Response**:
80+
\`\`\`json
81+
{
82+
"field": "type"
83+
}
84+
\`\`\`
85+
86+
**CURL Example**:
87+
\`\`\`bash
88+
curl -X METHOD "http://localhost:3432/api/endpoint-path" \
89+
-H "Content-Type: application/json" \
90+
-H "Authorization: Bearer your_api_key" \
91+
-d '{"field": "value"}'
92+
\`\`\`
93+
```
94+
95+
## Reference Files
96+
97+
- API documentation: `api-docs.md`
98+
- Auth utility: `src/lib/backend/auth-utils.ts`
99+
- API endpoints: `src/routes/api/`

0 commit comments

Comments
 (0)