the-frontend-testing-skill / example-app-vitest-browser
CLAUDE.md13 starsChanged 26 days agoMITView on GitHub
These instructions are for AI assistants working in this project. Always open @/openspec/AGENTS.md when the request: Use @/openspec/AGENTS.md to learn: Keep this managed block so 'openspec update' can refresh the instructions.
In this repository18 other files it gives its agents.
- .claude/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- example-app-playwright/AGENTS.mdAGENTS.md
- example-app-vitest-browser/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- example-app-playwright/CLAUDE.mdCLAUDE.md
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-bulk-archive-changeSkill
- openspec-continue-changeSkill
- openspec-exploreSkill
- openspec-ff-changeSkill
- openspec-new-changeSkill
- openspec-onboardSkill
- openspec-sync-specsSkill
- openspec-verify-changeSkill
- practica-brand-designSkill
- skill-maintenanceSkill
- vercel-react-best-practicesSkill
The file
Show its rules and text
We split this CLAUDE.md into the rules it gives an agent
38 rules. About 0 are common, 25 are distinctive, and 13 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈25
Distinctive · estimate
This author's own choices. Worth a look.
13
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 7
Always open @/openspec/AGENTS.md when the request:
- Very specific: line 13
Use @/openspec/AGENTS.md to learn:
- Distinctive: line 19
Keep this managed block so 'openspec update' can refresh the instructions.
- Distinctive: line 29
When unsure about implementation details, requirements, or business logic, ALWAYS consult the developer rather than making assumptions.
- Very specific: line 47
Always start with planning the work unless requested not to do it.
- Distinctive: line 49
If the task requires external knowledge or certain package, also research to get latest knowledge (Use Task tool for research).
- Distinctive: line 50
Don't over plan it, always think MVP.
- Very specific: line 56
After you complete tasks in .claude/tasks/TASK_NAME.md, you should update and append detailed descriptions of the changes you made, so …
- Very specific: line 62
Locate Anchors First: Before scanning, check for existing AIDEV-* anchors in relevant subdirectories.
- Distinctive: line 63
No Broad Scans: Avoid scanning unreferenced files unless the user explicitly permits it.
- Distinctive: line 64
Handle Insufficient Information: If referenced files lack context, state: "Insufficient information in provided files." Suggest specific …
- Very specific: line 138
Fixture pattern: - Test data generation in test-lib/fixtures/
- Very specific: line 141
Centralized API: - All API logic consolidated in src/lib/api/ with endpoint-based organization
- Very specific: line 187
Add specially formatted comments throughout the codebase, where appropriate, for yourself as inline knowledge that can be easily grepped …
- Very specific: line 189
Use AIDEV-NOTE:, AIDEV-TODO:, or AIDEV-QUESTION: (all-caps prefix) for comments aimed at AI and developers.
- Distinctive: line 190
Keep them concise (≤ 120 chars).
- Very specific: line 191
Before scanning files, always first try to grep for existing anchors AIDEV-* in prompt's referenced files or relevant files/subdirectories.
- Distinctive: line 192
Update relevant anchors: when modifying associated code.
- Distinctive: line 194
Make sure to add relevant anchor comments, whenever a file or piece of code is:
- Distinctive: line 205
Always follow the existing structure and formatting of referenced files.
- Distinctive: line 206
Do not add comments to code unless explicitly requested.
- Distinctive: line 207
Always use async/await for async code.
- Distinctive: line 208
Always use try/catch blocks for async operations.
- Distinctive: line 212
If TypeScript inference can do the job, use it instead of explicit types.
- Distinctive: line 213
Follow functional programming principles where possible, especially prefer immutability and pure functions.
- Distinctive: line 214
Prefer type over interface unless the user explicitly requests an interface.
- Distinctive: line 215
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access if needed.
- Very specific: line 216
Avoid using any type. If necessary, use unknown instead.
- Distinctive: line 220
Use functional components with hooks.
- Very specific: line 221
If a complicated useEffect is generated, create a custom hook instead.
- Very specific: line 222
Always prefix custom hooks with use
- Distinctive: line 223
Keep components small and focused.
- Distinctive: line 225
When editing/adding styles, look for available API of Chakra UI.
- Distinctive: line 240
Test meaningful scenarios that could realistically occur in production
- Distinctive: line 241
Keep test scenarios focused on single responsibilities
- Distinctive: line 242
Avoid redundant edge cases like:
- Distinctive: line 254
Use the frontend testing skill for any code editing, whether big or small.
- Distinctive: line 256
When using the test skill and the test planner - pass it the folder that is used to plan tasks so it can reuse it and put inside also the …
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
<!-- OPENSPEC:START -->OpenSpec Instructions
These instructions are for AI assistants working in this project.
Always open @/openspec/AGENTS.md when the request:
- Mentions planning or proposals (words like proposal, spec, change, plan)
- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
- Sounds ambiguous and you need the authoritative spec before coding
Use @/openspec/AGENTS.md to learn:
- How to create and apply change proposals
- Spec format and conventions
- Project structure and guidelines
Keep this managed block so 'openspec update' can refresh the instructions.
<!-- OPENSPEC:END -->CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Golden Rules
- When unsure about implementation details, requirements, or business logic, ALWAYS consult the developer rather than making assumptions.
- We optimize for maintainability over cleverness. When in doubt, choose the boring solution.
| #: | AI may do | AI must NOT do |
| G-0 | Whenever unsure about something that's related to the project, ask the developer for clarification before making changes. | ❌ Write changes or use tools when you are not sure about something project-specific, or if you don't have context for a particular feature/decision. |
| G-1 | Generate code only inside relevant source directories (e.g., src/features/ for features, src/lib/api/ for the API, src/pages/ for composing feature-wise components), or explicitly pointed files. | ❌ Touch files beyond src, or any *.stories.tsx / *.test.tsx / *.test.ts files (humans own tests & specs), unless requested. |
| G-2 | Add/update AIDEV-NOTE: anchor comments near non-trivial edited code. | ❌ Delete or mangle existing AIDEV- comments. |
| G-3 | Follow lint/style configs (.prettierrc, .eslint.config.mjs). Use the project's configured linter, if available, instead of manually re-formatting code. | ❌ Re-format code to any other style. |
| G-4 | For changes >300 LOC or >3 files, ask for confirmation. | ❌ Refactor large modules without human guidance. |
| G-5 | Stay within the current task context. Inform the dev if it'd be better to start afresh. | ❌ Continue work from a prior prompt after "new task" – start a fresh session. |
| G-6 | Modify API contracts only with explicit developer approval and clear documentation. | ❌ Change API contracts (e.g., endpoints, DTOs, mapping logic) without approval. |
| G-7 | Use git commands only when explicitly requested by the developer. | ❌ Stage, commit, or push changes without explicit developer request. |
Plan & Review
Before starting work
- Always start with planning the work unless requested not to do it. After getting the plan, never present it in the chat, write it to .claude/tasks/TASK_NAME.md instead.
- The plan should be a detailed implementation plan and the reasoning behind them, as well as tasks broken down.
- If the task requires external knowledge or certain package, also research to get latest knowledge (Use Task tool for research).
- Don't over plan it, always think MVP.
- Once you write the plan, firstly ask me to review it. Do not start implementation until I approve the plan.
While implementing
- You should update the plan in .claude/tasks/TASK_NAME.md as you work.
- After you complete tasks in .claude/tasks/TASK_NAME.md, you should update and append detailed descriptions of the changes you made, so following tasks can be easily hand over to other engineers.
- In case of lint errors/warnings, use
pnpm lint --fixto resolve them.
Scanning Repository
- Use Only Referenced Files: Analyze, generate code, or match patterns using only files explicitly mentioned in the user's prompt. [Important]
- Locate Anchors First: Before scanning, check for existing
AIDEV-*anchors in relevant subdirectories. [Important] - No Broad Scans: Avoid scanning unreferenced files unless the user explicitly permits it.
- Handle Insufficient Information: If referenced files lack context, state: "Insufficient information in provided files." Suggest specific files or details needed, e.g., "Please provide 'src/features/auth/[file_name]' or clarify expected behavior."
Essential Commands
Essential Commands
pnpm dev- Start development server on port 5173pnpm lint- Run ESLint with flat configpnpm lint --fix- Run ESLint and fix linting errors/warningspnpm test- Run all tests (unit + storybook)pnpm test:unit- Run unit tests onlypnpm test:storybook- Run storybook tests onlypnpm test:coverage- Run tests with coverage reportpnpm storybook- Start Storybook development server on port 6006
CI Commands
pnpm test:unit:ci- Run unit tests with coverage and reports for CIpnpm test:storybook:ci- Run storybook tests with coverage and reports for CI
Package Manager
This project uses PNPM as the package manager. Always use pnpm commands, not npm or yarn.
Architecture Overview
This is a React SPA built with Vite using feature slice based architecture with clean architecture principles.
Core Technologies
- React 19 with TypeScript
- Vite 7 for build tooling
- React Query (TanStack Query) for data fetching
- React Router 7 for routing
- i18next for internationalization
- MSW 2 for API mocking
- Vitest 3 for testing
- Storybook 9 for component development
- Zustand for state management
- Chakra UI for components
Project Structure
src/
├── app/ # App-level configuration (App.tsx, Providers.tsx)
├── features/ # Feature modules using feature slice architecture
│ ├── auth/ # Authentication feature
│ ├── carts/ # Shopping cart feature
│ ├── products/ # Product catalog feature
├── lib/ # Shared libraries and utilities
│ ├── api/ # Centralized API layer (queries, commands, DTOs)
│ ├── components/ # Reusable UI components
│ ├── http/ # HTTP client and error handling
│ ├── i18n/ # Internationalization setup
│ ├── router/ # Routing utilities
│ └── theme/ # Theme configuration
├── pages/ # Route-level page components composing feature components & logic
└── test-lib/ # Testing utilities and fixturesFeature Architecture
Each feature follows feature slice architecture patterns with three layers:
- presentation/ - UI components, UI-wise hooks
- application/ - Business logic, state management, logic-wise hooks
- infrastructure/ - Data fetching, external APIs, contracts, DTOs
- types/ - Type definitions
Key Patterns
- Co-location - Related files (component + story + test) are grouped together
- MSW handlers - API mocking is centralized in
test-lib/handlers/ - Fixture pattern - Test data generation in
test-lib/fixtures/ - Strong typing - Comprehensive TypeScript usage with branded types
- Component Composition: Features export composed components for pages to use,
- Centralized API - All API logic consolidated in
src/lib/api/with endpoint-based organization
Path Resolution
- Uses
@/*path mapping for clean imports fromsrc/ - Example:
import { Button } from '@/shared/components/button'
Testing Strategy
- Unit tests -
.test.ts/.test.tsxfiles alongside source code - Storybook tests -
.stories.tsxfiles alongside components - MSW integration - Mocked APIs for both development and testing
- Coverage reporting - Istanbul coverage with LCOV reports
State Management
- Zustand stores - For complex local state (auth, modals, etc.)
- React Query - For server state and caching
- React state - For simple component state
Routing
- File-based routing - Pages in
src/pages/with corresponding loaders - Strong typing - Route paths defined in
lib/router/routes.ts - Lazy loading - Components loaded on demand with error boundaries
Error Handling
- Using
react-error-boundaryfor unexpected components runtime errors
Build Optimization
- Lazy loading and code splitting based on
react-router - Using direct imports instead of default
Code Style and Patterns
Code Style
- Formatting: Prettier with 80-char lines
- Imports: sorted with eslint-plugin-import
- Components, providers:
PascalCase, co-located with their testsPascalCase.stories - Hooks, functions, classes, contexts:
kebab-case, co-located with their testskebab-case.test
Anchor comments
Add specially formatted comments throughout the codebase, where appropriate, for yourself as inline knowledge that can be easily grepped for.
- Use
AIDEV-NOTE:,AIDEV-TODO:, orAIDEV-QUESTION:(all-caps prefix) for comments aimed at AI and developers. - Keep them concise (≤ 120 chars).
- Before scanning files, always first try to grep for existing anchors
AIDEV-*in prompt's referenced files or relevant files/subdirectories. [Important] - Update relevant anchors when modifying associated code.
- Do not remove
AIDEV-NOTEs without explicit human instruction. - Make sure to add relevant anchor comments, whenever a file or piece of code is:
- too complex, or
- very important, or
- confusing, or
- could have a bug
Code Standards
General
- Preserve the original structure and formatting of the user's input.
- Always follow the existing structure and formatting of referenced files.
- Do not add comments to code unless explicitly requested. If needed, focus on better var/function names instead.
- Always use async/await for async code.
- Always use try/catch blocks for async operations.
Typescript
- If TypeScript inference can do the job, use it instead of explicit types.
- Follow functional programming principles where possible, especially prefer immutability and pure functions.
- Prefer type over interface unless the user explicitly requests an interface.
- Use optional chaining (?.) and nullish coalescing (??) operators for safe property access if needed.
- Avoid using
anytype. If necessary, useunknowninstead.
React
- Use functional components with hooks.
- If a complicated
useEffectis generated, create a custom hook instead. - Always prefix custom hooks with
use - Keep components small and focused.
- Try to separate JSX and custom styles from logic.
- When editing/adding styles, look for available API of Chakra UI.
Testing Discipline
⚠️ MANDATORY: When writing or modifying tests, you MUST follow all rules from the frontend-testing skill. These docs contain comprehensive testing guidelines including the 6 most important rules (the-test-anatomy.md), test structure, assertions, mocking, and DOM testing patterns. Violations should be reported by bullet number.
| What | AI CAN Do | AI MUST NOT Do |
| Implementation | Generate business logic | Touch test files |
| Test Planning | Suggest test scenarios | Write test code |
| Debugging | Analyze test failures | Modify test expectations |
Test Case Scenarios Preference
- Focus on business logic and domain requirements, not implementation details
- Test meaningful scenarios that could realistically occur in production
- Keep test scenarios focused on single responsibilities
- Avoid redundant edge cases like:
- Empty arrays when "not found" is already tested
undefinedcollections when the type system prevents this- Multiple variations of the same error condition
- Prioritize tests for:
- Happy path scenarios with realistic data
- Error conditions that users might encounter
- Edge cases that affect business logic (not just code coverage)
- Each test should verify distinct behavior, not just different ways to trigger the same code path
Testing
Use the frontend testing skill for any code editing, whether big or small. This project has a strict, opinionated, and regulated testing workflow that should never be discarded — specifically, follow the Double Gate 🌉 principle in every plan.
When using the test skill and the test planner - pass it the folder that is used to plan tasks so it can reuse it and put inside also the test context
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

