| 1 | Set 5-10 clear project rules upfront so Cursor knows your structure and constraints. Try /generate rules for existing codebases. | 预先设定5-10条明确的项目规则,让Cursor了解你的结构和限制。对于现有代码库,可以尝试使用/generate rules命令。 |
| 2 | Be specific in prompts. Spell out tech stack, behavior, and constraints like a mini spec. | 在提示中要具体明确。像写一份微型规格书一样,详细说明技术栈、行为和约束条件。 |
| 3 | Work file by file; generate, test, and review in small, focused chunks. | 逐文件处理;以小而专注的模块为单位进行生成、测试和审查。 |
| 4 | Write tests first, lock them, and generate code until all tests pass. | 先写测试,锁定它们,然后生成代码直到所有测试通过。 |
| 5 | Always review AI output and hard‑fix anything that breaks, then tell Cursor to use them as examples. | 始终审查AI的输出,对任何出错的地方进行硬性修复,然后告诉Cursor以这些修复作为示例。 |
| 6 | Use @ file, @ folders, @ git to scope Cursor's attention to the right parts of your codebase. | 使用@file、@folders、@git来限定Cursor对代码库中正确部分的注意力范围。 |
| 7 | Keep design docs and checklists in .cursor/ so the agent has full context on what to do next. | 将设计文档和检查清单保存在.cursor/目录下,这样代理就能全面了解下一步该做什么。 |
| 8 | If code is wrong, just write it yourself. Cursor learns faster from edits than explanations. | 如果代码有误,直接自己动手修改。Cursor从编辑中学习的速度比解释更快。 |
| 9 | Use chat history to iterate on old prompts without starting over. | 利用聊天记录迭代旧提示,无需从头开始。 |
| 10 | Choose models intentionally. Gemini for precision, Claude for breadth. | 有意识地选择模型。Gemini用于精确性,Claude用于广度。 |
| 11 | In new or unfamiliar stacks, paste in link to documentation. Make Cursor explain all errors and fixes line by line. | 在新的或不熟悉的技术栈中,粘贴文档链接。让Cursor逐行解释所有错误和修复。 |
| 12 | Let big projects index overnight and limit context scope to keep performance snappy. | 让大项目过夜索引,并限制上下文范围以保持性能敏捷。 |
### 1. 设定明确的项目规则
**核心:** 预先设定5-10条明确的项目规则,让Cursor了解你的结构和限制
**操作:**
- 对于现有代码库,使用 `/generate rules` 命令
- 在项目根目录创建 `.cursorrules` 文件
- 定义代码风格、架构约束、命名规范
**基础示例:**
```
- 使用Spring Boot 1.5.13 + Spring Cloud Edgware.SR4架构
I'll analyze the codebase structure and create comprehensive Cursor Rules to help with navigation and understanding of this microservices project. Let me first examine some key files to understand the architecture better.
Now let me check a few more key files to understand the other services:
Now I'll create comprehensive Cursor Rules for this microservices project. Let me create the rules directory and add the rule file:
```plaintext
# Microservices Architecture Guide
## Project Overview
This is a microservices-based parking management system built with Spring Boot 1.5.13 and Spring Cloud Edgware.SR4. The project consists of 4 main microservices organized as Maven modules under the parent POM [pom.xml](mdc:pom.xml).
## Project Structure
### Parent Project
- **Root**: [pom.xml](mdc:pom.xml) - Main Maven parent POM with shared dependencies
- **Architecture**: Multi-module Maven project with Spring Cloud microservices
- **Version**: 1.1.0 with Java 8 and custom framework version 1.1.0
### Microservices Overview
#### 1. micro-cloud-adapter
- **Purpose**: MQTT Gateway and IoT Device Adapter
This rule provides a high-level overview of your project structure including:
-**Project Overview**: Spring Boot 1.5.13 + Spring Cloud microservices architecture
-**Service Breakdown**: Detailed description of all 4 microservices (cloud-adapter, cprs, dts, edrs)
-**Key Technologies**: Spring Cloud, Redis, Kafka, MQTT, MyBatis, etc.
-**Configuration Management**: Template files and environment setup
-**Development Guidelines**: Best practices for adding features and service communication
### 2. **Coding Patterns and Conventions** (`.cursor/rules/coding-patterns.mdc`)
This rule focuses on implementation details and coding standards:
-**Package Structure**: Standardized layout across all services
-**Spring Boot Patterns**: Consistent annotations and configuration approaches
-**Service Communication**: Feign clients, circuit breakers, and message queues
-**Data Access**: MyBatis integration and entity patterns
-**Caching**: Redis patterns and key management
-**Naming Conventions**: Class and method naming standards
## 🎯 Key Benefits
These rules will help you and your team:
-**Navigate** the codebase more efficiently with direct file references
-**Understand** the architecture and service responsibilities
-**Follow** established patterns when adding new features
-**Maintain** consistency across the microservices
-**Troubleshoot** issues by understanding the system structure
The rules include direct file links using the `[filename](mdc:filename)` format, making it easy to jump to relevant files when working on specific features or debugging issues.
Your Cursor IDE will now have comprehensive context about this parking management microservices system, including the MQTT gateway functionality, core processing services, data synchronization, and external routing capabilities.