care_fe / rules
Cursor rule664 starsChanged 12 months agoMITView on GitHub
Routes are defined in dedicated API files (*Api.ts) within the corresponding type directory: Legacy routes are defined in src/Utils/api.tsx:
We split this 03-data-fetching.mdc into the rules it gives an agent
3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 11
Use TanStack Query with the query and mutate utilities from @/Utils/request/
- Distinctive: line 12
Use appropriate query keys following the resource pattern
- Very specific: line 124
Use silent: true option to suppress error notifications
≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description:
globs:
alwaysApply: false
---
# Data Fetching and API Guidelines
## TanStack Query Usage
- Use TanStack Query with the `query` and `mutate` utilities from `@/Utils/request/`
- Use appropriate query keys following the resource pattern
- Leverage built-in features for pagination and debouncing
- Implement proper error handling using the global error handler
## API Route Definitions
### Modern Route Pattern
Routes are defined in dedicated API files (`*Api.ts`) within the corresponding type directory:
```typescript
// src/types/user/userApi.ts
export default {
list: {
path: "/api/v1/users/",
method: HttpMethod.GET,
TRes: Type<PaginatedResponse<UserReadMinimal>>(),
},
create: {
path: "/api/v1/users/",
method: HttpMethod.POST,
TRes: Type<UserReadMinimal>(),
TBody: Type<UserCreate>(),
},
} as const;
// src/types/facility/facilityApi.ts
export default {
getFacility: {
path: "/api/v1/facility/{id}/",
method: HttpMethod.GET,
TRes: Type<FacilityRead>(),
},
updateMonetaryComponents: {
path: "/api/v1/facility/{facilityId}/set_monetary_codes/",
method: HttpMethod.POST,
TRes: Type<FacilityRead>(),
TBody: Type<{
discount_codes: Code[];
discount_monetary_components: MonetaryComponentRead[];
}>(),
},
} as const;
```
### Legacy Route Pattern
Legacy routes are defined in `src/Utils/api.tsx`:
```typescript
export const routes = {
auth: {
login: {
path: "/api/v1/auth/login/",
method: "POST",
} as ApiRoute<LoginResponse, never, LoginData>,
logout: {
path: "/api/v1/auth/logout/",
method: "POST",
} as ApiRoute<void>,
},
} as const;
```
## Query Patterns
### Basic Queries
```typescript
const { data } = useQuery({
queryKey: ['users'],
queryFn: query(userApi.list)
});
```
### With Parameters
```typescript
// Path parameters
const { data } = useQuery({
queryKey: ['user', username],
queryFn: query(userApi.get, {
pathParams: { username }
})
});
// Query parameters
const { data } = useQuery({
queryKey: ['facilities', searchTerm],
queryFn: query(facilityApi.getAllFacilities, {
queryParams: { search: searchTerm }
})
});
```
## Mutation Patterns
```typescript
const { mutate: createUser } = useMutation({
mutationFn: mutate(userApi.create),
onSuccess: () => {
queryClient.invalidateQueries(["users"]);
},
});
```
## Error Handling
- Errors are handled globally by default
- Common scenarios are automatically handled:
- Session expiry → Redirects to /session-expired
- Bad requests (400/406) → Shows error notification
- Use `silent: true` option to suppress error notifications
- Custom error handling can be implemented using `onError` callbacks
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 3,978 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- .cursor/rules/01-project-structure.mdcCursor rule
- .cursor/rules/02-coding-standards.mdcCursor rule
- .cursor/rules/04-ui-components.mdcCursor rule
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

