add-feature-hook
Creates TanStack Query hooks for API features with authentication. Use when connecting frontend to backend endpoints, creating data fetching hooks.
Best use case
add-feature-hook is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Creates TanStack Query hooks for API features with authentication. Use when connecting frontend to backend endpoints, creating data fetching hooks.
Teams using add-feature-hook should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/add-feature-hook/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How add-feature-hook Compares
| Feature / Agent | add-feature-hook | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Creates TanStack Query hooks for API features with authentication. Use when connecting frontend to backend endpoints, creating data fetching hooks.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Add Feature Hook
Creates TanStack Query hooks for API features with automatic authentication.
## Prerequisites
Generate latest API types (backend must be running):
```bash
cd front && pnpm run generate:api
```
## 3-Layer API Pattern
**NEVER call API directly in components!**
```
Feature Hooks (use-items.ts)
↓ uses
Base Auth Hooks (use-api.ts: useAuthenticatedQuery/Mutation)
↓ uses
Generated SDK (lib/api/*.gen.ts from OpenAPI)
```
## Workflow
### 1. Create Hook File
```typescript
// lib/hooks/use-my-feature.ts
import { useSuspenseQuery, useMutation, useQueryClient } from '@tanstack/react-query';
import { useAuthenticatedQuery, useAuthenticatedMutation } from './use-api';
import {
getMyFeatures,
createMyFeature,
updateMyFeature,
deleteMyFeature,
} from '@/lib/api/sdk.gen';
import type { CreateMyFeatureRequest, MyFeatureResponse } from '@/lib/api/types.gen';
// Query key factory - prevents cache bugs
export const myFeatureKeys = {
all: ['my-feature'] as const,
list: (userId?: string) => [...myFeatureKeys.all, 'list', userId] as const,
detail: (id: string) => [...myFeatureKeys.all, 'detail', id] as const,
};
```
### 2. Add Query Hook
```typescript
// Regular query (for optional data)
export function useMyFeatures(userId?: string) {
return useAuthenticatedQuery({
queryKey: myFeatureKeys.list(userId),
queryFn: async (token) => {
const response = await getMyFeatures({
headers: { Authorization: `Bearer ${token}` },
});
return response.data ?? [];
},
enabled: !!userId,
});
}
// Suspense query (for required data - use in content components)
export function useMyFeaturesSuspense(userId: string) {
return useAuthenticatedQuery({
queryKey: myFeatureKeys.list(userId),
queryFn: async (token) => {
const response = await getMyFeatures({
headers: { Authorization: `Bearer ${token}` },
});
return response.data ?? [];
},
suspense: true, // Enables Suspense mode
});
}
```
### 3. Add Mutation Hooks
```typescript
export function useCreateMyFeature() {
const queryClient = useQueryClient();
return useAuthenticatedMutation({
mutationFn: async (data: CreateMyFeatureRequest, token) => {
const response = await createMyFeature({
headers: { Authorization: `Bearer ${token}` },
body: data,
});
return response.data;
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: myFeatureKeys.all });
},
showSuccessToast: 'Created successfully!',
showErrorToast: true, // Default error handling
});
}
export function useDeleteMyFeature() {
const queryClient = useQueryClient();
return useAuthenticatedMutation({
mutationFn: async (id: string, token) => {
await deleteMyFeature({
headers: { Authorization: `Bearer ${token}` },
path: { id },
});
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: myFeatureKeys.all });
},
showSuccessToast: 'Deleted successfully!',
});
}
```
## Query Key Factory
**Always use query key factories** to prevent cache bugs:
```typescript
export const myFeatureKeys = {
all: ['my-feature'] as const,
list: (userId?: string) => [...myFeatureKeys.all, 'list', userId] as const,
detail: (id: string) => [...myFeatureKeys.all, 'detail', id] as const,
filtered: (filters: Filters) => [...myFeatureKeys.all, 'filtered', filters] as const,
};
```
## Usage in Components
```typescript
// Content component (with Suspense)
function MyFeatureContent({ userId }: { userId: string }) {
const { data } = useMyFeaturesSuspense(userId);
const createMutation = useCreateMyFeature();
const handleCreate = async (data: CreateMyFeatureRequest) => {
await createMutation.mutateAsync(data);
};
return (
<div>
{data.map((item) => <div key={item.id}>{item.name}</div>)}
<button onClick={() => handleCreate({ name: 'New' })}>
Create
</button>
</div>
);
}
```
## Toast Notifications
**Automatic** via `useAuthenticatedMutation`:
- Success: Green toast with custom message
- Error: Automatic error handling with red toast
- 401: Auto-redirect to login
**DO NOT** add manual error handling in components.
## Generated API Types
Types are auto-generated from backend OpenAPI:
```typescript
// Import from generated types
import type { CreateMyFeatureRequest, MyFeatureResponse } from '@/lib/api/types.gen';
// Import API functions
import { getMyFeatures, createMyFeature } from '@/lib/api/sdk.gen';
```
**DO NOT** edit files in `lib/api/` - regenerate instead.Related Skills
feature
Creates a new feature module with minimal viable structure. Use when bootstrapping a new feature from scratch, scaffolding the Tuist module, Container, Feature entry point, DeepLinkHandler, and initial screen with placeholder Text view. Includes all unit tests, mocks, stubs, and app integration. For adding domain/data layers afterward, use /datasource, /repository, /usecase. For enhancing views, use /view, /viewmodel, /navigator.
Data Engineering Data Driven Feature
World-class data science skill for statistical modeling, experimentation, causal inference, and advanced analytics. Expertise in Python (NumPy, Pandas, Scikit-learn), R, SQL, statistical methods, A/B testing, time series, and business intelligence. Includes experiment design, feature engineering, model evaluation, and stakeholder communication.
setup-webhook
Configure Vapi server URLs and webhooks to receive real-time call events, transcripts, tool calls, and end-of-call reports. Use when setting up webhook endpoints, building tool servers, or integrating Vapi events into your application.
implement-feature
Implementa feature nel sistema di fatturazione italiana validando contro normativa fiscale. Usa per aggiungere calcoli IVA, ritenuta d'acconto, split payment, imposta di bollo, gestione fatture PA, regime forfettario, numerazione progressiva, note di credito, o qualsiasi logica che deve rispettare DPR 633/72, DPR 600/73, DPR 642/72. NON usare per bug fix tecnici, refactoring, o modifiche UI senza impatto fiscale.
fullstack-feature
Load PROACTIVELY when task involves building a complete feature across multiple layers. Use when user says "build a feature", "add user profiles", "create a dashboard", or any request spanning database, API, UI, and tests. Orchestrates multi-agent work sequentially: schema and migrations, API endpoints, UI components, tests, and review. The runtime engine handles WRFC chains automatically via <gv> directives. Handles dependency ordering and cross-layer type sharing.
commit-feature
Stage changes, create conventional commit (no co-author), push to origin, and add detailed PR comment with session context
api_feature
Imported skill api_feature from openai
add-feature
Scaffold a new toggleable feature with full structure, storage, API exposure, and bootstrap registration
create-hook
Creates or adds Cursor agent lifecycle hooks. Use when the user asks to create a hook, add a hook, set up a lifecycle hook, or automate something on agent stop, afterFileEdit, afterAgentResponse, or other Cursor hook events. Hooks live in .cursor/hooks/ and are registered in .cursor/hooks.json.
claude-hooks-reference-2026
Complete reference for Claude Code hooks system (January 2026). Use when creating hooks, understanding hook events, matchers, exit codes, JSON output control, environment variables, plugin hooks, or implementing hook scripts.
Agentic Feature Design
Designing features for the "Action Era" that are AI-accessible by default
AgentDB Advanced Features
Master advanced AgentDB features including QUIC synchronization, multi-database management, custom distance metrics, hybrid search, and distributed systems integration. Use when building distributed AI systems, multi-agent coordination, or advanced vector search applications.