AgentSkillsCN

frontend-developer

本项目前端开发的最佳实践与指南。

SKILL.md
--- frontmatter
name: frontend-developer
description: Frontend development best practices and guidelines for this project.

Frontend Development Guidelines

Core Rules

RuleDescription
Directory StructureFollow CLAUDE.md strictly
AnimationUse motion/react actively
Data FetchingUse orval-generated clients only
TestingAll utils and hooks MUST have tests
UI ComponentsUse @ding/ui components
i18nAll text uses t() from @ding/i18n

Animation (motion/react)

typescript
import { motion, AnimatePresence } from 'motion/react'
Use CaseApproach
Enter/exit, page transitionsmotion + AnimatePresence
Scroll-linked, gestures, draguseScroll, whileHover, drag
Simple hover/loadingTailwind (transition-*, animate-*)

Data Fetching (orval)

typescript
// Always use generated clients
import { useListTweets, useCreateTweet } from '@/lib/api/generated/tweet/tweet'

// Storybook MSW mocking
import { getListTweetsMockHandler } from '@/lib/api/generated/tweet/tweet.msw'

Storybook + MSW

typescript
import { getListTweetsMockHandler } from '@/lib/api/generated/tweet/tweet.msw'

export const Default: Story = {
  parameters: {
    msw: { handlers: [getListTweetsMockHandler()] },
  },
}

export const Empty: Story = {
  parameters: {
    msw: { handlers: [getListTweetsMockHandler({ tweets: [], meta: { total: 0 } })] },
  },
}
PatternUsage
Default mockgetXxxMockHandler() - faker.js auto-generated
Custom datagetXxxMockHandler({ ...customData })
Response mockgetXxxResponseMock() - get mock data only

Testing

Utils and hooks MUST have tests.

code
utils/formatDate/
├── formatDate.ts
└── formatDate.test.ts    # REQUIRED

hooks/useDebounce/
├── useDebounce.ts
└── useDebounce.test.ts   # REQUIRED

Checklist

  • Directory structure follows CLAUDE.md
  • motion/react for animations
  • orval clients for API calls
  • Tests for utils/hooks
  • t() for all text
  • dark: variants for colors
  • @ding/ui components