adynato-mobile-api
БесплатноБез исполняемых скриптовНе проверенAPI integration patterns for Adynato mobile apps. Covers data fetching with TanStack Query, authentication flows, offline support, error handling, and…
от diegosouzapw★ 68 звёзд на GitHubОб этом скилле
Mobile API Skill
Use this skill when integrating APIs into Adynato mobile apps.
Stack
- Data Fetching: TanStack Query (React Query)
- HTTP Client: Fetch API or Axios
- Auth Storage: expo-secure-store
- Offline: TanStack Query persistence
Setup
Query Client Configuration
// lib/query-client.ts
import { QueryClient } from '@tanstack/react-query'
export const queryClient = new QueryClient({
defaultOptions: {
queries: {
staleTime: 1000 * 60 * 5, // 5 minutes
gcTime: 1000 * 60 * 30, // 30 minutes (formerly cacheTime)
retry: 2,
refetchOnWindowFocus: false, // Mobile doesn't have window focus
},
mutations: {
retry: 1,
},
},
})
Provider Setup
// app/_layout.tsx
import { QueryClientProvider } from '@tanstack/react-query'
import { queryClient } from '@/lib/query-client'
export default function RootLayout() {
return (
<QueryClientProvider client={queryClient}>
<Stack />
</QueryClientProvider>
)
}
API Client
Base Configuration
// lib/api.ts
import * as SecureStore from 'expo-secure-store'
const API_URL = process.env.EXPO_PUBLIC_API_URL
interface RequestOptions extends RequestInit {
requireAuth?: boolean
}
export async function api<T>(
endpoint: string,
options: RequestOptions = {}
): Promise<T> {
const { requireAuth = true, ...fetchOptions } = options
const headers: HeadersInit = {
'Content-Type': 'application/json',
...fetchOptions.headers,
}
if (requireAuth) {
const token = await SecureStore.getItemAsync('auth_token')
if (token) {
headers['Authorization'] = `Bearer ${token}`
}
}
const response = await fetch(`${API_URL}${endpoint}`, {
...fetchOptions,
headers,
})
if (!response.ok) {
const error = await response.json().catch(() => ({}))
throw new ApiError(response.status, error.error || 'Request failed')
}
// Handle 204 No Content
if (response.status === 204) {
return undefined as T
}
return response.json()
}
export class ApiError extends Error {
constructor(public status: number, message: string) {
super(message)
this.name = 'ApiError'
}
}
API Functions
// lib/api/users.ts
import { api } from '@/lib/api'
export interface User {
id: string
email: string
name: string
}
export const usersApi = {
getMe: () => api<{ data: User }>('/api/users/me'),
getById: (id: string) => api<{ data: User }>(`/api/users/${id}`),
update: (id: string, data: Partial<User>) =>
api<{ data: User }>(`/api/users/${id}`, {
method: 'PATCH',
body: JSON.stringify(data),
}),
}
Query Hooks
Basic Query
// hooks/useUser.ts
import { useQuery } from '@tanstack/react-query'
import { usersApi } from '@/lib/api/users'
export function useUser(id: string) {
return useQuery({
queryKey: ['users', id],
queryFn: () => usersApi.getById(id),
enabled: !!id,
})
}
Query with Transform
export function useCurrentUser() {
return useQuery({
queryKey: ['users', 'me'],
queryFn: usersApi.getMe,
select: (response) => response.data, // Extract data from wrapper
})
}
Paginated Query
import { useInfiniteQuery } from '@tanstack/react-query'
export function useUsersList() {
return useInfiniteQuery({
queryKey: ['users', 'list'],
queryFn: ({ pageParam = 1 }) =>
api(`/api/users?page=${pageParam}&limit=20`),
getNextPageParam: (lastPage, pages) => {
if (lastPage.data.length < 20) return undefined
return pages.length + 1
},
initialPageParam: 1,
})
}
Mutations
Basic Mutation
// hooks/useUpdateProfile.ts
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { usersApi } from '@/lib/api/users'
export function useUpdateProfile() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: ({ id, data }: { id: string; data: Partial<User> }) =>
usersApi.update(id, data),
onSuccess: (response, { id }) => {
// Update cache
queryClient.setQueryData(['users', id], response)
queryClient.invalidateQueries({ queryKey: ['users', 'me'] })
},
})
}
Optimistic Update
export function useToggleFavorite() {
const queryClient = useQueryClient()
return useMutation({
mutationFn: (itemId: string) => api(`/api/favorites/${itemId}`, {
method: 'POST'
}),
onMutate: async (itemId) => {
// Cancel outgoing refetches
await queryClient.cancelQueries({ queryKey: ['items', itemId] })
// Snapshot previous value
const previousItem = queryClient.getQueryData(['items', itemId])
// Optimistically update
queryClient.setQueryData(['items', itemId], (old: any) => ({
...old,
isFavorite: !old.isFavorite,
}))
return { previousItem }
},
onError
Установить adynato-mobile-api в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл adynato-mobile-api?
API integration patterns for Adynato mobile apps. Covers data fetching with TanStack Query, authentication flows, offline support, error handling, and optimistic updates in React Native/Expo apps. Use when integrating APIs into mobile applications.
Как установить скилл adynato-mobile-api?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл adynato-mobile-api запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
skill-creator
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an…
от Anthropicdiscernment-nudge
After you give a substantive answer or draft that the user may act on — advice or recommendations, drafted artifacts such as goals, plans, pitches, proposals…
от Anthropicdata-consolidate
Joins the plant's scheduled exports and connector data into one working dataset — ERP items (NetSuite or Infor M3), sales orders, production work orders…
от Anthropicinspection-to-capa
Runs the quality chain end to end: writes the nonconformance against the requirement it violates, searches history at the moment of writing to say whether…
от Anthropic