Awesome Cursor Rules Collection

Showing 2281-2292 of 2626 matches

Java
You are an expert in Android development, Java, Android Studio, and related technologies.

**Code Style and Structure**
- Write clean, efficient, and well-documented Android code.
- Follow Android best practices and design patterns.
- Use modern Android architecture components (e.g., MVVM, LiveData, ViewModel).
- Structure Android applications into modules: Activities, Fragments, Views, ViewModels, and Repositories.
- Follow Kotlin conventions and idioms for concise, expressive code.

**Android-Specifics**
- Use Jetpack libraries for UI, data persistence, and lifecycle management.
- Implement RESTful API interactions with Retrofit or Ktor.
- Utilize Room for local database management.
- Leverage Coroutine-based asynchronous programming for background tasks.
- Use Hilt or Dagger for dependency injection.
- Optimize for various screen sizes and densities (responsive layouts).

**Naming Conventions**
- Use camelCase for method and variable names (e.g., getUserData, isUserLoggedIn).
- Use PascalCase for class names (e.g., UserActivity, UserRepository).
- Use ALL_CAPS for constants (e.g., MAX_RETRIES, BASE_URL).

**Android UI and UX**
- Design clean and intuitive user interfaces with Material Design principles.
- Implement RecyclerView for list-based UIs.
- Ensure proper handling of configuration changes (e.g., orientation changes, multi-window).
- Use ConstraintLayout for flexible layouts.

**Data and API Usage**
- Use Retrofit for API calls and handle errors properly.
- Implement ViewModels to manage UI-related data.
- Use LiveData or StateFlow for reactive data observation.
- Leverage Room for local data storage with proper migration strategies.

**Performance and Scalability**
- Optimize application performance by minimizing background operations.
- Use memory-efficient techniques (e.g., image loading libraries like Glide or Picasso).
- Minimize unnecessary UI updates and heavy computation on the main thread.

**Security**
- Use Android’s EncryptedSharedPreferences or Keystore for sensitive data storage.
- Implement proper authentication mechanisms (e.g., OAuth, Firebase Auth).
- Ensure safe handling of user permissions and data privacy.

**Testing**
- Write unit tests using JUnit and Mockito.
- Use Espresso for UI testing.
- Implement UI tests with the Android Test Framework.
- Write instrumented tests for application behavior on real devices.

**Logging and Monitoring**
- Use Logcat for logging during development.
- Implement crash reporting with Firebase Crashlytics.
- Monitor app performance using Android Vitals.

**Build and Deployment**
- Use Gradle for build automation.
- Implement proper flavors and build variants for different environments (dev, prod).
- Optimize APK size and build time.

**Follow best practices for:**
- Efficient handling of background tasks (e.g., WorkManager).
- User interface responsiveness and smooth interactions.
- Proper usage of background services and notifications.

Adhere to SOLID principles and maintain clean architecture in your Android application design.
express.js
firebase
java
kotlin
oauth
react
rest-api
solidjs

First seen in:

yanayusman/WIA2007-MAD

Used in 1 repository

TypeScript
You are an expert in TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Radix UI, Drizzle, and Tailwind.

## Code Style and Structure

- Write concise, technical TypeScript code with accurate examples.
- Use functional and declarative programming patterns; avoid classes.
- Prefer iteration and modularization over code duplication.
- Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
- Structure files: exported component, subcomponents, helpers, static content, types.
- Use the Receive an Object, Return an Object (RORO) pattern.
- Server actions code should be placed in the '@/actions/\*' directory.
- Zod schemas should be placed in the '@/models/\*' directory.
- Data fetching code should be placed in the '@/data/\*' directory.

## Naming Conventions

- Use lowercase with dashes for directories (e.g., components/auth-wizard).
- Favor named exports for components.

## JavaScript/TypeScript

- Use TypeScript for all code; prefer interfaces over types.
- Avoid enums; use maps instead.
- Use the "function" keyword for pure functions. Omit semicolons.
- Avoid unnecessary curly braces in conditional statements.
- For single-line statements in conditionals, omit curly braces.
- Use concise, one-line syntax for simple conditional statements (e.g., if (condition) doSomething()).
- Use functional components with TypeScript interfaces.
- Use declarative JSX.
- Place static content and interfaces at file end.
- Use content variables for static content outside render functions.

## UI and Styling

- Use Shadcn UI, Radix, and Tailwind for components and styling.
- Implement responsive design with Tailwind CSS; use a mobile-first approach.

## Performance and Optimization

- Minimize 'use client', 'useEffect', and 'setState'. Favor React Server Components (RSC).
- Wrap client components and components that use searchParams in Suspense with fallback.
- Use dynamic loading for non-critical components.
- Optimize images: WebP format, size data, lazy loading.

## Server Actions and API

- Use next-safe-action for all server actions:
  - Implement type-safe server actions with proper validation using the authActionClient (authenticated) or actionClient, e.g. `import { authActionClient } from '@/lib/safe-action'`.
  - Place action code in the '@/actions/\*' directory.
  - Place Zod schemas in the '@/models/\*' directory.
  - Utilize the `useAction` hook from next-safe-action for client-side components, e.g. `import { useAction } from 'next-safe-action/hooks'`.
  - Implement consistent error handling and success responses using ActionResponse.
  - Use the `import { renderSafeActionErrorToast } from '@components/render-safe-action-error-toast'`and the `onError` callback function from the useAction hook to render error toasts.

## Error Handling and Validation

- Prioritize error handling and edge cases:
  - Handle errors and edge cases at the beginning of functions.
  - Use early returns for error conditions to avoid deeply nested if statements.
  - Place the happy path last in the function for improved readability.
  - Avoid unnecessary else statements; use if-return pattern instead.
  - Use guard clauses to handle preconditions and invalid states early.
  - Implement proper error logging and user-friendly error messages.
  - Consider using custom error types or error factories for consistent error handling.
  - Model expected errors as return values; avoid using try/catch for expected errors in Server Actions.
  - Use error boundaries (error.tsx and global-error.tsx) for unexpected errors to provide a fallback UI.
  - Use Zod for form validation.

## Database

- Use Drizzle ORM for all database interactions to ensure type safety and consistency.
- Define database schemas using Drizzle ORM's schema definitions in TypeScript.
- Almost every table should have timestamps (createdAt, updatedAt) and auth related fields (userId, orgId).
- Avoid raw SQL queries; utilize Drizzle ORM's query builder for constructing queries.
- Leverage TypeScript inference provided by Drizzle ORM to ensure strict typing in database operations.
- Implement relations using Drizzle ORM's relation APIs for one-to-one, one-to-many, and many-to-many associations.
- Optimize database performance by defining indexes and constraints within your Drizzle ORM schema definitions.
- Use transactions (db.transaction) provided by Drizzle ORM for atomic and consistent database operations.
- Prefer built-in operators and functions of Drizzle ORM; use the sql tagged template only for advanced queries when necessary.

## Key Conventions

1. Rely on Next.js App Router for state changes.
2. Prioritize Web Vitals (LCP, CLS, FID).
3. Minimize 'use client' usage:
   - Prefer server components and Next.js SSR features.
   - Use 'use client' only for Web API access in small components.
   - Avoid using 'use client' for data fetching or state management.
4. Use 'nuqs' for URL search parameter state management.

Refer to Next.js documentation for Data Fetching, Rendering, and Routing best practices.
css
drizzle-orm
java
javascript
mdx
nestjs
next.js
plpgsql
+5 more

First seen in:

feliche93/felixvemmer

Used in 1 repository

Python
Follow priciples of TDD and keep the scope very small

Only focus on the necessary testing that will achieve a level of quality to merge the changes that are in current branch.You will may to compare it to the main branch.

Any context that you need, get it before proceding to the next decision.

Remember to avoid changing the app just to get a test to work but if you think it's warranted, then present the justification and ensure that it stays within the proper scoping to get the feature merged.

Work on very small changes at a time, so that we keep the scope very small.

Focus on the necessary testing that will achieve a level of quality to merge the changes that are in the current branch.

If you need to change the app to get a test to work, then present the justification and ensure that it stays within the proper scoping to get the feature merged.

You must perform the necessary testing to ensure that the changes are working as expected and that the code is of high quality.

Create a new branch for each feature and merge it into the main branch.

Create new bug fixes as needed but keep the scope very small and only focus on the necessary testing that will achieve a level of quality to merge the changes that are in the current branch. The bug fix should be narrow in scope and only fix the specific issue.

Each commit should be a single change and should be atomic.

When attempting to fix a bug, try to fix the root cause of the bug and not just the symptom. Gather all the information you need to isolate the root cause of the bug before proceeding to fix it.

You must activate the virtual environment before running commands.

Look at the [text](ai-deep-stock-analyzer.txt) for an example to draw from for the project when deciding on features to implement.

Test early and often.


Follow the [implementation plan](docs/implementation_plan.md) for the project.

Keep the documentation up to date with the code.
python

First seen in:

dglewis/trend-signal

Used in 1 repository

Python
# Tech Transfer Pipeline Rules

## Codebase Structure
This is a pipeline for scraping, summarizing, and embedding technology transfer listings. It consists of:

1. Core Services:
   - scraper.py: Web scraping using AgentQL and Playwright
   - summarization_service.py: AI summarization using DeepSeek
   - embedding_service.py: Vector embeddings using Pinecone
   - run_pipeline.py: Pipeline orchestrator

2. Documentation:
   - README.md: Main documentation and usage guide
   - data_format.md: Data structure specifications
   - LICENSE: MIT license

3. Data:
   - data/*.json: JSON files containing tech transfer data
   - data/.gitkeep: Maintains directory structure

## Documentation Rules

When modifying files, update the following documentation:

1. If changing data formats:
   - Update data_format.md
   - Update relevant sections in README.md
   - Update docstrings in affected services

2. If modifying scraper.py:
   - Update AgentQL queries in code comments
   - Update data_format.md "After Scraping" section
   - Update README.md scraper customization section

3. If modifying summarization_service.py:
   - Update prompt templates in code comments
   - Update data_format.md "After Summarization" section
   - Update README.md summarizer customization section

4. If modifying embedding_service.py:
   - Update metadata fields in code comments
   - Update data_format.md "Vector Database Format" section
   - Update README.md embedder customization section

5. If modifying run_pipeline.py:
   - Update pipeline steps in code comments
   - Update README.md pipeline execution section

## File Dependencies

- scraper.py → data/[university]_results.json
- summarization_service.py → data/[university]_results_summarized.json
- embedding_service.py reads from data/*.json
- run_pipeline.py imports all services

## Environment Variables

When modifying services, ensure .env requirements are documented in:
- README.md setup section
- .env.example (if exists)
- Relevant service files

## Error Handling

When modifying error handling:
- Update README.md troubleshooting section
- Update error screenshots naming convention
- Update logging configuration

## Command Line Arguments

When adding/modifying CLI arguments:
- Update README.md usage section
- Update argparse help text
- Update pipeline orchestrator if needed

## Code Style

Follow these conventions:
- Use docstrings for all functions
- Include type hints where helpful
- Keep consistent error handling patterns
- Maintain modular service structure

## Testing

When adding features:
- Add example usage in README.md
- Update troubleshooting guides
- Document edge cases

## Version Control

- Keep data directory structure but ignore contents
- Track all documentation changes
- Include meaningful commit messages 
playwright
python
andrew-medrano/scraping_agent

Used in 1 repository

TypeScript

  You are an expert in TypeScript, Node.js, Next.js App Router, React, Shadcn UI, Radix UI and Tailwind.
  
  Code Style and Structure
  - Write concise, technical TypeScript code with accurate examples.
  - Use functional and declarative programming patterns; avoid classes.
  - Prefer iteration and modularization over code duplication.
  - Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError).
  - Structure files: exported component, subcomponents, helpers, static content, types.
  
  Naming Conventions
  - Use lowercase with dashes for directories (e.g., components/auth-wizard).
  - Favor named exports for components.
  
  TypeScript Usage
  - Use TypeScript for all code; prefer interfaces over types.
  - Avoid enums; use maps instead.
  - Use functional components with TypeScript interfaces.
  
  Syntax and Formatting
  - Use the "function" keyword for pure functions.
  - Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.
  - Use declarative JSX.
  
  UI and Styling
  - Use Shadcn UI, Radix, and Tailwind for components and styling.
  - Implement responsive design with Tailwind CSS; use a mobile-first approach.
  
  Performance Optimization
  - Minimize 'use client', 'useEffect', and 'setState'; favor React Server Components (RSC).
  - Wrap client components in Suspense with fallback.
  - Use dynamic loading for non-critical components.
  - Optimize images: use WebP format, include size data, implement lazy loading.
  
  Key Conventions
  - Use 'nuqs' for URL search parameter state management.
  - Optimize Web Vitals (LCP, CLS, FID).
  - Limit 'use client':
    - Favor server components and Next.js SSR.
    - Use only for Web API access in small components.
    - Avoid for data fetching or state management.
  
  Follow Next.js docs for Data Fetching, Rendering, and Routing.
  
  Please write me a web application in this mentioned stlye for a app with the following features:
  - please install all necessary npm packages first at the end the app should fully work and run in dev mode
  - it will be a notes app
  - a entry where cou can add a new note
  - a list of all notes
  - a detail page for each note
  - a edit page for each note
  - a delete button for each note
  - please also add a search field to the list of notes
  - please also add a filter field to the list of notes
  - please also add a sort field to the list of notes
  - please also add a pagination to the list of notes
  - please also add a loading state to the list of notes
  - please also add a error state to the list of notes
  - please add a drag and drop feature to the list of notes
css
javascript
next.js
npm
radix-ui
react
shadcn/ui
tailwindcss
+1 more

First seen in:

ChrisFeldmeier/notes-app

Used in 1 repository

Java
When revising or creating JavaDoc comments and inline comments for Java code, please follow these guidelines:

1. Comprehensive Explanation:
   - Provide a clear, step-by-step explanation of the algorithm or design pattern.
   - Explain the "why" behind design decisions, not just the "how".
   - Relate the code to real-world applications and modern Java development practices.

2. Complexity Analysis:
   - Include time complexity analysis for worst, best, and average cases.
   - Discuss space complexity and any trade-offs between time and space.
   - Compare the efficiency with alternative implementations or data structures.

3. Modern Java Features:
   - Highlight the use of modern Java features (e.g., lambdas, streams, optional) where applicable.
   - Explain how these features enhance readability, maintainability, or performance.

4. Design Patterns and Principles:
   - Identify and explain any design patterns used in the code.
   - Discuss how the code adheres to SOLID principles and other best practices.
   - Suggest potential refactoring to better align with design patterns if applicable.

5. Concurrency and Performance:
   - Address any concurrency considerations or potential issues.
   - Discuss performance optimizations and their impact.
   - Mention relevant Java concurrency utilities if applicable.

6. Error Handling and Robustness:
   - Explain error handling strategies and exception hierarchies.
   - Discuss input validation and edge cases.

7. Testing and Debugging:
   - Provide insights on how to effectively test the code.
   - Mention relevant testing frameworks (e.g., JUnit 5, Mockito).
   - Offer debugging tips for common issues.

8. Integration and Scalability:
   - Discuss how the code integrates with larger systems or frameworks (e.g., Spring).
   - Address scalability concerns for cloud-native or microservices architectures.

9. Security Considerations:
   - Highlight any security best practices implemented in the code.
   - Suggest additional security measures if relevant.

10. Code Style and Readability:
    - Emphasize clean code principles and consistent formatting.
    - Use meaningful variable names and modular structure.

11. Alternative Implementations:
    - Discuss potential alternative implementations using different Java collections or algorithms.
    - Compare trade-offs between different approaches.

12. Practical Applications:
    - Provide examples of real-world scenarios where this code or pattern is particularly useful.
    - Relate to industry practices and common use cases.

13. Advanced Topics:
    - If relevant, touch on advanced topics like reactive programming, big data processing, or machine learning integration.

14. Learning Resources:
    - Suggest additional learning resources or related topics for further exploration.

15. Continuous Improvement:
    - Encourage code reviews and continuous learning.
    - Mention the importance of staying updated with Java developments and community best practices.

Remember to tailor the level of detail to the complexity of the code and the intended audience (e.g., beginner, intermediate, or advanced Java developers). Strive for a balance between comprehensiveness and clarity, ensuring the documentation is both informative and accessible.
batchfile
css
golang
html
java
javascript
react
shell
+2 more

First seen in:

Surfer12/Recursion

Used in 1 repository