start-vibing 2.0.27 → 2.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/template/.claude/CLAUDE.md +74 -0
package/package.json
CHANGED
|
@@ -113,6 +113,80 @@ Project-specific settings are in `.claude/config/`:
|
|
|
113
113
|
|
|
114
114
|
---
|
|
115
115
|
|
|
116
|
+
## HTTP Requests (MANDATORY)
|
|
117
|
+
|
|
118
|
+
All HTTP requests MUST use **axios** with proper configuration.
|
|
119
|
+
|
|
120
|
+
### Base Setup
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
// lib/api/axios.ts - Create a configured axios instance
|
|
124
|
+
import axios from 'axios';
|
|
125
|
+
|
|
126
|
+
export const api = axios.create({
|
|
127
|
+
baseURL: process.env.NEXT_PUBLIC_API_URL || '/api',
|
|
128
|
+
withCredentials: true, // ALWAYS for auth cookies/sessions
|
|
129
|
+
headers: {
|
|
130
|
+
'Content-Type': 'application/json',
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
// Request interceptor for auth tokens
|
|
135
|
+
api.interceptors.request.use((config) => {
|
|
136
|
+
const token = localStorage.getItem('token');
|
|
137
|
+
if (token) {
|
|
138
|
+
config.headers.Authorization = `Bearer ${token}`;
|
|
139
|
+
}
|
|
140
|
+
return config;
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Response interceptor for error handling
|
|
144
|
+
api.interceptors.response.use(
|
|
145
|
+
(response) => response,
|
|
146
|
+
(error) => {
|
|
147
|
+
if (error.response?.status === 401) {
|
|
148
|
+
// Handle unauthorized
|
|
149
|
+
}
|
|
150
|
+
return Promise.reject(error);
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Usage Rules
|
|
156
|
+
|
|
157
|
+
| Rule | Description |
|
|
158
|
+
|------|-------------|
|
|
159
|
+
| ALWAYS use `api` instance | Never raw `axios.get()` or `fetch()` |
|
|
160
|
+
| ALWAYS `withCredentials: true` | Required for cookies/sessions |
|
|
161
|
+
| Extend for specific APIs | Create `api.auth`, `api.payments`, etc. |
|
|
162
|
+
| Type responses | `api.get<UserResponse>('/users')` |
|
|
163
|
+
| Handle errors centrally | Use interceptors, not try/catch everywhere |
|
|
164
|
+
|
|
165
|
+
### When to Create API Wrapper
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// If you call the same endpoint multiple times, create a wrapper:
|
|
169
|
+
// lib/api/users.ts
|
|
170
|
+
export const usersApi = {
|
|
171
|
+
getAll: () => api.get<User[]>('/users'),
|
|
172
|
+
getById: (id: string) => api.get<User>(`/users/${id}`),
|
|
173
|
+
create: (data: CreateUser) => api.post<User>('/users', data),
|
|
174
|
+
update: (id: string, data: UpdateUser) => api.patch<User>(`/users/${id}`, data),
|
|
175
|
+
delete: (id: string) => api.delete(`/users/${id}`),
|
|
176
|
+
};
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### FORBIDDEN
|
|
180
|
+
|
|
181
|
+
| Don't | Do Instead |
|
|
182
|
+
|-------|------------|
|
|
183
|
+
| `fetch('/api/...')` | `api.get('/...')` |
|
|
184
|
+
| `axios.get(...)` | `api.get(...)` |
|
|
185
|
+
| `withCredentials: false` | Always `true` |
|
|
186
|
+
| Inline error handling | Use interceptors |
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
116
190
|
## VETO Power Agents
|
|
117
191
|
|
|
118
192
|
These agents CAN and MUST stop the flow if rules are violated:
|