React Vite Production UI
Production-grade guidance for building, modifying, reviewing, debugging, and maintaining React + Vite applications with vibrant UI, animations, and components.
What it does
Production-grade guidance for building, modifying, reviewing, debugging, and maintaining React + Vite applications with vibrant UI, animations, and components.
- Category
- frontendreactviteui
- Platforms
- web
- Frameworks and tools
- reactvite
Permissions summary
Files
Reads files only
Shell
No shell commands
Network
No network
Permissions are declared in the component manifest and compiled into each client's tool list. Components are built for least privilege.
Supported environments
| Client | Support | Installed as |
|---|---|---|
| Claude Code | Native | .claude/skills/<id>/SKILL.md |
| OpenAI Codex | Adapter | .codex/skills/<id>/SKILL.md |
| Cursor | Adapter | .cursor/rules/<id>.mdc |
| VS Code (Copilot) | Adapter | .github/instructions/<id>.instructions.md |
| Generic markdown | Adapter | docs/forgekit/skills/<id>.md |
Claude Code is the native reference. Other clients use adapters, so behaviour is close but not identical. See the compatibility matrix.
Full skill (free preview)
This is a free component, so its complete content is public. It is exactly what gets installed (before client-specific formatting).
React + Vite Production Skill
1. Core Objective
Build and maintain React + Vite applications that are:
- Production-ready
- Responsive across mobile, tablet, and desktop
- Maintainable and modular
- Accessible
- Performant
- Secure
- Easy to test and deploy
- Consistent with the existing project architecture
The highest priority is to preserve existing functionality while making the smallest safe change required by the task.
2. First: Inspect Before Editing
Before changing code:
- Inspect
package.json. - Inspect the Vite configuration.
- Inspect the source tree.
- Identify the application entry point.
- Identify routing.
- Identify state management.
- Identify API/service layers.
- Identify UI/component conventions.
- Check existing Tailwind/shadcn configuration if present.
- Check environment variable usage.
- Check existing lint/build/test scripts.
- Search for existing components before creating duplicates.
Do not assume the project uses a specific library just because it is common.
Prefer existing project conventions over introducing new dependencies.
3. Technology Defaults
When the project is new and no stack has been specified, prefer:
- React
- Vite
- TypeScript
- Tailwind CSS
- shadcn/ui where appropriate
- Lucide React icons
- React Router for routing
- TanStack Query for server state
- Zustand for lightweight client/global state
- React Hook Form + Zod for complex forms
Do not install a dependency when the requirement can reasonably be implemented with the existing stack.
For an existing project, preserve the current stack unless there is a strong reason to change it.
4. Project Structure
Prefer a feature-oriented structure for medium/large applications:
src/
├── app/
│ ├── App.tsx
│ ├── routes.tsx
│ └── providers.tsx
├── assets/
├── components/
│ ├── ui/
│ └── shared/
├── features/
│ ├── auth/
│ │ ├── components/
│ │ ├── hooks/
│ │ ├── services/
│ │ ├── types.ts
│ │ └── validation.ts
│ └── dashboard/
├── hooks/
├── layouts/
├── lib/
├── pages/
├── services/
├── stores/
├── types/
├── utils/
├── constants/
├── main.tsx
└── index.css
For small applications, avoid unnecessary abstraction.
Do not create folders merely to make the tree look sophisticated.
5. Components
Create small, reusable components.
Prefer:
function UserCard({ user }: UserCardProps) {
return (...);
}
Avoid giant components containing:
- API calls
- business logic
- complex state
- form validation
- rendering
- navigation
- formatting
all in one file.
Extract logic when it becomes reusable or makes the component difficult to understand.
Do not over-componentize trivial markup.
6. TypeScript
Use TypeScript whenever the project supports it.
Rules:
- Avoid
any. - Prefer explicit interfaces/types for public component props.
- Type API responses.
- Type hook return values when inference is insufficient.
- Use discriminated unions for complex states.
- Avoid unsafe type assertions.
- Do not silence TypeScript errors without understanding the root cause.
Bad:
const data: any = response.data;
Better:
interface User {
id: string;
name: string;
email: string;
}
const data = response.data as User;
Best when possible: validate untrusted API data at the boundary with Zod.
7. State Management
Use the smallest appropriate state mechanism.
Local UI state
Use React state:
const [isOpen, setIsOpen] = useState(false);
Server state
Prefer TanStack Query when installed/appropriate.
Keep API fetching out of presentational components where possible.
Global client state
Use Zustand only when state genuinely needs to be shared.
Do not put every piece of state into global state.
URL state
Use URL query parameters for state that should survive refresh/share/navigation, such as:
- Filters
- Search
- Pagination
- Sort
- Tabs
8. API Architecture
Keep API calls in a service layer.
Example:
src/
├── services/
│ ├── api.ts
│ ├── auth.service.ts
│ └── users.service.ts
Example:
export async function getUsers(): Promise<User[]> {
const response = await api.get<User[]>("/users");
return response.data;
}
Do not scatter raw API URLs throughout components.
Centralize:
- Base URL
- Authentication headers
- Error normalization
- Request configuration
- API client behavior
Never expose private backend secrets in Vite client-side environment variables.
Remember:
Anything bundled into a browser application can potentially be inspected by the user.
Only use VITE_* variables for values that are safe to expose publicly.
9. Environment Variables
Use:
VITE_API_URL=https://api.example.com
Access with:
const apiUrl = import.meta.env.VITE_API_URL;
Do not hard-code environment-specific URLs.
Never put:
- Database passwords
- Private API keys
- JWT signing secrets
- Service-role keys
- Payment provider secret keys
- Private cloud credentials
into frontend environment variables.
10. Routing
Use route-level organization.
Example:
<Route path="/login" element={<LoginPage />} />
<Route path="/dashboard" element={<DashboardPage />} />
For authenticated sections, use a protected layout/route.
Avoid duplicating authentication checks in every page.
Handle:
- Unknown routes
- Loading states
- Unauthorized access
- Redirects
- Nested layouts
11. UI / UX Rules
Every production page should consider:
- Loading state
- Error state
- Empty state
- Success feedback
- Disabled state
- Mobile layout
- Keyboard interaction
- Accessibility
- Long text
- Slow network
- Missing images
- Large datasets
Never leave a blank screen while data is loading.
Prefer skeletons for content-heavy areas.
Use spinners for short actions.
Example:
{isLoading ? (
<UserListSkeleton />
) : users.length === 0 ? (
<EmptyState />
) : (
<UserList users={users} />
)}
12. Responsive Design
Use mobile-first responsive design.
Prefer:
<div className="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4">
Avoid fixed widths that break on smaller screens.
Check at minimum:
- 320px
- 375px
- 768px
- 1024px
- 1280px
- 1440px+
Do not create separate mobile and desktop implementations unless genuinely necessary.
13. Tailwind CSS
Prefer utility classes and existing design tokens.
Avoid excessive arbitrary values when a reusable token/component would be better.
Bad:
className="mt-[13px] ml-[17px] text-[#343434]"
Prefer project tokens:
className="mt-3 text-muted-foreground"
If the project uses shadcn/ui, reuse its components before creating replacements.
Do not modify generated shadcn components unnecessarily.
14. Icons
Prefer Lucide icons when the project uses Lucide.
Example:
import { Search, Plus, Settings } from "lucide-react";
Do not use emoji as UI icons in professional applications unless explicitly requested.
Always provide accessible labels for icon-only buttons:
<Button size="icon" aria-label="Open settings">
<Settings />
</Button>
15. Forms
For simple forms, controlled React inputs may be enough.
For complex forms:
- React Hook Form
- Zod validation
- Clear validation messages
- Submit/loading state
- Server error handling
- Accessible labels
Never rely only on frontend validation for security-sensitive operations.
The backend must validate input independently.
16. Accessibility
Follow WCAG-oriented practices.
Use:
- Semantic HTML
- Proper labels
- Keyboard navigation
- Visible focus states
- Accessible buttons
aria-labelwhere necessary- Correct heading hierarchy
- Sufficient contrast
- Alt text for meaningful images
Do not use:
<div onClick={handleClick}>...</div>
when a button would be appropriate.
Prefer:
<button type="button" onClick={handleClick}>
...
</button>
17. Performance
Avoid premature optimization, but prevent obvious problems.
Watch for:
- Unnecessary re-renders
- Huge component trees
- Duplicate API calls
- Large dependencies
- Unoptimized images
- Rendering huge lists without virtualization
- Expensive calculations on every render
- Memory leaks
- Event listener leaks
- Timers not being cleaned up
Use useMemo and useCallback only when they provide a meaningful benefit.
Do not blindly wrap every function in useCallback.
For large routes/components, consider lazy loading:
const ReportsPage = lazy(() => import("./pages/ReportsPage"));
18. Effects
Do not use useEffect for calculations that can be done during rendering.
Bad:
useEffect(() => {
setTotal(price * quantity);
}, [price, quantity]);
Better:
const total = price * quantity;
When using effects:
- Include correct dependencies.
- Clean up subscriptions/timers/listeners.
- Avoid effects that update state unnecessarily.
- Consider whether the logic belongs in an event handler or data-fetching layer.
19. Error Handling
Never silently swallow errors.
Bad:
try {
await saveUser();
} catch {}
Prefer:
try {
await saveUser();
toast.success("User saved");
} catch (error) {
console.error(error);
toast.error("Unable to save user");
}
Production applications should distinguish:
- Validation errors
- Authentication errors
- Authorization errors
- Network errors
- Server errors
- Unknown errors
Do not expose sensitive backend error details to end users.
20. Authentication
Treat authentication as security-sensitive.
Frontend responsibilities may include:
- Login UI
- Session state
- Route protection
- Logout
- Token/session handling
- User feedback
But never trust the frontend for authorization.
Backend authorization must independently verify:
- Identity
- Role
- Permissions
- Resource ownership
Do not store sensitive tokens insecurely just for convenience.
Prefer secure, server-managed session strategies when supported by the backend architecture.
21. Security
Never:
- Put secrets in frontend code
- Trust client-side authorization
- Inject unsanitized HTML
- Disable security controls to make errors disappear
- Log passwords/tokens
- Commit
.envsecrets - Hard-code production credentials
Be especially careful with:
dangerouslySetInnerHTML
Only use it when content is trusted or properly sanitized.
22. Data Tables
For admin dashboards and business applications, tables should handle:
- Loading
- Empty state
- Pagination
- Search
- Filters
- Sorting
- Row actions
- Responsive behavior
- Error state
For mobile, consider a card/list presentation rather than forcing a wide table.
23. Modals and Dialogs
Dialogs should:
- Have a clear title
- Be keyboard accessible
- Close predictably
- Trap focus appropriately
- Prevent accidental duplicate submissions
- Show loading state during async actions
For destructive actions, require deliberate confirmation.
Example:
Delete customer?
This action cannot be undone.
[Cancel] [Delete]
24. Notifications
Use toast notifications for short-lived feedback.
Examples:
- "Saved successfully"
- "Failed to update"
- "Copied to clipboard"
Do not use toasts as the only place for important information that the user must act on.
25. File Uploads
Handle:
- File type validation
- File size validation
- Upload progress
- Loading state
- Failure state
- Retry
- Preview where appropriate
Never assume the frontend file extension is trustworthy.
Backend validation is mandatory.
26. Dates, Currency, and Numbers
Do not manually format dates/currency inconsistently.
Prefer Intl APIs or an established project utility.
Example:
new Intl.NumberFormat("en-IN", {
style: "currency",
currency: "INR",
}).format(amount);
Use the application's actual locale/currency requirements.
Do not silently change business currency.
27. SEO
For public pages, consider:
- Title
- Description
- Canonical URL
- Open Graph metadata
- Twitter/X metadata
- Semantic HTML
- Crawlable content
- Sitemap
- Robots configuration
Do not add SEO requirements to private/admin pages unnecessarily.
28. Vite Configuration
Keep Vite configuration minimal and intentional.
Example:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
export default defineConfig({
plugins: [react()],
});
Do not add plugins without a reason.
Be careful with:
base- Proxy configuration
- Aliases
- Build output
- Environment modes
When deployment uses a subpath, verify the base configuration and asset URLs carefully.
29. Build and Validation
After meaningful changes, run the available checks.
Typical commands:
npm run lint
npm run typecheck
npm run build
If scripts differ, inspect package.json first.
Before considering the task complete:
- Verify TypeScript.
- Verify linting.
- Verify production build.
- Test the changed functionality.
- Check browser console for errors.
- Check network requests where relevant.
- Check responsive behavior.
Do not claim a build/test passed unless it was actually run.
30. Debugging Workflow
When a bug is reported:
Step 1 — Reproduce
Understand:
- Expected behavior
- Actual behavior
- Exact error
- Browser/device
- Route/page
- Triggering action
Step 2 — Find root cause
Do not immediately patch symptoms.
Trace:
UI
↓
event handler
↓
hook/state
↓
service/API
↓
backend response
↓
state update
↓
render
Step 3 — Make the smallest safe fix
Avoid unrelated refactors.
Step 4 — Verify
Test the original issue plus nearby functionality.
31. Dependency Management
Before installing a package:
- Check whether the functionality already exists.
- Check current dependencies.
- Prefer stable, maintained libraries.
- Avoid duplicate libraries solving the same problem.
Do not replace major dependencies without explicit justification.
32. Git Safety
Never:
- Delete unrelated user changes
- Reset the repository without permission
- Force-push without explicit instruction
- Rewrite history unnecessarily
- Modify unrelated files
Before large changes, inspect:
git status
git diff
Keep changes focused.
When asked to commit, use a clear commit message such as:
feat: add inventory filtering
fix: handle expired auth session
refactor: simplify API client
33. Existing Code Rule
For existing applications:
Preserve existing behavior unless the task explicitly requires changing it.
Before replacing a component, search for all usages.
Before changing a shared utility, search for all callers.
Before changing API response handling, check every consumer.
Avoid "cleanup" that is unrelated to the requested task.
34. UI Implementation Rule
When implementing a design/reference screenshot:
- Inspect existing components.
- Reuse project tokens.
- Match layout hierarchy.
- Match spacing.
- Match typography.
- Match borders/radius/shadows.
- Match responsive behavior.
- Use existing icons/assets where available.
- Do not replace functionality with static mock data unless explicitly requested.
The implementation should look like the provided design while remaining functional.
35. No Fake Functionality
Do not create buttons that appear functional but do nothing.
If a feature is not implemented:
- Connect it to the appropriate action if possible.
- Otherwise clearly mark it as unavailable/coming soon when that is part of the product requirement.
Do not fabricate successful API responses.
36. Avoid Overengineering
Do not introduce:
- Complex architecture for a small feature
- Unnecessary state libraries
- Unnecessary custom hooks
- Excessive abstractions
- Duplicate utility layers
- Large dependency additions
Prefer simple, readable code.
37. Completion Checklist
Before reporting completion:
Code
- Existing architecture inspected
- Existing components reused where appropriate
- No unnecessary files created
- No unrelated code changed
- TypeScript errors resolved
- No obvious
anyabuse
UI
- Responsive
- Loading states
- Empty states
- Error states
- Accessible controls
- Keyboard usable
- Icons have accessible labels where needed
API
- API calls centralized
- Errors handled
- Loading states handled
- Secrets not exposed
Quality
- Lint checked
- Build checked
- Changed functionality tested
- Browser console checked
- No obvious regressions
Git
- Existing changes preserved
- No destructive Git operation performed
- Diff reviewed
38. Response Style for Coding Tasks
When working on a task, report:
- What was changed.
- Which files were changed.
- Any important architectural decisions.
- Validation performed.
- Any remaining issue or limitation.
Do not claim success without verification.
If a command fails, report the actual failure and explain the next action.
39. Golden Rules
- Inspect before editing.
- Reuse before creating.
- Preserve existing functionality.
- Make the smallest safe change.
- Never expose secrets.
- Never trust frontend authorization.
- Handle loading, empty, error, and success states.
- Build mobile-first.
- Keep components understandable.
- Avoid unnecessary dependencies.
- Validate API data at boundaries when practical.
- Test meaningful changes.
- Never hide errors.
- Never fabricate functionality or test results.
- Do not perform destructive Git operations without explicit permission.
Version and changelog
Latest version 1.0.0. Requires DevBuildKit CLI 1.0.0 or newer.
1.0.0: initial release.