.cursorrules (deprecated)
.cursorrules.cursorrulesroot
Quality
96/100
Scores the file, not the repository.Length
1,218 words
41 headings · 6 code blocksRepository
17
— · pushed 200 days agoLast changed
3 days ago
First indexed 3 days ago.1# Cursor Rules for Megarepo - AI Setup Repository23You are an expert AI developer working in the Megarepo, a comprehensive AI setup repository designed for AI-related projects. Follow these rules when assisting with code development, analysis, and project setup.45## Repository Overview67This is a minimal AI setup repository template configured for Node.js/Next.js development. The repository serves as a foundation for AI-related projects and contains basic setup files with comprehensive development guidelines.89**Current State**: Minimal setup with basic configuration files10- Use these rules to guide development when source code is added11- Follow Node.js/Next.js patterns and best practices12- Prioritize AI-specific development patterns and security1314## Core Development Principles1516### 1. AI-First Development17- Prioritize AI integration patterns and best practices18- Consider model performance, API efficiency, and token usage19- Implement proper error handling for AI service failures20- Design for scalability with AI workloads2122### 2. Security & API Key Management23- **NEVER** commit API keys, secrets, or credentials to version control24- Always use environment variables for sensitive data25- Create `.env.example` files to document required environment variables26- Implement proper API key rotation and management patterns27- Use secure storage solutions for production deployments2829### 3. Code Quality Standards30- Write clean, readable, and well-documented code31- Use TypeScript for type safety when applicable32- Implement comprehensive error handling and logging33- Follow established linting and formatting rules34- Write meaningful commit messages and documentation3536## Technology Stack Guidelines3738### Node.js/Next.js Development39- Follow Next.js 13+ App Router patterns when applicable40- Use modern ES6+ JavaScript/TypeScript features41- Implement proper async/await patterns for AI API calls42- Use React Server Components where appropriate43- Optimize for both development and production environments4445### AI Integration Patterns46```javascript47// Preferred AI API integration pattern48const aiResponse = await fetch('/api/ai-service', {49 method: 'POST',50 headers: {51 'Content-Type': 'application/json',52 'Authorization': `Bearer ${process.env.AI_API_KEY}`53 },54 body: JSON.stringify({ prompt, options })55});5657if (!aiResponse.ok) {58 throw new Error(`AI service error: ${aiResponse.status}`);59}60```6162### Common AI Dependencies63When adding AI functionality, prefer these well-established packages:64- `openai` - Official OpenAI API client65- `@langchain/core` - LangChain framework66- `@vercel/ai` - Vercel AI SDK67- `@huggingface/inference` - Hugging Face API client6869## File Structure and Organization7071### Expected Project Structure72```73.74├── README.md # Project documentation75├── LICENSE # MIT license76├── .gitignore # Node.js/Next.js patterns77├── .cursorrules # This file78├── .env.example # Environment variable template79├── package.json # Dependencies and scripts80├── next.config.js # Next.js configuration81├── tsconfig.json # TypeScript configuration82├── src/83│ ├── app/ # Next.js app directory84│ ├── components/ # React components85│ ├── lib/ # Utility functions and AI clients86│ ├── types/ # TypeScript type definitions87│ └── utils/ # Helper functions88├── public/ # Static assets89└── docs/ # Additional documentation90```9192### Key Directories93- `src/lib/` - Place AI client configurations and utilities here94- `src/components/` - Reusable UI components, including AI-powered components95- `src/app/api/` - API routes for AI services and integrations96- `src/types/` - TypeScript definitions for AI responses and data models9798## Development Workflow99100### Before Writing Code1011. Check if `package.json` exists before running npm commands1022. Review existing environment variable requirements1033. Understand the AI service integrations being used1044. Consider rate limiting and usage patterns105106### Code Development1071. Write TypeScript definitions for AI API responses1082. Implement proper error handling for AI service failures1093. Add loading states and user feedback for AI operations1104. Consider performance implications of AI API calls1115. Implement caching strategies where appropriate112113### Testing AI Components114```javascript115// Example AI component test pattern116describe('AI Chat Component', () => {117 it('handles API errors gracefully', async () => {118 // Mock AI service failure119 mockAIService.mockRejectedValue(new Error('API Error'));120121 render(<ChatComponent />);122123 // Test error handling and user feedback124 expect(screen.getByText(/error/i)).toBeInTheDocument();125 });126});127```128129## Environment Setup130131### Required Environment Variables132Create `.env.local` with these patterns:133```bash134# AI Service Keys135OPENAI_API_KEY=your_openai_key_here136ANTHROPIC_API_KEY=your_anthropic_key_here137138# Application Settings139NEXT_PUBLIC_APP_URL=http://localhost:3000140NODE_ENV=development141142# Database (if needed)143DATABASE_URL=your_database_url_here144```145146### Development Commands147When `package.json` exists, use these commands:148```bash149npm install # Install dependencies150npm run dev # Start development server151npm run build # Production build152npm run test # Run tests153npm run lint # Run linter154npm run type-check # TypeScript validation155```156157## AI-Specific Best Practices158159### 1. Prompt Engineering160- Store prompts in separate files or constants161- Use template literals for dynamic prompt generation162- Implement prompt versioning for A/B testing163- Consider token limits and optimize prompt length164165### 2. Response Handling166- Always validate AI responses before using them167- Implement fallback mechanisms for failed requests168- Log AI interactions for debugging and monitoring169- Handle streaming responses appropriately170171### 3. Performance Optimization172- Cache AI responses when appropriate173- Implement request debouncing for user inputs174- Use background processing for long-running AI tasks175- Consider edge functions for AI API proxying176177### 4. User Experience178- Provide clear loading indicators for AI operations179- Implement progressive disclosure for complex AI features180- Give users control over AI behavior and settings181- Provide feedback mechanisms for AI output quality182183## Code Style and Formatting184185### TypeScript Preferences186- Use strict type checking187- Define interfaces for all AI API responses188- Use union types for AI model selections189- Implement proper error type definitions190191### React Patterns192- Use functional components with hooks193- Implement proper cleanup for AI subscriptions194- Use React.memo for expensive AI-powered components195- Handle loading and error states consistently196197### API Development198- Follow RESTful principles for AI service endpoints199- Implement proper rate limiting and authentication200- Use middleware for common AI service operations201- Document API endpoints with clear examples202203## Error Handling and Monitoring204205### AI Service Errors206```javascript207// Comprehensive error handling pattern208try {209 const response = await aiClient.complete(prompt);210 return response;211} catch (error) {212 if (error.code === 'rate_limit_exceeded') {213 // Implement backoff strategy214 await delay(exponentialBackoff(retryCount));215 return retry();216 } else if (error.code === 'insufficient_quota') {217 // Handle quota issues218 throw new QuotaExceededError('AI service quota exceeded');219 } else {220 // Log and handle unexpected errors221 logger.error('AI service error', error);222 throw new AIServiceError('Unexpected AI service error');223 }224}225```226227### Monitoring and Logging228- Log AI API usage and costs229- Monitor response times and error rates230- Track user interactions with AI features231- Implement health checks for AI services232233## Documentation Requirements234235### Code Documentation236- Document all AI-related functions and components237- Include usage examples for AI integrations238- Explain prompt engineering decisions239- Document environment setup requirements240241### API Documentation242- Document all AI service endpoints243- Include request/response examples244- Explain rate limiting and authentication245- Provide troubleshooting guides246247## Security Considerations248249### Data Privacy250- Avoid sending sensitive user data to AI services251- Implement data anonymization where possible252- Follow GDPR and privacy regulations253- Document data usage and retention policies254255### API Security256- Validate all inputs before sending to AI services257- Implement proper CORS settings258- Use HTTPS for all AI API communications259- Regularly rotate API keys and secrets260261Remember: This repository is designed as a foundation for AI projects. Always consider the specific AI use case when implementing features, and prioritize user experience, security, and performance in all AI-related development.
Also in HerringtonDarkholme/megarepo
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 |
|---|---|---|---|---|---|
| HerringtonDarkholme/megarepo.clinerules/03-documentation.md · 17 | Cline rules | securitydocs | 50/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.cursor/rules/code-quality.mdc · 17 | Cursor rules | teststyletypestesting-strategy+3 | 58/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.cursor/rules/project-structure.mdc · 17 | Cursor rules | stylearchui | 66/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.github/copilot-instructions.md · 17 | Copilot instructions | setupbuildtestlint-format+7 | 100/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.clinerules/README.md · 17 | Cline rules | archdo-not | 55/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.clinerules/01-core-principles.md · 17 | Cline rules | gitsecuritydeploymentdo-not+1 | 51/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.clinerules/02-development.md · 17 | Cline rules | setupbuildteststyle+3 | 92/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.clinerules/04-security.md · 17 | Cline rules | setupstylesecurityapi+1 | 65/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.cursor/rules/ai-development.mdc · 17 | Cursor rules | stylesecuritydependenciesapi+1 | 54/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.cursor/rules/prompt-engineering.mdc · 17 | Cursor rules | teststylearch | 70/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.cursor/rules/security.mdc · 17 | Cursor rules | setupstylesecuritydatabase+1 | 54/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.cursor/rules/testing-advanced.mdc · 17 | Cursor rules | teststyletesting-strategyperformance | 58/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.windsurf/rules/README.md · 17 | Windsurf rules | typesdo-not | 51/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.windsurf/rules/ai-development-core.md · 17 | Windsurf rules | do-notdocs | 45/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.windsurf/rules/ai-optimization.md · 17 | Windsurf rules | no sections | 30/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.windsurf/rules/documentation-standards.md · 17 | Windsurf rules | docs | 30/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.windsurf/rules/security-api-keys.md · 17 | Windsurf rules | securityapido-not | 37/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.windsurf/rules/testing-ai-components.md · 17 | Windsurf rules | testtesting-strategy | 34/100 | 3 days ago | |
| HerringtonDarkholme/megarepo.windsurf/rules/typescript-javascript.md · 17 | Windsurf rules | styletypesdo-not | 49/100 | 3 days ago | |
| HerringtonDarkholme/megarepoAGENTS.md · 17 | AGENTS.md | archagent-behaviour | 52/100 | 3 days ago |
Diff against .clinerules/03-documentation.md Diff against .cursor/rules/code-quality.mdc Diff against .cursor/rules/project-structure.mdc Diff against .github/copilot-instructions.md Diff against .clinerules/README.md Diff against .clinerules/01-core-principles.md Diff against .clinerules/02-development.md Diff against .clinerules/04-security.md Diff against .cursor/rules/ai-development.mdc Diff against .cursor/rules/prompt-engineering.mdc Diff against .cursor/rules/security.mdc Diff against .cursor/rules/testing-advanced.mdc Diff against .windsurf/rules/README.md Diff against .windsurf/rules/ai-development-core.md Diff against .windsurf/rules/ai-optimization.md Diff against .windsurf/rules/documentation-standards.md Diff against .windsurf/rules/security-api-keys.md Diff against .windsurf/rules/testing-ai-components.md Diff against .windsurf/rules/typescript-javascript.md Diff against AGENTS.md
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| SkeneTechnologies/skene-cookbook.cursorrules · 51 | .cursorrules | setuptestlint-formatstyle+11 | 96/100 | 2 days ago | |
| survivorforge/cursor-rulesrules/devops-docker/.cursorrules · 16 | .cursorrules | setupbuildteststyle+4 | 93/100 | 2 days ago | |
| survivorforge/cursor-rulesrules/devops-infrastructure/.cursorrules · 16 | .cursorrules | buildteststylesecurity+3 | 93/100 | 2 days ago | |
| survivorforge/cursor-rulesrules/api-microservices/.cursorrules · 16 | .cursorrules | buildteststylearch+5 | 92/100 | 2 days ago | |
| fall-out-bug/sdp_lab.cursorrules · 0 | .cursorrules | setupbuildtestlint-format+3 | 86/100 | 3 days ago | |
| bashdeban/fastmind.cursorrules · 5 | .cursorrules | buildtestlint-formattypes+5 | 81/100 | 3 days ago | |
| storybookjs/storybook.cursorrules · 91k | .cursorrules | teststylearchdo-not+1 | 78/100 | 3 days ago | |
| forem/forem.cursorrules · 23k | .cursorrules | teststyletypesdatabase+4 | 71/100 | 3 days ago |
