|
| 1 | +# [Project Name] |
| 2 | + |
| 3 | +Every time you choose to apply a rule(s), explicitly state the rule(s) in the output. You can abbreviate the rule description to a single word or phrase. |
| 4 | + |
| 5 | +## Project Context |
| 6 | + |
| 7 | +[Brief description ] |
| 8 | + |
| 9 | +- [more description] |
| 10 | +- [more description] |
| 11 | +- [more description] |
| 12 | + |
| 13 | +## Code Style and Structure |
| 14 | + |
| 15 | +- Write concise, technical TypeScript code with accurate examples |
| 16 | +- Use functional and declarative programming patterns; avoid classes |
| 17 | +- Prefer iteration and modularization over code duplication |
| 18 | +- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError) |
| 19 | + |
| 20 | +## Tech Stack |
| 21 | + |
| 22 | +- React |
| 23 | +- TypeScript |
| 24 | +- Tailwind CSS |
| 25 | +- Shadcn UI |
| 26 | +- Chrome Extension |
| 27 | +- Express.js |
| 28 | + |
| 29 | +## Naming Conventions |
| 30 | + |
| 31 | +- Use lowercase with dashes for directories (e.g., components/form-wizard) |
| 32 | +- Favor named exports for components and utilities |
| 33 | +- Use PascalCase for component files (e.g., VisaForm.tsx) |
| 34 | +- Use camelCase for utility files (e.g., formValidator.ts) |
| 35 | + |
| 36 | +## TypeScript Usage |
| 37 | + |
| 38 | +- Use TypeScript for all code; prefer interfaces over types |
| 39 | +- Avoid enums; use const objects with 'as const' assertion |
| 40 | +- Use functional components with TypeScript interfaces |
| 41 | +- Define strict types for message passing between different parts of the extension |
| 42 | +- Use absolute imports for all files @/... |
| 43 | +- Avoid try/catch blocks unless there's good reason to translate or handle error in that abstraction |
| 44 | +- Use explicit return types for all functions |
| 45 | + |
| 46 | +## Chrome Extension Specific |
| 47 | + |
| 48 | +- Use Manifest V3 standards |
| 49 | +- Implement proper message passing between components: |
| 50 | + ```typescript |
| 51 | + interface MessagePayload { |
| 52 | + type: string; |
| 53 | + data: unknown; |
| 54 | + } |
| 55 | + ``` |
| 56 | +- Handle permissions properly in manifest.json |
| 57 | +- Use chrome.storage.local for persistent data |
| 58 | +- Implement proper error boundaries and fallbacks |
| 59 | +- Use lib/storage for storage related logic |
| 60 | +- For the async injected scripts in content/, |
| 61 | + - they must not close over variables from the outer scope |
| 62 | + - they must not use imported functions from the outer scope |
| 63 | + - they must have wrapped error handling so the error message is returned to the caller |
| 64 | + |
| 65 | +## State Management |
| 66 | + |
| 67 | +- Use React Context for global state when needed |
| 68 | +- Implement proper state persistence using chrome.storage (for extension) |
| 69 | +- Implement proper cleanup in useEffect hooks |
| 70 | + |
| 71 | +## Syntax and Formatting |
| 72 | + |
| 73 | +- Use "function" keyword for pure functions |
| 74 | +- Avoid unnecessary curly braces in conditionals |
| 75 | +- Use declarative JSX |
| 76 | +- Implement proper TypeScript discriminated unions for message types |
| 77 | + |
| 78 | +## UI and Styling |
| 79 | + |
| 80 | +- Use Shadcn UI and Radix for components |
| 81 | +- use `npx shadcn@latest add <component-name>` to add new shadcn components |
| 82 | +- Implement Tailwind CSS for styling |
| 83 | +- Consider extension-specific constraints (popup dimensions, permissions) |
| 84 | +- Follow Material Design guidelines for Chrome extensions |
| 85 | +- When adding new shadcn component, document the installation command |
| 86 | + |
| 87 | +## Error Handling |
| 88 | + |
| 89 | +- Implement proper error boundaries |
| 90 | +- Log errors appropriately for debugging |
| 91 | +- Provide user-friendly error messages |
| 92 | +- Handle network failures gracefully |
| 93 | + |
| 94 | +## Testing |
| 95 | + |
| 96 | +- Write unit tests for utilities and components |
| 97 | +- Implement E2E tests for critical flows |
| 98 | +- Test across different Chrome versions |
| 99 | +- Test memory usage and performance |
| 100 | + |
| 101 | +## Security |
| 102 | + |
| 103 | +- Implement Content Security Policy |
| 104 | +- Sanitize user inputs |
| 105 | +- Handle sensitive data properly |
| 106 | +- Follow Chrome extension security best practices |
| 107 | +- Implement proper CORS handling |
| 108 | + |
| 109 | +## Git Usage |
| 110 | + |
| 111 | +Commit Message Prefixes: |
| 112 | + |
| 113 | +- "fix:" for bug fixes |
| 114 | +- "feat:" for new features |
| 115 | +- "perf:" for performance improvements |
| 116 | +- "docs:" for documentation changes |
| 117 | +- "style:" for formatting changes |
| 118 | +- "refactor:" for code refactoring |
| 119 | +- "test:" for adding missing tests |
| 120 | +- "chore:" for maintenance tasks |
| 121 | + |
| 122 | +Rules: |
| 123 | + |
| 124 | +- Use lowercase for commit messages |
| 125 | +- Keep the summary line concise |
| 126 | +- Include description for non-obvious changes |
| 127 | +- Reference issue numbers when applicable |
| 128 | + |
| 129 | +## Documentation |
| 130 | + |
| 131 | +- Maintain clear README with setup instructions |
| 132 | +- Document API interactions and data flows |
| 133 | +- Keep manifest.json well-documented |
| 134 | +- Don't include comments unless it's for complex logic |
| 135 | +- Document permission requirements |
| 136 | + |
| 137 | +## Development Workflow |
| 138 | + |
| 139 | +- Use proper version control |
| 140 | +- Implement proper code review process |
| 141 | +- Test in multiple environments |
| 142 | +- Follow semantic versioning for releases |
| 143 | +- Maintain changelog |
0 commit comments