.cursorrules Next.js TypeScript Tailwind copy # Project Overview This project, named Astral, the Block Explorer of Autonomys network, is built using Next.js and TypeScript. It integrates various libraries for state management, UI components, and data fetching. # Key URLs - Astral Block Explorer: https://explorer.autonomys.xyz/ - GitHub Repository: https://github.com/autonomys/astral - Autonomys: https://autonomys.xyz/ - Academy: https://academy.autonomys.xyz/ - Documentation: https://docs.autonomys.xyz/ # Project Structure - **Components**: Contains reusable UI components. - **App**: Next.js app for routing. - **Hooks**: Custom React hooks for state management. # Development Guidelines - Use TypeScript for type safety. - Follow the coding standards defined in the ESLint configuration. - Ensure all components are responsive and accessible. - Use Tailwind CSS for styling, adhering to the defined color palette. # Important Scripts - `dev`: Starts the development server. - `build`: Builds the application for production. # AI Interaction Guidelines - When generating code, prioritize TypeScript and React best practices. - Ensure that any new components are reusable and follow the existing design patterns. - Minimize the use of AI generated comments, instead use clearly named variables and functions. - Always validate user inputs and handle errors gracefully. - Use the existing components and pages as a reference for the new components and pages. # Lexicon of Terms and Concepts - **H+AI (Human + Artificial Intelligence)**: The collaboration between humans and AI to enhance capabilities and ensure a harmonious coexistence. - **Autonomys Network**: A decentralized network designed to provide infrastructure for AI-powered decentralized applications (dApps). - **deAI Ecosystem**: A stack of components that includes distributed storage, compute, and a dApp/agent layer for building and deploying AI applications. - **Distributed Storage**: A system ensuring data integrity and availability for AI-related data. - **Distributed Compute**: Scalable computational resources for AI training and inference. - **dApp (Decentralized Application)**: Applications that run on a decentralized network, providing enhanced security and transparency. # Additional Resources - [Next.js Documentation](https://nextjs.org/docs) - [TypeScript Handbook](https://www.typescriptlang.org/docs/) - [Tailwind CSS Documentation](https://tailwindcss.com/docs) - [React Documentation](https://reactjs.org/docs/getting-started.html) - [Autonomys Overview](https://autonomys.xyz/) Cursor AI by @Marc-Aurele Besner
.cursorrules JavaScript TypeScript Code Quality copy # Persona You are a senior full-stack developer. One of those rare 10x developers that has incredible knowledge. # Coding Guidelines Follow these guidelines to ensure your code is clean, maintainable, and adheres to best practices. Remember, less code is better. Lines of code = Debt. # Key Mindsets **1** **Simplicity**: Write simple and straightforward code. **2** **Readability**: Ensure your code is easy to read and understand. **3** **Performance**: Keep performance in mind but do not over-optimize at the cost of readability. **4** **Maintainability**: Write code that is easy to maintain and update. **5** **Testability**: Ensure your code is easy to test. **6** **Reusability**: Write reusable components and functions. Code Guidelines **1** **Utilize Early Returns**: Use early returns to avoid nested conditions and improve readability. **2** **Conditional Classes**: Prefer conditional classes over ternary operators for class attributes. **3** **Descriptive Names**: Use descriptive names for variables and functions. Prefix event handler functions with "handle" (e.g., handleClick, handleKeyDown). **4** **Constants Over Functions**: Use constants instead of functions where possible. Define types if applicable. **5** **Correct and DRY Code**: Focus on writing correct, best practice, DRY (Don't Repeat Yourself) code. **6** **Functional and Immutable Style**: Prefer a functional, immutable style unless it becomes much more verbose. **7** **Minimal Code Changes**: Only modify sections of the code related to the task at hand. Avoid modifying unrelated pieces of code. Accomplish goals with minimal code changes. Comments and Documentation * **Function Comments**: Add a comment at the start of each function describing what it does. * **JSDoc Comments**: Use JSDoc comments for JavaScript (unless it's TypeScript) and modern ES6 syntax. Function Ordering * Order functions with those that are composing other functions appearing earlier in the file. For example, if you have a menu with multiple buttons, define the menu function above the buttons. Handling Bugs * **TODO Comments**: If you encounter a bug in existing code, or the instructions lead to suboptimal or buggy code, add comments starting with "TODO:" outlining the problems. Example Pseudocode Plan and Implementation When responding to questions, use the Chain of Thought method. Outline a detailed pseudocode plan step by step, then confirm it, and proceed to write the code. Here’s an example: # Important: Minimal Code Changes **Only modify sections of the code related to the task at hand.** **Avoid modifying unrelated pieces of code.** **Avoid changing existing comments.** **Avoid any kind of cleanup unless specifically instructed to.** **Accomplish the goal with the minimum amount of code changes.** **Code change = potential for bugs and technical debt.** Follow these guidelines to produce high-quality code and improve your coding skills. If you have any questions or need clarification, don’t hesitate to ask! Cursor AI by @Thomas Haferlach
.cursorrules Code Guidelines copy 1. **Verify Information**: Always verify information before presenting it. Do not make assumptions or speculate without clear evidence. 2. **File-by-File Changes**: Make changes file by file and give me a chance to spot mistakes. 3. **No Apologies**: Never use apologies. 4. **No Understanding Feedback**: Avoid giving feedback about understanding in comments or documentation. 5. **No Whitespace Suggestions**: Don't suggest whitespace changes. 6. **No Summaries**: Don't summarize changes made. 7. **No Inventions**: Don't invent changes other than what's explicitly requested. 8. **No Unnecessary Confirmations**: Don't ask for confirmation of information already provided in the context. 9. **Preserve Existing Code**: Don't remove unrelated code or functionalities. Pay attention to preserving existing structures. 10. **Single Chunk Edits**: Provide all edits in a single chunk instead of multiple-step instructions or explanations for the same file. 11. **No Implementation Checks**: Don't ask the user to verify implementations that are visible in the provided context. 12. **No Unnecessary Updates**: Don't suggest updates or changes to files when there are no actual modifications needed. 13. **Provide Real File Links**: Always provide links to the real files, not the context generated file. 14. **No Current Implementation**: Don't show or discuss the current implementation unless specifically requested. 15. **Check Context Generated File Content**: Remember to check the context generated file for the current file contents and implementations. 16. **Use Explicit Variable Names**: Prefer descriptive, explicit variable names over short, ambiguous ones to enhance code readability. 17. **Follow Consistent Coding Style**: Adhere to the existing coding style in the project for consistency. 18. **Prioritize Performance**: When suggesting changes, consider and prioritize code performance where applicable. 19. **Security-First Approach**: Always consider security implications when modifying or suggesting code changes. 20. **Test Coverage**: Suggest or include appropriate unit tests for new or modified code. 21. **Error Handling**: Implement robust error handling and logging where necessary. 22. **Modular Design**: Encourage modular design principles to improve code maintainability and reusability. 23. **Version Compatibility**: Ensure suggested changes are compatible with the project's specified language or framework versions. 24. **Avoid Magic Numbers**: Replace hardcoded values with named constants to improve code clarity and maintainability. 25. **Consider Edge Cases**: When implementing logic, always consider and handle potential edge cases. 26. **Use Assertions**: Include assertions wherever possible to validate assumptions and catch potential errors early. Cursor AI by @Hamza Farhan
.cursorrules Astro TypeScript copy { "rules": { "commit_message_guidelines": { "description": "Guidelines for creating conventional commit messages.", "format": { "description": "The format for commit messages using the conventional commits spec.", "body": "[optional scope]: \n\n[optional body]\n\n[optional footer(s)]" }, "enabled": true, "rules": [ { "description": "Always suggest a conventional commit with a type and optional scope in lowercase letters." }, { "description": "Keep the commit message concise and within 60 characters." }, { "description": "Ensure the commit message is ready to be pasted into the terminal without further editing." }, { "description": "Provide the full command to commit, not just the message." } ], "examples": [ { "prompt": " /commit", "response": "git commit -m 'feat: add responsive navbar with TailwindCSS'" } ] }, "development_guidelines": { "description": "Guidelines for developing code with Astro, TypeScript, and TailwindCSS.", "enabled": true, "rules": [ { "description": "Enforce strict TypeScript settings, ensuring type safety across the project." }, { "description": "Use TailwindCSS for all styling, keeping the utility-first approach in mind." }, { "description": "Ensure Astro components are modular, reusable, and maintain a clear separation of concerns." } ] }, "coding_style": { "description": "Guidelines for maintaining consistent coding style.", "enabled": true, "rules": [ { "description": "Code must start with path/filename as a one-line comment." }, { "description": "Comments should describe purpose, not effect." }, { "description": "Prioritize modularity, DRY principles, and performance." } ] }, "custom_slash_commands": { "description": "Custom slash commands.", "enabled": true, "commands": [ { "name": "/commit", "description": "Generate a Git commit message using the conventional commits spec.", "enabled": true } ] } } } Cursor AI by @Jaime Aleman