mirror of
https://github.com/DeckardGer/tanstack-agent-skills.git
synced 2026-09-14 20:46:35 +08:00
9c57b2b509
Merged unique content (common scenarios, code review checklist) into AGENTS.md. CLAUDE.md now points to AGENTS.md to avoid duplication. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
5.1 KiB
5.1 KiB
Agent Guidelines
This document provides instructions for AI coding agents working with the TanStack Agent Skills repository.
Repository Structure
tanstack-agent-skills/
├── skills/
│ ├── tanstack-query/
│ │ ├── SKILL.md
│ │ └── rules/
│ ├── tanstack-router/
│ │ ├── SKILL.md
│ │ └── rules/
│ ├── tanstack-start/
│ │ ├── SKILL.md
│ │ └── rules/
│ └── tanstack-integration/
│ ├── SKILL.md
│ └── rules/
├── README.md
├── AGENTS.md
└── CLAUDE.md
Skill Format
SKILL.md Structure
Each skill's main file uses YAML frontmatter:
---
name: skill-name
description: Brief description of what this skill covers
---
Followed by markdown sections:
- When to Apply
- Rule Categories by Priority
- Quick Reference
- How to Use
Rule File Naming
Rules use kebab-case with category prefixes:
qk-— Query keyscache-— Cachingmut-— Mutationserr-— Error handlingpf-— Prefetchinginf-— Infinite queriesssr-— SSR patternsperf-— Performancets-— Type safetyorg-— Organizationload-— Data loadingsearch-— Search paramsnav-— Navigationsplit-— Code splittingpreload-— Preloadingctx-— Contextsf-— Server functionssec-— Securitymw-— Middlewareauth-— Authenticationfile-— File organizationdeploy-— Deploymentsetup-— Setupflow-— Data flow
Rule File Structure
# rule-id: Rule Title
## Priority: CRITICAL | HIGH | MEDIUM | LOW
## Explanation
Why this pattern matters and what problem it solves.
## Bad Example
\`\`\`tsx
// Code showing the anti-pattern
// With comments explaining why it's bad
\`\`\`
## Good Example
\`\`\`tsx
// Code showing the recommended pattern
// With comments explaining the approach
\`\`\`
## Context
- When to apply this rule
- When to skip this rule
- Related considerations
Skill Activation
Skills should activate when agents detect:
tanstack-query
- Data fetching code (
useQuery,useMutation) - React Query imports
- Cache management patterns
- Server state handling
tanstack-router
- Route definitions
- Navigation code
- Search params handling
- Code splitting setup
tanstack-start
- Server functions (
createServerFn) - Middleware setup
- SSR configuration
- Authentication flows
tanstack-integration
- Combined Query + Router usage
- Full-stack TanStack applications
- SSR with data prefetching
Priority Levels
| Priority | Meaning |
|---|---|
| CRITICAL | Must follow - violations cause bugs or security issues |
| HIGH | Strongly recommended - improves reliability and performance |
| MEDIUM | Good practice - enhances maintainability and UX |
| LOW | Nice to have - optimization and polish |
Context Efficiency
To minimize token usage:
- Keep individual rule files under 200 lines
- Use concise code examples
- Reference external docs for deep dives
- Only load relevant rules based on context
Applying Rules
When generating or reviewing code:
- Check CRITICAL rules first — These prevent bugs
- Apply HIGH priority patterns — Improve reliability
- Consider MEDIUM patterns — Better UX
- Suggest LOW patterns — When optimizing
Common Scenarios
New TanStack Query Setup
- Load tanstack-query skill
- Apply
qk-factory-patternfor query organization - Apply
cache-stale-timeandcache-gc-time - Set up error boundaries per
err-error-boundaries
New TanStack Router Setup
- Load tanstack-router skill
- Apply
ts-register-routerfor type safety - Apply
org-file-based-routingconventions - Configure preloading per
preload-intent
Adding Server Functions
- Load tanstack-start skill
- Apply
sf-create-server-fnpatterns - Always apply
sf-input-validation - Consider
mw-request-middlewarefor auth
Full-Stack Data Flow
- Load tanstack-integration skill
- Apply
setup-query-client-context - Follow
flow-loader-query-pattern - Configure
cache-single-source
Code Review Checklist
When reviewing TanStack code:
- Query keys are arrays (
qk-array-structure) - All dependencies in query keys (
qk-include-dependencies) - Router types registered (
ts-register-router) - Loaders use ensureQueryData (
load-ensure-query-data) - Search params validated (
search-validation) - Server function inputs validated (
sf-input-validation) - Mutations invalidate queries (
mut-invalidate-queries) - Error boundaries in place (
err-error-boundaries)
Adding New Rules
- Identify the category and create appropriate prefix
- Write clear explanation of the problem/solution
- Provide realistic bad and good examples
- Include context for when to apply
- Assign appropriate priority level
- Update SKILL.md quick reference table