Back to skills
SKILL.md
Api Patterns
ASecurityConnect Query patterns for API calls. Use when working with mutations, queries, or data fetching.
- 2 stars
- 0 votes
- 0 copies
- 0 views
- Added September 27, 2026
Works with
Security analysis
100/100Pro scans all 5 files and shows the line behind each finding
npx -y skills add David-Li0406/meta-skill-evloving --skill api-patterns --agent claude-codeAre you the author of Api Patterns?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/david-li0406-api-patterns)---
name: api-patterns
description: Connect Query patterns for API calls. Use when working with mutations, queries, or data fetching.
---
# API Patterns
Make API calls with Connect Query and handle responses properly.
## Activation Conditions
- Making API calls
- Using Connect Query hooks
- Cache invalidation
- Mutations and optimistic updates
- Toast notifications for errors
## Quick Reference
| Action | Rule |
|--------|------|
| Fetch data | `use-connect-query.md` |
| After mutation | `api-invalidate-cache.md` |
| Handle errors | `api-toast-errors.md` (use `formatToastErrorMessage` in onError) |
| Protobuf files | `protobuf-no-edit.md` |
## Key Locations
| Location | Purpose |
|----------|---------|
| `/src/react-query/` | Connect Query hooks |
| `/src/protogen/` | Generated protos (DO NOT EDIT) |
Regenerate protos: `task proto:generate` (from repo root)
## Basic Patterns
### Query
```typescript
import { useQuery } from '@connectrpc/connect-query';
import { getUser } from 'protogen/user-UserService_connectquery';
const { data, isLoading, error } = useQuery(
getUser,
{ id: userId },
{ enabled: !!userId }
);
```
### Mutation
```typescript
import { useMutation } from '@connectrpc/connect-query';
import { createUser } from 'protogen/user-UserService_connectquery';
const mutation = useMutation(createUser, {
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['getUser'] });
},
});
mutation.mutate({ name, config });
```
## Rules
See `rules/` directory for detailed guidance.
Files in this skill
- SKILL.md
- rules/api-invalidate-cache.md
- rules/api-toast-errors.md
- rules/protobuf-no-edit.md
- rules/use-connect-query.md
Attribution
Comments
Loading comments…