Cursor rule
front/.cursor/rules/workflow.mdcCursor rules
Quality
77/100
Scores the file, not the repository.Length
1,006 words
24 headings · 7 code blocksRepository
47
— · pushed 336 days agoLast changed
3 days ago
First indexed 3 days ago.12345# Frontend Development Workflow67## Architecture89This project uses Next.js with Firebase integration and Material-UI components. The architecture follows a component-based pattern with clear separation of concerns between presentation, business logic, and data management.1011## Primary Rules1213Below are the rules that you must follow when developing frontend functionality:1415### Template and Components1617- Use Material-UI components as the foundation18- Explore MUI documentation for ready-to-use components before creating custom ones19- Mix components from different MUI versions if necessary (with caution)20- Keep unused template components during early development stages21- Make components reusable but maintainable and understandable2223### Theme and Context2425- Customize application through theme context (`ThemeProvider`)26- Use separate contexts for different themes if needed (app theme, widget theme)27- Place theme contexts at the appropriate level (top-level for app, specific for widgets)28- Disable CssBaseline for widget themes to avoid style conflicts29- Always use theme variables for styling (colors, spacing, typography)30- Add custom colors in theme configuration (e.g., `theme.palette.customColors.primaryDark`)3132### User Experience (UX)3334- **Always** adopt the perspective of a critical user35- Use `LoadingScreen` or skeletons for loading states36- Display `EmptyContent` component for empty tables/lists37- Use `LoadingButton` for form actions (`loading={isSubmitting}`)38- Show informative error messages using snackbar notifications39- Ensure the app is self-explanatory - users should never wonder "what's happening?"40- Test on various mobile devices and large screens41- Use `100dvh` instead of `100vh` for mobile compatibility4243### Code Quality4445- Balance code quality with development speed46- Add comments where logic is complex47- Use TypeScript strictly - avoid 'any' type48- Keep functions and components focused (single responsibility)49- Use proper error boundaries and error handling5051### State Management5253- Use React Context for global state (avoid Redux unless necessary)54- Leverage Firebase real-time listeners for live data55- Use local state for component-specific data56- Implement optimistic UI updates where appropriate5758### Performance Optimization5960- Use `useCallback` and `useMemo` efficiently61- Pay attention to dependency arrays in hooks62- Lazy load components when appropriate63- Implement proper code splitting6465### Authorization6667- Use auth context with `onAuthStateChanged`68- Use `AuthGuard` for protected content69- Always show loading indicators during auth processes70- Handle auth errors gracefully7172## Workflow7374When building new features, follow this systematic workflow:7576### 0. Planning Phase7778Before starting, create a comprehensive to-do list following this exact process:7980- Understand the feature requirements81- Identify affected components and pages82- List all necessary UI components83- Plan the data flow and state management84- Consider edge cases and error states8586### 1. Design Analysis8788- Review existing components that can be reused89- Identify new components that need to be created90- Plan responsive behavior for all screen sizes9192### 2. Component Development9394```tsx95// Start with the component structure96// components/features/NewFeature.tsx97import { useState, useEffect } from "react";98import { Box, Paper, Typography, Skeleton } from "@mui/material";99import { useAuth } from "@/auth/useAuth";100import { useSnackbar } from "notistack";101102export function NewFeature() {103 const [loading, setLoading] = useState(true);104 const [data, setData] = useState(null);105 const { user } = useAuth();106 const { enqueueSnackbar } = useSnackbar();107108 // Always handle loading states109 if (loading) {110 return <Skeleton variant="rectangular" height={200} />;111 }112113 // Always handle empty states114 if (!data) {115 return <EmptyContent title="No data available" />;116 }117118 return <Paper sx={{ p: 3 }}>{/* Component content */}</Paper>;119}120```121122### 3. Firebase Integration123124```tsx125// lib/firestore.ts - Define operations126export const dataOperations = {127 async create(data: DataType) {128 try {129 const docRef = await addDoc(collections.data, data);130 return docRef.id;131 } catch (error) {132 console.error("Error creating document:", error);133 throw error;134 }135 },136137 async getById(id: string) {138 const docRef = doc(collections.data, id);139 const docSnap = await getDoc(docRef);140 return docSnap.exists() ? docSnap.data() : null;141 },142};143144// hooks/useData.ts - Create real-time hook145export function useData(dataId: string) {146 const [data, setData] = useState(null);147 const [loading, setLoading] = useState(true);148149 useEffect(() => {150 const unsubscribe = onSnapshot(151 doc(db, "data", dataId),152 (doc) => {153 setData(doc.exists() ? doc.data() : null);154 setLoading(false);155 },156 (error) => {157 console.error("Error fetching data:", error);158 setLoading(false);159 }160 );161162 return unsubscribe;163 }, [dataId]);164165 return { data, loading };166}167```168169### 4. Form Handling170171```tsx172// Always use controlled components with proper validation173import { useForm, Controller } from "react-hook-form";174import { yupResolver } from "@hookform/resolvers/yup";175import * as yup from "yup";176177const schema = yup.object({178 name: yup.string().required("Name is required"),179 email: yup.string().email("Invalid email").required("Email is required"),180});181182export function DataForm() {183 const {184 control,185 handleSubmit,186 formState: { errors, isSubmitting },187 } = useForm({188 resolver: yupResolver(schema),189 });190 const { enqueueSnackbar } = useSnackbar();191192 const onSubmit = async (data) => {193 try {194 await dataOperations.create(data);195 enqueueSnackbar("Data saved successfully", { variant: "success" });196 } catch (error) {197 enqueueSnackbar(error.message, { variant: "error" });198 }199 };200201 return (202 <form onSubmit={handleSubmit(onSubmit)}>203 <Controller204 name="name"205 control={control}206 render={({ field }) => (207 <TextField208 {...field}209 label="Name"210 error={!!errors.name}211 helperText={errors.name?.message}212 fullWidth213 margin="normal"214 />215 )}216 />217218 <LoadingButton219 type="submit"220 variant="contained"221 loading={isSubmitting}222 fullWidth223 >224 Submit225 </LoadingButton>226 </form>227 );228}229```230231### 5. Testing232233- Check if front end compiles and runs.234-235236## Common Patterns237238### Notification Pattern239240```tsx241const { enqueueSnackbar } = useSnackbar();242243// Success244enqueueSnackbar("Operation successful", { variant: "success" });245246// Error247enqueueSnackbar("Something went wrong", { variant: "error" });248249// Info250enqueueSnackbar("Please note...", { variant: "info" });251```252253### Protected Route Pattern254255```tsx256// Use AuthGuard wrapper257<AuthGuard>258 <ProtectedContent />259</AuthGuard>;260261// Or conditional rendering262const { isAuthenticated } = useAuth();263if (!isAuthenticated) {264 return <Navigate to="/signin" />;265}266```267268## Navigation Rules269270### Next.js Link271272```tsx273// Correct - use href274<Link href="/dashboard">275 <Button>Go to Dashboard</Button>276</Link>277```278279### MUI Link with Navigation280281```tsx282// Correct - use router.push283import { useRouter } from "next/navigation";284285const router = useRouter();286<MuiLink component="button" onClick={() => router.push("/dashboard")}>287 Dashboard288</MuiLink>;289```290291## Debugging Checklist292293When something doesn't work:2942951. Check browser console for errors2962. Verify Firebase configuration2973. Check network tab for API calls2984. Verify authentication state2995. Check component props and state3006. Verify data types match interfaces3017. Check for race conditions3028. Verify cleanup functions in useEffect303
Also in agency-ai-solutions/nextjs-firebase-ai-coding-template
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| agency-ai-solutions/nextjs-firebase-ai-coding-template.cursor/rules/ADR.mdc · 47 | Cursor rules | archgitmonorepo | 50/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-template.cursor/rules/PRD.mdc · 47 | Cursor rules | database | 44/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templateAGENTS.md · 47 | AGENTS.md | no sections | 16/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templateback/.cursor/rules/ADR.mdc · 47 | Cursor rules | testtesting-strategygitdatabase | 52/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templateback/.cursor/rules/backend-workflow.mdc · 47 | Cursor rules | teststyledo-notagent-behaviour | 69/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templateback/.cursor/rules/folder-structure.mdc · 47 | Cursor rules | testarch | 52/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templatefront/.cursor/rules/ADR.mdc · 47 | Cursor rules | teststylearchtypes+3 | 58/100 | 3 days ago | |
| agency-ai-solutions/nextjs-firebase-ai-coding-templatefront/.cursor/rules/folder-structure.mdc · 47 | Cursor rules | stylearchtypesapi+2 | 77/100 | 3 days ago |
Diff against .cursor/rules/ADR.mdc Diff against .cursor/rules/PRD.mdc Diff against AGENTS.md Diff against back/.cursor/rules/ADR.mdc Diff against back/.cursor/rules/backend-workflow.mdc Diff against back/.cursor/rules/folder-structure.mdc Diff against front/.cursor/rules/ADR.mdc Diff against front/.cursor/rules/folder-structure.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
