Skip to content
Agentmart
Submit a tool

tanstack-query-patterns

Use TanStack Query v5 patterns in the MultimateAi codebase.

Skill by NarihitoM

IndexedMIT★ 9
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/narihitom-tanstack-query-patterns

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Use TanStack Query v5 patterns in the MultimateAi codebase. Use when: creating queries or mutations, invalidating cache, handling loading/error states, setting up query keys, or configuring staleTime/gcTime.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/tanstack-query-patterns

What's inside

Skill name
tanstack-query-patterns
Description
Use TanStack Query v5 patterns in the MultimateAi codebase. Use when: creating queries or mutations, invalidating cache, handling loading/error states, setting up query keys, or configuring staleTime/gcTime.
License
MIT
Instructions
126 lines in SKILL.md · view on GitHub

Files (1)

  • SKILL.md

SKILL.md (first lines)

# TanStack Query Patterns

## When to Use

- Creating a new `useQuery` or `useMutation` hook
- Debugging stale data or unwanted refetches
- Setting up query key naming conventions
- Handling optimistic updates or cache invalidation

## Global Config

Defined in `src/shared/config/tanstackqueryconfig.ts`:

```typescript
const queryClient = new QueryClient({
  defaultOptions: {
    queries: {
      staleTime: 1000 * 60 * 10, // 10 minutes
      gcTime: 1000 * 60 * 10, // 10 minutes (v5 rename of cacheTime)
    },
  },
});
```

## Query Hook Pattern

Every feature follows this exact shape for data-fetching hooks:

```typescript
import { useQuery } from "@tanstack/react-query";
import { myserviceauth } from "../api/api";

export const useMyServiceAccount = () => {
  return useQuery({
    queryKey: ["myserviceconfig"],
    queryFn: async () => {
      const response = await myserviceauth.fetchConfig();
      return response.success ? response.data : null;
    },
    staleTime: 1000 * 60 * 10,
    gcTime: 1000 * 60 * 10,
    retry: false,
  });
};
```

### Key Rules

- **Query keys**: lowercase hyphenated string, e.g., `['n8nconfig']`, `['user']`, `['chat']`, `['telegramaccount']`, `['slack-messages']`
- **staleTime**: Always 10 minutes (`1000 * 60 * 10`) unless the data must be fresh
- **gcTime**: Match staleTime
- **retry**: Usually `false` — let the UI handle errors via toast
- **queryFn**: Always parse the API response and return the data payload or `null`

## Mutation Hook Pattern

```typescript
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { myserviceauth } from "../api/api";

export const useDisconnectMyService = () => {
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: () => myserviceauth.disconnect(),
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: ["myserviceconfig"] });
    },
    onError: (error: any) => {
      toast.error(error?.response?.data?.message || error.message || "Failed to disconnect");
    },
  });
};
```

### Mutation Patterns by Type

| Action                      | Cache Strategy                                      |
| --------------------------- | --------------------------------------------------- |
| Disconnect / Delete         | `invalidateQueries` — refetch to show updated state |
| Create / Connect            | `invalidateQueries` — refetch list                  |
| Update / Rename             | `setQueryData` — optimistic update preferred        |
| Toggle (e.g., pin, archive) | `setQueryData` for instant UI feedback              |

## Using Hooks in Components

The standard usage pattern in service components:

```typescript
const MyServicePage = () => {
  const { data: config, isLoading, error } = useMyServiceAccount()
  const disconnect = useDisconnectMyService()

  if (isLoading) return <Spinner />
  if (error || !config) return <ConnectForm />

  return (
    <div>
      <ConnectionStatus config={config} />
      <Button onClick={() => disconnect.mutate()}>Disconnect</Button>
    </div>
  )
}
```

## Query Invalidation Map

| Query Key             | Invalidated By                | Effect                    |
| --------------------- | ----------------------------- | ------------------------- |
| `['user']`            | Login, logout, profile update | Refetch current user      |
| `['n8nconfig']`       | Connect, disconnect           | Refetch connection status |
| `['telegramaccount']` | Connect, disconnect           | Refetch connection status |
| `['slackaccount']`    | Connect, disconnect           | Refetch connection status |
| `['notionaccount']`   | Connect, disconnect           | Refetch connection status |
| `['chat']`            | Create, delete chat           | Refetch chat list         |
| `['key']`             | Add, delete service key       | Refetch API keys          |

## Best Practices

From NarihitoM/MultimateAi, MIT.

Signals

Stars
9
Forks
1
Open issues
0
Last commit (this folder)
Jul 23, 2026 (3 months ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from NarihitoM

Cite this page

tanstack-query-patterns skill. Agent Mart. https://agentmart.dev/skills/narihitom-tanstack-query-patterns (last updated 2026-10-24)